I’m trying to render spotlight enabled scene but I’ve some trouble about fallof_angle What is fallof_angle exactly? I really look a dozen of books/web pages and not sure how to use this param. In OpenGL/GLSL cutoff angle is using to specify cone angle. But when I tried to use falloff_angle as cutoff angle then, my cone size become 2x bigger than original, when I used cut off angle = fallof_angle/2 then everythings look perfect! Any idea?
According Realtime Rendering book I guess fallof_angle is umbra angle and I found a formula in MSDN (https://msdn.microsoft.com/en-us/library/windows/desktop/bb172279(v=vs.85).aspx they used umbra angle / 2
Here how to I use fallof angle in my shader, vPosition and light.position are in view/camera space and direction is [0 0 -1] if there is no rotation, falloffCos is cosf(fall_of_angle):
... float spotCos; spotCos = dot(lights[i].direction, -normalize(lights[i].position - vPosition)); if (spotCos < lights[i].falloffCos) attn = 0.0; else attn *= pow(spotCos, lights[i].falloffExp); ...
Maybe I’ve some bugs but checked multiple times everythings(posiitons, coord space…) looks valid