Parts Of The Voxel Engine: LookMaps
In this post I want to look in detail at LookMaps.
Click on the example below to see how look maps work:

Since some Voxel models can have 10,000+ voxels (or 3d pixels) it could be very intensive to for example tint every single voxel.
To put it into perspective imagine looping through 10,000+ colours and calculating their new colour every single frame, and then along with that also calculating new positions for 10,000+ particles. Traditionally this is how things would be done each particle contains it’s own colour.
Instead what I’ve done with the Voxel Engine is create a separate look map. A look map is essentially an array of colours and then each voxel (or 3d pixel) has an index that points to a colour in a look map.
Think of an image on the internet most likely every single pixel in the image is not going to be a completely different colour but instead colours are repeated. This is the basic idea behind the “look map” to have a colour pallette to create an image.
In the above example you may have noticed that when you were clicking on different colour swatches you would see the colours in the voxel model also change. We were essentially changing colour values in the look map without changing the index at which each voxel is pointing at.
Look Maps Do More
Ok so every single Voxel Model has a LookMap. During the rendering process what actually happens is that when the renderer is rendering a model it will grab that models look map and tell it to render “something” at a specific 2d position.
So what that means is that the LookMap actually performs the physical rendering. This allows us to do some amazing things…
For instance in the above example you can see small squares not pixels being rendered. What’s actually happening is that this models look map is a “FillRectLookMap”. Essentially instead of rendering pixels (PixelLookMap) it’s rendering rectangles or squares.
Of course there is also a “BitmapLookMap”. Check out the example below where instead of drawing pixels or rectangles we are drawing bitmaps:

Again since we are using lookmaps we can quickly and easily change which bitmap is being rendered for which voxel. Another note is that because we only have 10 bitmaps to render and entire model we are using a lot less memory than each Voxel having it’s own BitmapData that would be rendered.
_Posted in R&D, Voxel Engine




