View Full Version : Lookup texture coordinate issue

05-16-2014, 05:18 PM

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?

05-18-2014, 04:08 PM
Soved - was my stupid tex coord calculations :P