PDA

View Full Version : Flat 3D texture fetch / lookup



Dylan
02-07-2007, 10: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.

TIA,
Dylan

V-man
02-07-2007, 11:08 PM
In GLSL fragment shader,

uniform sampler3D mytexture;

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

etc......
}


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)

Dylan
02-08-2007, 12:12 AM
But my texture is 2D...

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

Dylan
02-08-2007, 01: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 :)

kon
02-12-2007, 04:38 AM
http://www.gpgpu.org/forums/viewtopic.php?t=3233

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