PDA

View Full Version : sampler parameters: bind texture object id OR bind texture unit



Chris Lux
03-03-2004, 03:22 AM
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).

imr1984
03-03-2004, 04:26 AM
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 http://www.opengl.org/discussion_boards/ubb/frown.gif

Axel Mamode
03-03-2004, 02:06 PM
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
specifications.

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 ?