Hi everyone! I’m looking to write a shader (surface shader, vertex, or frag) that edits the color from a light source ONLY IF it’s not a Directional Light. Is there any syntax in CG or another usable language for knowing what type of light is being evaluated?
Thank you!
The unity_LightPosition of a light is a 4d vector. The w coordinate of that vector tells you whether it is a directional light (it will be 0 for directional lights). To get a direction to the light basically you normally do:
unity_LightPosition[n].xyz - (vertexPostion * unity_LightPosition[n].w)
For directional lights the direction is already in xyz so the 0 w cancels out the vertex position - you can just check that. I can’t think how to do that in a surface shader so I’d be guessing you need a vertex/fragment shader.