Voxels in OpenGL?

Fdf8c00a746f0a9bec29bb4e6270936a
0
Rei 101 Mar 04, 2004 at 03:03

I’m working on a voxel-based 3d engine in OpenGL. I’ve done voxel engines before in which the graphics library’s only job was to blit pixels to the screen - my code did all the 3d math and primitive rendering. However, in the interests of efficiency, I’d like to use OpenGL this time to take advantage of fast routines and hardware acceleration. The problem is, OpenGL doesn’t seem to be very aware of concepts related to voxel engines.

For example, regardless of the type of voxel engine (surface rendering, depth rendering, etc), you generally need a method to blit a 2d shape in 3d space. Technologically, this is very simple. Once the points are rotated into the display space, for each point you get the z value, and draw your 2d primitive (generally a square, rectangle, or circle) into the z buffer with all points having the same z depth. Easy - easier than your average polygon draw routine, in fact. However, for the life of me, I can’t think of an efficient way to do that in OpenGL. The only ways I can think of are:

A) Replace each voxel with four 3d coordinates that act as corners to a polygon. Not only do I beforehand have to calculate the proper location of these points to center this polygon around the voxel, but OpenGL has to do 4 times the work of rotating and then has to then do a polygon draw routine in 3d. That’ll probably run *slower* than just writing my own routines and going without hardware acceleration.

:blink: For however much space the voxel would take up on the screen, you blit 3d points using OpenGL. Of course, if your voxel is up close and is taking up 20 by 20 pixels, you’re going to need 400 3d points drawn with OpenGL, and the rotating of those points is going to be unbearable. Additionally, you still need to calculate where all those points are.

Both of these options are, quite clearly, unfeasable. Does anyone have any better ideas, or is a voxel-engine writer stuck with writing their own entire unaccelerated rotation and primitive functions for no good reason other than OpenGL doesn’t contain a very simple “draw a 2d shape in 3d” function?

Ideas?

2 Replies

Please log in or register to post a reply.

F7a4a748ecf664f189bb704a660b3573
0
anubis 101 Mar 04, 2004 at 03:41

you could use point sprites. they are usually used to render particle systems. instead of 4 points you only specifiy one and opengl does the rest for you (rendering a billboarded quad that is). i’m not sure if i’m getting you here because i never worked with voxels and know little about it (just the basic theory…). if drawing a square is all you need to do this might be what you want

Dfe642d6dafd7fcf0e54b8562e042559
0
soundeye 101 Mar 07, 2004 at 01:35

hey there couldn’t resist
might wan’t to take a look at

http://www.vis.uni-stuttgart.de/\~engel/pre-integrated/