Lighting shader color.w

Hi, I’m messing with the shaders and just wanted to check this 1 thing from the Lighting material vertex shader

float posLight = step(0.5, color.w); (color is g_LightColor)

color.w is the light type I believe, and light types are 0 1 and 2, so for a pointlight, value 1, then step function will return 1…?
I’m trying to re-create part of the shader, why is that done?

posLight will be 0 for directional lights and 1 for point and spot lights. It is done so the they can use same code for directional, point and spot lights event the calculations are slightly different. posLight is used like a branch statement (like if) without actual branching.

1 Like

Oh I see, thanks