How can you tell in a shader if Directional light is “vertex lit” or “pixel lit”
so you can have either one work in same shader ? ( ForwardBase pass )
tried every #ifdef I could find nothing seems to work…
How can you tell in a shader if Directional light is “vertex lit” or “pixel lit”
so you can have either one work in same shader ? ( ForwardBase pass )
tried every #ifdef I could find nothing seems to work…
What exactly are you attempting to do? And by “vertex lit” are you referring to a non-important light?
Yeah so if they have a dir light set as non-important. then I will calc dir light in vertex shader
if its Important then in frag shader
Unity shaders and examples I found on net. all seem to be one or the other … I was hoping for a way to make it automatic
I guess I could make a script and detects if there is 1 dir light only and if its set to not important then set a shader keyword… but was hoping this was built into unity
Okay, so an important thing to understand. When you set a directional light to be non-important it gets baked into the ambient SH. The Standard shader will calculate the SH per vertex if the model has no normal map, otherwise it’s done per pixel. The 4 brightest affecting point lights (and spot lights) that are set to auto (after the pixel light count is exausted) or non-important get put into the data used by the Shade4PointLights() function. That is usually run per vertex, but importantly it does not include directional lights.
Basically, directional lights are never “vertex lights” in the forward base pass.
The ShadeVertexLights() and ShadeVertexLightsFull() functions, which includes directional lights and spot lights along with point light, only seem to work when used with “LightMode”=“Vertex” and terrain details. It used to work with “ForwardBase” as well, but it doesn’t seem to anymore.
thanks