I am currently using a shader to execute some directional lights. I follow the tutorial on Lighthouse 3d ( http://www.lighthouse3d.com/tutorials/glsl-core-tutorial/directional-lights-per-pixel/ )
The problem I am facing is the following lines:
vec3 h = normalize(l_dir + e); float intSpec = max(dot(h, n), 0.0); float specularPower = pow(intSpec, shininess);
If I leave the line “float specularPower”, then the shader will no longer “work” .... I say “works” in quotes because I do not get any output or errors from Shader Log, however now there are single places for my entire return -1, and I can not set the texture location, etc.
If I remove it, the rest of the shader works as expected (but producing incorrect results due to the lack of Specular Power).
What is even more curious is that if I have nVidia Nsight Debugger connected, I get the output on the screen and it seems to work, but if I just use VS2012 in debug mode, I can’t see anything on the screen, and following error message:
First-chance exception at 0x000000005EB066E6 (nvoglv64.dll) in application.exe: 0xC0000005: Access violation reading location 0x0000000000000008. First-chance exception at 0x000000005EB066E6 (nvoglv64.dll) in application.exe: 0xC0000005: Access violation reading location 0x0000000000000008.
This behavior has been demonstrated on both the GTX 480 and GTX 560, on a PC with 64-bit Windows 8.
I know that -1, returned as a unified location, either means the wrong name, or the compiler optimized it, but there is no point in adding it to one line, the result of which is then not used at all after that. Even less does it make sense that the behavior is different from when the NSight debugger is connected or not.
What can i do wrong?
Edit:
The following are the simplest Vertex / Fragment shaders that I could create that replicate the problem while maintaining the real world shader.
Vertex Shader:
// Default Vertex Shader
Fragment Shader:
// Default Fragment Shader
I also checked the program information log and did not return any errors. Once again, with these shaders, it does not work (the uniform returns -1) when launched through VS2012, but it "works" when the nVidia Nsight debugger is connected.