VolumeRendering

3D Texturing Example

3D Texture Data | | 3D Texture Parameters

3D texture is supposed to be given as texture object with id texid.

// global settings
glTexEnvi(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE,GL_MODULATE);
glEnable(GL_TEXTURE_3D);

// bind specific texture
glBindTexture(GL_TEXTURE_3D,texid);

// render textured geometry
glMatrixMode(GL_TEXTURE);
glLoadIdentity();
glTranslated(0.5,0.5,0.5);
glMatrixMode(GL_MODELVIEW);
glBegin(GL_QUADS);
   glTexCoord3f(x_0,y_0,z_0);
   glVertex3d(x_0,y_0,z_0);
   glTexCoord3f(x_1,y_1,z_1);
   glVertex3d(x_1,y_1,z_1);
   glTexCoord3f(x_2,y_2,z_2);
   glVertex3d(x_2,y_2,z_2);
   glTexCoord3f(x_3,y_3,z_3);
   glVertex3d(x_3,y_3,z_3);
glEnd();

// unbind texture
glBindTexture(GL_TEXTURE_3D,0);
glDisable(GL_TEXTURE_3D);

Let $y_0, y_1, y_2, y_3$ be the height h of a horizontal slice.
For h = $-\frac14$, $0$, $+\frac14$ the result looks like this:

Q What vertices and texture coordinates are needed for vertical slices?


3D Texture Data | | 3D Texture Parameters

Options: