Creating 3D Texture - Sample Help

In 2D texture, only the (s,t) coordinates are used
=> glTexCoord2f(s,t)

In 3D texture, there is too a third coordinate r to use
(where the r coordinate represent the slice plane in your case)
=> glTexcoord3f(s,t,r)

You have to use the alpha component and draw slice by slice for to handle the transparency

You can draw the horizontals and verticals separation lines with something like this on a texture3D[DEPTH][HEIGHT][WIDTH]:

   M = 256 / N ;

           if( (r%M == 0) || (t%M == 0) || (s%M) == 0) )
                texture3D[r][s][t] = separation_color;

(this can be a lot optimised if we draw directly the verticals/horizontals lines instead to test if the texel is on a separation or not)

Ok, you don’t want a separation between voxels and what do you want to make is GPU ray casting

I have never play with this :frowning:

But it’s never too late for to begin :slight_smile:

I have found a GPU Raycasting Tutorial at
=> I test to adapt it for the linux platform and come back after
(it already use glut/glew/CG, so with a little chance I have only to delete the “#include <windows.h>” and create a makefile for to port it)

The linux port is make :slight_smile:

Only the files main.cpp, and Vector3.h found at are necessary

I have only modify a little the beginning of the main.cpp file and rename it raycasting.cpp :

// --------------------------------------------------------------------------

// GPU raycasting tutorial

// Made by Peter Trier jan 2007


// This file contains all the elements nessesary to implement a simple 

// GPU volume raycaster.

// Notice this implementation requires a shader model 3.0 gfxcard
// YLP 26/05/2011 : adapted to the Linux plateform

// --------------------------------------------------------------------------

// #include <windows.h>

#include <iostream>

#include <fstream>

#include <sstream>

#include <vector>

#include <cmath>

#include <ctime>

#include <cassert>

#include <GL/glew.h>

//#include <GL/gl.h>

//#include <GL/glu.h>

#include <GL/glut.h>

#include <Cg/cg.h>

#include <Cg/cgGL.h>

#include "Vector3.h"

and this is the makefile

all: raycasting	

raycasting: raycasting.cpp
	g++ -o raycasting -L/usr/X11R6/lib -lGL -lGLU -lglut -lCg -lCgGL -lGLEW raycasting.cpp

A little ‘make’ and I have now a raycasting executable that work :slight_smile:

But the %CPU is now near 50% when I execute it :frowning:
(100% when I execute it with one Free TV channel on VLC in //)
=> I see if I can adapt this for to have a very lesser %CPU

This is really really very slow : only 0.022 fps on my linux box :frowning:
(ok, it’s only a NVidia GeForce 7100 GS but I have very very more fps on others gl programs, about 190 fps on the Lesson47 of Jeff Molofee’s at for example, so I don’t think that it is a hardware/software driver path problem )

I’m “happy”, I have found something to optimize a lot :slight_smile:

What did you find?
thanks for the help

I have open a new thread at :slight_smile: