Hi,
i’ve a piece of code that isn’t working and i don’t know why…
This part of my vertex shader is just clamping a color (no matter it is a color could be anything else…) between 0 and 1 (cause I can get negative value when N.L is negative, don’t ask why )
float zeroValues[4] = { 0.f, 0.f, 0.f, 1.0f};
GLuint intensity;
GLuint temp;
GLuint temp2;
GLuint zero;
[snip]
intensity = glGenSymbolsEXT( GL_VECTOR_EXT, GL_LOCAL_EXT, GL_FULL_RANGE_EXT, 1);
temp = glGenSymbolsEXT( GL_VECTOR_EXT, GL_LOCAL_EXT, GL_FULL_RANGE_EXT, 1);
temp2 = glGenSymbolsEXT( GL_VECTOR_EXT, GL_LOCAL_EXT, GL_FULL_RANGE_EXT, 1);zero=glGenSymbolsEXT( GL_VECTOR_EXT, GL_LOCAL_CONSTANT_EXT, GL_FULL_RANGE_EXT, 1);
glSetLocalConstantEXT( zero, GL_FLOAT, &zeroValues);
[snip]glSwizzleEXT(temp, intensity, GL_ONE_EXT, GL_ONE_EXT, GL_ONE_EXT, GL_ONE_EXT);
glShaderOp3EXT( GL_OP_CLAMP_EXT, temp2, temp2, zero, temp);
glShaderOp2EXT( GL_OP_ADD_EXT, intensity, intensity, temp2);
[snip]
If in glSwizzleEXT(temp, intensity, GL_ONE_EXT, GL_ONE_EXT, GL_ONE_EXT, GL_ONE_EXT); i put anything but intensity the code is working.
With intensity as second parameter the effect i get is the same as if i was clamping in [0, 0] interval.
I don’t seek a solution, as I said it is working if i use another variable. I just want somebody to explain why it doesn’t work with intensity.
Or there is something i totally misunderstood how vertex shaders are working or there is some kind of bug (quite irritating, spent some time before trying another variable).
I do like the swizzling trick where you can make a vector [1,1,1,1] without declaring this vector as you must with NV’s vertex programs. (I know i could have done the same with my zero variable but i didn’t… for now )
Could someone explain me why this doesn’t work ?
Joel.