I reached the point where the same function in hlsl works, but
in cg with opengl doesn't.
It's a very simple function that is going to calculate shading based on the spot cut off angle in the shader. This same func is called by another func
that is calculating the overall lighting.
The behaviour is that in hlsl I can see the smooth fall-off (thanks to the pow
func), but in CG using opengl I get hard edges.
I did some tests and it seems is going through just the first two if leaving the 3rd line like if it's not there. I
tried eliminating the two if statements, seeing what was happening, but then
I could see completely black. I'm sure the values of the cos of the angles are
correct since I checked them.
Those two screen will outline better the problem:
CG: http://img837.imageshack.us/i/spotlightcg.jpg/
HLSL: http://img541.imageshack.us/i/spotlighthlsl.jpg/
And here is the code of such a function:
float get_spotLight_influence(in Light light ,in float3 p ){ float cosTheta = dot(normalize(get_light_dir(light,p)),-normalize(light.lightDir)); if( cosTheta > light.cosPhi ) return 1.f; if( cosTheta < light.cosSigma ) return 0.f; return pow((cosTheta-light.cosSigma)/(light.cosSigma-light.cosPhi),50.f); //this line seems to be never reached at all in CG}
Any help would be appreciated, thanks