Uniform variables not listed when glGetActiveUniform is called

OS: Mandrake Linux 10.1 Official
GL_RENDERER: Quadro FX 4400/PCI/SSE2
GL_VERSION: 2.0.1 NVIDIA 81.78
GL_VENDOR: NVIDIA Corporation

I am having a problem with uniform variables. I can’t seem to get some of my uniform variables to be seen as active. I have a sampler2D in my frag shader, which is listed in the list of active uniforms when I call glGetActiveUniform. However when I add another uniform to the frag shader, for example

  
uniform vec3 SourceDirection;

this uniform is not listed in the list of active uniforms. I am using SourceDirection, so it should be active correct?

Any ideas?

Thanks,
CD

You say you used it, but was it really needed? :wink:
Post the whole vertex and fragment shaders.

Yes I need it… wouldn’t be trying to get the variable working if not… When I say I “used” it, I simply added something like:

vec3 temp = SourceDirection;

in an attempt to force it to be seen as active…

Can’t post the entire shader code… proprietary algorithms in them…

CD

When I say I “used” it, I simply added something like:
vec3 temp = SourceDirection;
in an attempt to force it to be seen as active…

That’s not what I meant with “needed”.
Any uniform or attribute which does not contribute anything to the final output can be eliminated by compilers.
If you added gl_FragColor = vec4(SourceDirection, 1.0);
in an executed branch, then that’s what I call needed.

Sorry… didn’t mean to come across as a smart-alec…

It appears my understanding of an active variable is in complete… From what you said “Any uniform or attribute which does not contribute anything to the final output can be eliminated by compilers” seems to say that simply “using” the variable in the body of the shader isn’t enough, but that it actually has to be something that is used to generate the final output… Is that correct?

Thanks,
CD

Originally posted by Relic:
[b] [quote] When I say I “used” it, I simply added something like:
vec3 temp = SourceDirection;
in an attempt to force it to be seen as active…

That’s not what I meant with “needed”.
Any uniform or attribute which does not contribute anything to the final output can be eliminated by compilers.
If you added gl_FragColor = vec4(SourceDirection, 1.0);
in an executed branch, then that’s what I call needed.[/b][/QUOTE]

Originally posted by Relic:
[b]
Any uniform or attribute which does not contribute anything to the final output can be eliminated by compilers.

If you added gl_FragColor = vec4(SourceDirection, 1.0);
in an executed branch, then that’s what I call needed.
[/b]
That was the problem… Thanks,

CD

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.