GPU voxel raytracing

Community Forums/Showcase/GPU voxel raytracing

Noobody(Posted 2010) [#1]
Since I don't want to hijack the other voxel thread I'm making this one for my GPU voxel shader.

So, what is a voxel?
A voxel is the 3D counterpart of a pixel. A pixel is represented by a square, while a voxel is represented by a cube. Voxels are contained in 3D volumes, as opposed to 2D images (a volume has a, e.g., 512x512x512 voxel resolution, while an image has a 512x512 pixel resolution). To render these voxels efficiently in real-time, GPU acceleration is needed. I have done this using OpenGL and a set of shaders.

The principle is simple: For each pixel on the screen, a ray is sent into the voxel volume. The intersection point with the volume boundary is computed (if the camera is outside the volume) and a ray is marched through the volume. Raymarching means that the position of the ray is moved along its direction by small amounts; each time the position is incremented, the volume is queried to see if the ray position inside a voxel. For exact results, small steps are needed, which is of course very slow. I made an attempt to solve this by using greater steps, but letting the program estimate where the actual intersection point was once its inside a filled voxel. This works relatively well and is very cheap computational-wise.

The shaders come in different quality versions. Texturing requires shader model 4.0 which is not *that* common. If your graphic card doesn't support it, the log gets filled with tons of compilation errors, but that's okay - non-supported shaders are deactivated in the program so it will still run, as long as at least one shader is compiled. You can change the current shader by pressing 'S', 'I' or 'T', respectively. Non-supported features are colored red.

The voxel model also has 3 different resolutions because some graphic cards have a size limit for volume textures and also because smaller resolutions are rendered faster. You can change the resolution by hitting 'R'.

Screenshot:


Download (.exe + .bmx source code): Link

If you have a really good computer, try out the 512x512x512 version: Link


Panno(Posted 2010) [#2]
wow looks cool
but i got error 2001 under vmware


Who was John Galt?(Posted 2010) [#3]
High quality work, my man. Did you see the recent thread about 'infinite resolution' and using binary space partition to efficiently search for ray intersections with your voxels?

The GPU acceleration is a winner. Did you get the idea somewhere or think of it yourself?


Oiduts Studios(Posted 2010) [#4]
I got a blue screen...computer restarted... it's probably because of my SLI setup or something, looks good though.


DareDevil(Posted 2010) [#5]
thanks ;)


Ryan Burnside(Posted 2010) [#6]
Looks awesome! Voxels seem to be something that many people never take the time to tinker with.

Sadly the demo would not run as "GLSL is not supported on this system."


BlitzSupport(Posted 2010) [#7]
Wow, nice! I get 90 FPS in 256x256 (very smooth movement), and 40-50 in 512x512, though it seems slower than that -- it also somehow doesn't look as good as the 256 version. (This was in 1024 x 768 x 32 display mode.)

Really cool demo, though!


Noobody(Posted 2010) [#8]
I'll be looking for a few more interesting voxel models, but I'll soon be moving on to volume rendering.

Did you see the recent thread about 'infinite resolution' and using binary space partition to efficiently search for ray intersections with your voxels?

I didn't know there was a thread here, but I had a discussion about the same site a few days ago.

As far as I can judge from the videos, the don't use voxels, but point clouds. Point clouds are different from voxel volumes in that they don't use grids (arrays), but store the position with each sample point. This is less space consuming because you usually have more empty space than filled space. Also, the points don't have to be grid aligned but can be positioned freely.
For rendering, they most probably used point splatting. It's basically just rendering an alpha-blended sprite for each point, but the difficulty is that the points have to be sorted from back to front so the blending works right. Except for the sorting part, point splatting is much, much faster, because you don't have to actually raytrace a whole scene, but just shove a few tenthousands of polygons down the graphic card. And rendering many polygons is what the GPU is good at.

So what they did was write an acceleration structure (most probably a modified kD-Tree) that allows efficient depth sorting. But this still doesn't solve the issues with point splatting. First of all, it is impossible to make surfaces with points. In a voxel volume, one voxel has 6 neighbours, which allows efficient interpolation to find the curve that represents the surface of the voxel model. This doesn't work in point splatting, because you don't know the neighbours of a point and because the points themselves don't represent density values like in voxel rendering, but just parts of the geometry, it is much harder to estimate where the surface passes through. So what's the big deal with not having surfaces? It means that there is no way of determining the exact area that a model fills which makes it impossible to use shaders, to determine exakt depth values and to interpolate features like normals and colors.

Besides that, point splatting models can't have sharp features and tend to look blurry. Besides the obvious drawbacks like lack of animation, memory consumption etc. (which voxel rendering suffers from too), this just makes it not suitable for the future of rendering. Also, the programmers sound extremely unprofessional. They proclaim to have found the biggest revolution since the beginning of computer graphics - I mean, seriously? How could you say that?

It still is impressive what they accomplished, but its not more than a tech demo. You couldn't make games with that approach.

If you're interested in point splatting, Iņigo Quilez wrote some interesting articles and codes on them: Link

The GPU acceleration is a winner. Did you get the idea somewhere or think of it yourself?

Well, it was kind of obvious. I've been redoing quite a few programs into GPU accelerated ones, because the GPU is unbeatable at parallelizable algorithms. And raytracing is the prime example of a parallelizable algorithm :)

I got a blue screen....

That is certainly not the desired result! I hope it didn't destroy any unsaved projects.


Taron(Posted 2010) [#9]
thehe...my god, my Nvidia 7300 GT is laughing in despair. Can't compile the shaders... too bad. I would've loved to see it.
(too many temporaries, can you imagine that?!) :P

Looked inspiring, though! :'(


MGE(Posted 2010) [#10]
If Taron can't run it....not even going to attempt on my end. ;) lol...


Vorderman(Posted 2010) [#11]
crashed the graphics driver of the 9800GTX in my works PC :(


ShadowTurtle(Posted 2010) [#12]
i think there is more GPU power needed as from leadwerks engine ;=)


Oiduts Studios(Posted 2010) [#13]
crashed the graphics driver of the 9800GTX in my works PC :( 


I as well have a 9800 gtx, i guess that is the problem?


Nate the Great(Posted 2010) [#14]
lol I get 2 fps but nice never the less. Maybe that guy that does 'unlimited voxels' could let his secret slip so we can all enjoy this luxury lol.


DareDevil(Posted 2010) [#15]
41 fps
Geforce 9800 GTX
4GB Ram

very good ;)
good


_33(Posted 2010) [#16]
For some reason the keys didn't work in this program.


Dabhand(Posted 2010) [#17]
Very nice! :)

Dabz


Jason W.(Posted 2010) [#18]
That is very cool.

Thank for the defintion of a voxel.

I have found an interesting voxel engine:

Termite 3D
http://www.thermite3d.org/joomla/index.php?option=com_content&view=article&id=32&Itemid=7


Jason


Pete Carter(Posted 2010) [#19]
nice demo

How would you animate a voxel object? it would have a massive over head having to keep track of each voxel for each frame of a characters animation :O(


Noobody(Posted 2010) [#20]
I have found an interesting voxel engine

That one's not exactly a voxel engine - it does store the scene as voxels to allow destructible environments, but the voxels are converted to polygons (triangles) before rendering. I didn't test the demos to see how fast it is, but it's still impressive.

How would you animate a voxel object?

Bone animation would be extremely costly computational wise. The alternative would be naīve frame-by-frame animation, which is extremely costly memory wise. Maybe one day someone will invent an efficient animation algorithm for voxel models, but for now, the only reasonable use for voxel rendering is for static models :)


KennethMcI(Posted 2010) [#21]
83 fps on the 512 version, 166 on the 256 version. both at 1024x768

i7-920
ati 5870

very nice!


KennethMcI(Posted 2010) [#22]
forgot to say - these fps are without moving the screen at all ( good for comparison )