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 3 of 3

Thread: Fixed function equivalent of simple shader

  1. #1
    Junior Member Regular Contributor
    Join Date
    Jun 2006
    Location
    Edinburgh - Scotland
    Posts
    147

    Fixed function equivalent of simple shader

    Hi,
    I'm using a 3D seamless texture with a really simple shader that uses a scaled gl_Position to access the texture
    Code :
    varying vec3  position3v;
    void main(void)
    {
        gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
        position3v = gl_Vertex.xyz * 0.5;
    }
     
    uniform sampler3D TEX3D;
    varying vec3  position3v;
    void main(void)
    {
        gl_FragColor = texture(TEX3D, position3v);
    }
    Is there anyway I can get something similar using fixed function? Basically I want to use the 3D texture to texture my object without having to give texture coords to vertices. I assume I need the glTexGeni routines, but I really can't get my head around them.

    Thanks.

  2. #2
    Advanced Member Frequent Contributor
    Join Date
    Jan 2007
    Posts
    965

    Re: Fixed function equivalent of simple shader

    You don't need texgen for this, just set your texcoord pointer to the same data as your vertex pointer (assuming you're using vertex arrays/VBOs/etc) and do a glScalef (or equivalent) on the texture matrix.

  3. #3
    Junior Member Regular Contributor
    Join Date
    Jun 2006
    Location
    Edinburgh - Scotland
    Posts
    147

    Re: Fixed function equivalent of simple shader

    That worked a treat thanks! So obvious, but I would never have thought of it.

Posting Permissions

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