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

Thread: Lookup texture coordinate issue

  1. #1
    Junior Member Newbie
    Join Date
    Jun 2010
    Posts
    3

    Lookup texture coordinate issue

    Hi,

    I have a 4x4 float texture containing positions ranging from 0 ..10.
    I have a lookup float texture a 64x64x64 packed as a 2D texture 64x4096 containing some vectors in each texel.

    the 64x64x64 is packed into a 64x4096 2d image:

    data[y * height + z+0] = value;
    data[y * height + z+1] = value;
    data[y * height + z+2] = value;
    data[y * height + z+3] = value;


    I wish to use the value from the 4x4 texture as a lookup into my 64x4096 texture.
    However when I try to generate texture coords to lookup into my vector texture I just get garbage.

    Here is how I am generating tex coords:

    //get our position
    vec2 texCoord = gl_TexCoord[0].xy;
    vec4 position = texture2D(positions, texCoord);

    //generate tex coords
    float u = (float(position.x * width))/width ;
    float v = float( position.y * height + position.z)/height ;

    vec4 vector = texture2D(noise, vec2(u,v));


    Does anyone know what I'm doing wrong?

  2. #2
    Junior Member Newbie
    Join Date
    Jun 2010
    Posts
    3
    Soved - was my stupid tex coord calculations :P

Posting Permissions

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