Sign in to follow this  

Volume Rendering

Recommended Posts

Original post by Larry91
I wanna render a volumetric object using a 3d texture (slices), by DX9 and VC++!
I wanna see a source code!

Render a quad for each slice of the volume, texture it with a slice of your 3D texture, i.e. each slice uses a constant valve for the 3rd component of the UVW set.

An alternative approach would be to store your volume as a number of 2D textures, for each slice change texture and draw your quad. This is more draw calls sure (higher CPU load) but 2D texturing is faster than 3D on the GPU.

Source to texture a quad with a 2D texture is very very easy to find.

Share this post

Link to post
Share on other sites
Is there a specific reason you want to render using slices instead of ray-casting? Do you intend to render surfaces or "cloudy" data? What about lighting and shadows? Rendering slices can be faster on current GPUs, but ray-casting is attractive for its flexibility and is becoming comparable in performance.

Any modern implementation will use 3D textures. 2D texturing is an old approach used before GPUs offered 3D texturing.

For slicing, you can generate view-aligned slices of a box, which involves intersecting a sequence of planes with the box to get a sequence of polygons with appropriate 3D tex coords. This intersection is equivalent to marching cubes for a voxel. Then you render the slices either back-to-front or front-to-back, depending on how you are compositing. In your pixel shader, you typically map a scalar texture value to RGBA using a transfer function implemented as a 1D texture. You can increase quality using pre-integration, which involves precomputing color/alpha composition for the space between slices.

I don't have any source code handy, but here are some links:

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this