PDA

View Full Version : shaders affecting eachother... annoying



Dragon89
02-23-2007, 03:14 AM
ive got two shaders... if i add a texture fetch in one of the shaders fragment program... then i get some bug in the others vertex program...

im getting alot of problems where changes in shader causes problem with the other shader that has nothin to do with the other... which forces me to keep some code i dont need like just a simple if statement that doesnt do anythin so that the other shader works properly...

what might be causing this?

tomtrenki
02-23-2007, 07:08 AM
sounds like a driver problem or bug. what's your hardware? and what problem do you have exactly?

Dragon89
02-23-2007, 07:54 AM
7800 GT


this is an example within the same shader...


THIS WORKS!

FinalColor = pow(FinalColor*exposure, gamma);

alpha.x = 1.0;
if (OverWater)
{
alpha.x = 1.0;
}

gl_FragColor = vec4(FinalColor, alpha.x);

THIS DOESNT

FinalColor = pow(FinalColor*exposure, gamma);
gl_FragColor = vec4(FinalColor, 1.0);


the difference..? there is none!

dorbie
02-23-2007, 09:24 AM
Both look OK but we don't see the declarations so we can't be sure for example that FinalColor is the vec3 the code assumes it is (of course that would break both versions, but you can't assess this without seeing the varyings out of your vertex and into your fragment shaders).

Komat
02-23-2007, 11:03 AM
Check that you load the shaders correctly. For example if you are using zero terminated strings, check that they are really zero terminated at correct place. You can use the NVEmulate (http://developer.nvidia.com/object/nvemulate.html) tool to see shader source code as it is seen by the driver.

k_szczech
02-23-2007, 02:08 PM
Komat made a good point. I once had an issue with my shader loading code. I was skipping newline characters. Everything was fine until I used #ifdef in shader :) Now I had one big preprocessor directive.
Not only this turned out to be a bug in my code, but it also coused the driver to enter endless loop. I reported driver bug and fixed my own - both are fixed now.
At first it could appear that that's purely driver bug, but it was also my fault of not passing the source code correctly.