Volume Render GLSL Shader

toneburst's picture

Just been working on a volume-rendering implementation in GLSL, based on a tutorial on Peter Trier's blog http://www.daimi.au.dk/~trier/?page_id=98

Unfortunately, since QC can't deal with 3D textures, I can't render any cool medical data with it (until I get around to making a custom plugin that is), but I've been getting some interesting results rendering a couple of surface equations from the Paul Bourke's perennially-popular website.

Here's an example, rendering the Borg surface:

..and another, this time it's The Blob:

I'll tidy up the QTZ a bit and release it sometime soon, if anyone is interested.

a|x

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

psonice's picture
Re: Volume Render GLSL Shader

Very cool! I'd definitely be interested in seeing the .qtz :)

cwright's picture
Re: Volume Render GLSL Shader

I'll second psonice's request -- no time for me to actually do anything with it, but it could be a cool launchpad into 3d texture stuff.

(I now realize that we could write a custom image provider/subclass to deal with 3d textures, potentially -- need some more R&D on that front)

toneburst's picture
Re: Volume Render GLSL Shader

cwright wrote:
I'll second psonice's request -- no time for me to actually do anything with it, but it could be a cool launchpad into 3d texture stuff.

Just about to post a QTZ.

Quote:
(I now realize that we could write a custom image provider/subclass to deal with 3d textures, potentially -- need some more R&D on that front)

Ooh, ooh... reallllllly....? That would be cool. That would be really useful, I think. As long as you could then use them in a standard GLSL patch in QC, of course. I'd still like to write a GLSL patch to do volume-rendering using this or a similar method though.

a|x

toneburst's picture
Re: Volume Render GLSL Shader

OK, here's the composition. The GLSL shader code probably needs some optimisation, but I have a feeling it's never going to be that fast, simply because of the number of times it has to run through the raycasting loop per-pixel.

Hope you can make some sense of it. Peter's blog entry explains the basics of how it works, though I found it a little confusing on the details. Also, the way texture coordinates are setup on the builtin Quartz Composer Cube primitive meant I had to hack the shader code around a bit (took me ages to work out why things weren't working as expected).

EDIT: I should add that it requires vade's excellent v002 Blur patch to be installed. You can easily bypass the macro where it's used though- it's the Bloom one. Then again, you should have v002 Blur anyway; it's very cool!

a|x

PreviewAttachmentSize
tb_trierRaycaster_170609.qtz60.49 KB

toneburst's picture
Re: Volume Render GLSL Shader

Did either off you have a go with this one, by any chance? I'm thinking of adding some other equations, and attempting some adaptive-sampling-type optimisations.

a|x

cybero's picture
Re: Volume Render GLSL Shader

an intricate piece of work.

responds well to mouse input on the blur or position.

toneburst's picture
Re: Volume Render GLSL Shader

Cheers! Not quite sure what you mean by the blur though.

I'll add support for the SpaceNavigator 3D mouse thing, I think. I keep forgetting I have one on the shelf, gathering dust, but they're actually a pretty cool control device for 3D stuff.

a|x

cybero's picture
Re: Volume Render GLSL Shader

The Space navigator is that the 3d axys thing that I've ended up using in Audio Atom ? I think so - sheepish grin :-)

Mouse input for x and y position into blur amount and blur sizewas what I was referring to.

toneburst's picture
Re: Volume Render GLSL Shader

SpaceNavigator is a really cool piece of hardware, which I bought a while back, and keep forgetting about. http://www.3dconnexion.com/3dmouse/spacenavigator.php

I used it to control the movement of the IsoSurface in this clip:

a|x

cybero's picture
Re: Volume Render GLSL Shader

I see, Logitech's 3DConnexion Space Navigator. All becomes clear. A cool looking little bit of kit that does a whole lot more than you might at first imagine.

cybero's picture
Re: Volume Render GLSL Shader

What a cool clip :-) Spacey Volumetric Dynamics

toneburst's picture
Re: Volume Render GLSL Shader

Cheers!

I like the way the SpaceNavigator allows nice organic movement. I had it setup to allow toggling of the controls, so you could control either rotation/movement, or the parameters of the IsoSurface raytracer, which worked really nicely.

That was the first clip I ever posted on Vimeo, actually...

a|x