Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 4 of 4

Thread: Multitexturing

  1. #1
    Junior Member Newbie
    Join Date
    May 2004
    Location
    Oregon
    Posts
    5

    Multitexturing

    I'm new to multi-texturing, so I may just be missing an init of some sort...

    When I bind a texture to position 0, I can see/modify/use my texture in my fragment shader after setting the following in my vertex shader:

    gl_TexCoord[0] = gl_MultiTexCoord0

    and, if I use the same texture data and try to bind it to texture position 1 (after building a different texture first) I would expect to see it in a similar manner:

    gl_TexCoord[1] = gl_MultiTexCoord1

    but I can't see my texture in this manner.

    some background info: I am trying to use one image as texture0 and use a second texture map as a LUT to do window and leveling in the fragment shader.

    But, it seems I can only see one texture at a time in the shader. Is it possible to use both gl_MultiTexCoord0 and gl_MultiTexCoord1 at the same time?

  2. #2
    Advanced Member Frequent Contributor
    Join Date
    Jan 2001
    Location
    NVIDIA, Austin, TX
    Posts
    555

    Re: Multitexturing

    Are you specifying texture coordinates for both texture units using glMultiTexCoord?

    Something like this:

    Code :
    glMultiTexCoord2f(GL_TEXTURE0, ...);
    glMultiTexCoord2f(GL_TEXTURE1, ...);
    glVertex3f(...);
    etc...

  3. #3
    Junior Member Newbie
    Join Date
    May 2004
    Location
    Oregon
    Posts
    5

    Re: Multitexturing

    Thank you for responding so quickly... yes, that's what I'm doing.

    But, when I pass into the fragment shader a sampler2D of the second texture and try to access it with texture2D it's just gray, not the actual texture. The first texture (0) comes through fine.

  4. #4
    Senior Member OpenGL Guru zed's Avatar
    Join Date
    Jul 2000
    Location
    S41.16.25 E173.16.21
    Posts
    2,407

    Re: Multitexturing

    youve gotta set the uniforms to get the textureID from your program into the shader.
    sorry about being unspecific, but check the spec from memory use somehting like

    int id = glGet...ID....( the_shader, "tex0" )
    glSetUniform(...., id, .. )

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •