Sampler parameters: bind texture object id OR bind texture unit

the spec of ARB_fragment_program and ARB_shader_objects isn’t clear about this topic. what must be bound to a sampler2D uniform parameter, the texture unit (GL_MAX_TEXTURE_UNITS is the maximum) or the texture object id (created with glGenTextures()).
in the first case this issue would limit the shader to 4 textures (on a geforce card) while GL_MAX_TEXTURE_IMAGE_UNITS reports 16 available units per shader. also would the first case imply quiet an overhead for the setup for multiple textures for one shader (glActiveTexture must be set for every texture and an texture object must be bound).

you bind a texture unit

i agree - the spec isnt clear on this, and it caused me a lot of grief trying to find out why my program was not working

From the spec:

The value of a sampler indicates the
texture image unit being accessed. Setting a sampler’s value to i selects texture
image unit number i. The values of i range from zero to the maximum supported number
of texture image units. This maximum is implementation dependent, and defined in other

The type of the sampler identifies the target on the texture image unit. The texture
object bound to that texture image unit’s target is then used for the texture lookup.
For example, a variable of type sampler2D selects target TEXTURE_2D on its texture
image unit.

Is it the wording using texture image unit that you find confusing ?

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