View Full Version : Flat 3D texture fetch / lookup

02-07-2007, 09:47 PM
Hi, I have used a flat 3D texture to store 3D data containing a flow field.

Now I need to find a way to fetch the right values that I'll need for trilinear interpolation. I have used an simple low res flow field for now to try. It has the following dimensions (xyz) = (32,32,20) and I have put this data in a Flat 3D texture of simensions 160(=32*5) * 128(32*4). So for every linear interpolation I need 8 values. The domain is wrap around.

I was wondering how my fetch algorithm should look like and wheter or not I should use a 1D lookup texture.


02-07-2007, 10:08 PM
In GLSL fragment shader,

uniform sampler3D mytexture;

void main()
vec4 texel;
texel=texture3D(mytexture, texcoord.xyz);


Easy as pie. Be aware that it might better for you to use floating point texture format.
Also, you will need non power of 2 support (NPOT)

02-07-2007, 11:12 PM
But my texture is 2D...

02-08-2007, 12:06 AM
Then why don't you use 3D?

02-08-2007, 12:09 AM
Since I cannot render to 3D texture. And i want to read back the results into a texture to use them in a feedback loop.

Besides that flat 3D textures are more efficient for these kind of operations that 3D textures.

we're talking GPGPU here :)

02-12-2007, 03:38 AM

you were almost at the right place with your question on gpgpu.org ;)