Flat 3D texture fetch / lookup

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(=325) * 128(324). 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.


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)

But my texture is 2D…

Then why don’t you use 3D?

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 :slight_smile:


you were almost at the right place with your question on gpgpu.org :wink:

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.