PDA

View Full Version : octree texture, need to scale ?



lobbel
08-21-2010, 07:36 AM
Hello,
for volume rendering it is common to apply some kind of
empty space leaping. One approach is the use of an octree.
Drawing only those cubes that contain data acoording to the
transfer function. Actually I wanted to use a depth of 5 or 6
that means 32768 or 262144 cubes that subdivide the volume.
I wanted to put the vertex data for the sub cubes on gpu with
a vbo, but this is too much. A volume itself can be 500mb or more and the vertex data for octree depth is approx. 70MB and for depth 6 it's approx 500MB.
So I decided implementing the octree in a 3d texture. The octree is still created on cpu side at the beginning. in the
thexture i write min and max iso value for the respectiv sub cub. When casting the volume in a fragment shader I can obtain the current sample position. With this sample position
I want to look up in the octree texture to skip empty areas.

My question is, do I have to do some scaling in the shader when doing the texture look up in the shader ?
Let's say my volume is 256*256*256 and the octree's size is
16*16*16 (4096) cubes. In the shader, texture coordinates are
from 0,0,0 to 1,1,1, so far so good.

The octree is always built from a root node with min(-1,-1,-1)
and max(1,1,1)


pseudo code


sampler3D texVolume;
sampler3D texOctree;
while(inside volume)
{
vec3 samplePos = front + t*dir;
float val = texture(texOctree, samplePos);
if(val....)
{
samplePos += getNextCubePos(samplePos);
}
}


regards,
thanks