About Me

I'm just someone struggling against my own inertia to be creative. My current favorite book is "Oh the places you'll go" by Dr. Seuss

Saturday, April 7, 2007

Voxels

What is a voxel? it's like a 3 dimensional pixel. It is short for "VOlume piXEL". It's a very simple concept which has been used in countless applications, from medical imagery to videogames. The basic idea is a 3D raster, each element of which stores attributes such as color, transparency, density, normal, and countless other possible things, or subsets of these. The classic Demoscene demo is the voxel landscape. (not true voxels, but possibly an impressive demo nonetheless).

I have been obsessed with voxels. Why? I think there is one application of voxels which has been underserved: 2D style games. Rapid development of Pixel art. Imagine the standard 16 bit games with multiplane parallax backgrounds. Now imagine them with many more contiguous planes, 3 dimensional objects in the background smoothly passing by in perfect perspective. Not flattened cardboard 2D paintings, but fully 3D props rendered with a 1voxel=1 pixel style engine. Most voxel rendering engines I see make the grim mistake of rendering a voxel with many pixels, creating an ugly pixelated look. Imagine 3D worlds with the tidy detail which is given to 2d pixel art. You can get a taste of it at the metroid cubed site here http://pages.infinit.net/voxel/home.htm

I get excited at the potential of this guy's work, but saddened to see it wasted in cheesy 8-bit style graphics, and reliving old games, and old gameplay models.

Like many, I have been dissappointed in the graphic quality of games since the playstation arrived. 3D graphics in videogames are consistantly ugly as sin. Their bicubic scaled textures filling the screen with vomited blurs of pixels.

I want a 1pixel=1voxel world. A 1pixel=1voxel oriented graphics editor. A 1pixel=1voxel oriented game engine which combines the flexibility of 3D with the exquisite detail and lush beauty of 2D pixel art graphics.

1. The Basics.
Each voxel can store a color, and an opacity. Most of the time, opacity is a simple on/off switch. Either it exists or it doesn't. It can be full alpha, which significantly slows down the rendering of the voxels. The result is a smooth density cloud- this is what makes voxels useful for medical imaging. Newer game engines are using voxels for more realistic clouds and smoke effects.

2. Normals.
what is a normal? In 3d graphics parlance, a normal is a point in 3D space which is the terminal of a line that is perpendicular to the angle of the surface at a specific point on a surface. In other words, the surface normal defines what direction a surface is facing. One can determine how well lit a surface is by measuring the angle between the light source, the surface, and the normal. This is a very simple cross product, then arc tangent operation.

With voxels, each voxel can have its own surface normal. Many voxel engines determine the surface normal automatically based on a voxel's neighbors. This produces a very legoish appearance to your voxel models. It is possible to smooth this out by taking into account more neighbors. I think a better idea, is to model first in a standard 3d modeller, then remember the normal of a surface when converting from the standard model to your voxels.

Thus, a voxel model can be more than just a flat colored grid of 3d pixels, but dynamic per voxel shading is possible, with very smooth appearance to the surface.

Some other very handy things can be done with normals though. You can find the contours of a voxel model, and use them to add cel shading style lines. Here's how it works: Simply give your voxel model a shell of invisible voxels, just a 1 voxel thick coating. Then, render the shell voxels if their normals are parallel or near parallel to the camera. This is a common technique in polygonal cel shading. This is an application of the same principal at a pixel level of precision. Essentially what this does is render a pixel next to any "surface" which is perpendicular to the camera. This will be the object's contours, what we normally perceive as its edges.

The beauty of this is that the exact shape of the shell can be tweaked and modified to exactly how you need it to look, at a pixel level. What's more, this can do more than just outlines. Pixels which only render when their normals are pointing a certain direction away or towards the camera, can be used for view specific pixel level tweaks. Is one view particularly awkward? just tweak it a bit. This is the same basic principle as hints in vector fonts.

3. Simulations.
Since every atomic element of the object is defined as a point, this opens the door for a vast variety of particle simulations. Particles in simulations can be made to behave like liquid, smoke, jelly, springs, strings, cloths, solar systems, bouncyballs, pendulums, rag dolls, etc. Voxel positions can be attached to particles in a simulation, allowing characters and objects to realistically bounce, flow, explode, melt, stretch, fall down, trees grown, geological simulations producing realistic voxel landscapes. The possibilities are endless.

4. Sprites.
Remember the opening title screen for Yoshi's Island? It's basically a 3d island composed of a number of 2D graphics attached at some point on their base to a 3d plane. The plane rotates around carrying the graphics with them, creating the impression of a 3d island while keeping the cartoony detailed appearance that only dot graphics can achieve.
If I create my voxel paint program, I want this effect to be achievable as any other voxel effect, and combinable with any amount of voxel graphics. Just attach a 2d graphic to a voxel, and the 3d calculations take care of themselves.

5. Isometric.
One comprimise that I don't think any pixel art purist will object to, is that I intend that my ideal voxel rendering engine not apply perspective to its voxels. the scaling of the voxel has the potential to destroy the 1pixel=1voxel idea. At the very least, a perspective engine should not scale a voxel any larger than a pixel.

6. Sub Surface Scattering
This is a popular effect in computer graphics for simulating the appearance of skin. In order for it to be realistic though, an object needs to have an interior. For humans, the interior must be red and meaty. In a voxel object, the interior is already there.


How will I make this all work? what programming language shall I use? What sort of game will I make?
I haven't decided yet. Maybe flash. Maybe java. Maybe SDL and C. Maybe all of the above? Perhaps anyone who happens to read this has an opinion? Who knows.

4 comments:

Anonymous said...

good idea, im working on a similar idea, it uses a sort of ray tracing system with the entire environment formed of voxel spaces. what color and its translucentcy occupies the space is determined by the game engine. the entire thing will be recursively sectioned in octrees. its the ebst possible idea for a volumetric simulation, and the only practacle implemintation of true 3d to date

Jon said...

i, too, am working on a raytraced voxel-based engine to aid in creating visual effects! (http://sourceforge.net/projects/vcam/) i haven't updated my code or docs, yet, but will in a few weeks. i've been busy with classes and my kids. it has been really exciting so far. what's most amazing to me is the simplicity of the engine, and the power and potential of it. have you checked out ken silverman's voxlap engine? (http://www.advsys.net/ken/voxlap.htm) look at the screenshots (linked at the top of the page). he has been working on a game/engine called voxelstein 3d. (http://voxelstein3d.blogspot.com/)

Jon said...

also, the vfx studio double negative has a proprietary voxel system... i'd like to know a lil more about it, but haven't found much, yet.

XICO2KX said...

Very nice ideas there in your post! ;)
Did you managed to start coding your voxel engine?
How is it progressing? ;)