Samplers in uniform buffer objects

I’d like to store samplers in a uniform buffer object. According to the wiki, this should be fine:

uniform Textures
{
	sampler2D diffuseTexture;
};

However, my NVidia driver complains that:

error C7554: OpenGL requires samplers to be explicitly declared as uniform

Did I miss something? Do I have to add the keyword uniform a 2nd time?!

In this wiki it is written that samplers cannot be part of uniform block. I have tested it with an ati card and here the info log:


 Fragment shader failed to compile with the following errors:
ERROR: 0:18: error(#6) Extension error: usage incorrect Sampler can be not in uniform block
ERROR: error(#273) 0 compilation errors.  No code generated


I don’t know where you found this because, no, sampler should not be place in uniform block.

Well it seems that it’s neither supported by nv nor ati atm. I don’t see why, though.

Well it seems that it’s neither supported by nv nor ati atm. I don’t see why, though.

Because that’s what the OpenGL specification says. It was probably a mistake for GLSL to consider samplers to be “uniforms” to begin with, rather than their own special kind of thing. But because samplers are not really uniforms in the same way that vec3s or mat4s are uniforms, they cannot be in uniform blocks.

And what about structs? Can sampler be in a structure?

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