PDA

View Full Version : Are vertex attributes in a fragment shader valid?



LaBasX2
09-19-2008, 03:11 PM
I want to create a unified shader file similar to the D3D FX format where vertex and fragment shaders are in one file. I have some technique annotations that I parse manually and I create a main function on the fly. I just send the complete shader code to the GLSL compiler, either as vertex or fragment shader. For a fragment shader, the vertex shader functions are just stripped out by the compiler since they are not called from my entry function. But I also have vertex attributes in this file of course.

Can I safely assume that the fragment shader parser will just ignore them without outputting errors? A quick look at the spec did not give me any info about that. It seems to work on NVidia drivers but I want to make sure that I don't do anything "illegal" that could not work on other platforms/drivers.

Thanks in advance...

Korval
09-19-2008, 03:32 PM
Can I safely assume that the fragment shader parser will just ignore them without outputting errors?

No, it will not. It is not legal to define a vertex attribute in a non-vertex shader. It certainly won't in 1.3, with it's "in/out" stuff.

Brolingstanz
09-20-2008, 01:06 PM
Btw, NV's 1.3 compiler is really good about dumping deprecation warnings to the logs. Got a slew of them right off the bat ;-)