Tomus Blogus Noteworthy coding techniques and discussion

8Jul/14Off

Voxalising Morrowind – Part 1: The idea

So I've been working on a real-time rendering engine for Sparse Voxel Octrees (SVOs) for a while now. (Voxels are way of representing 3D content as tiny little cubes, instead of textured polygons. A Sparse Voxel Octree is a way to arranging them that's suitable for fast ray-tracing.) People much smarter than I have been writing papers on how to do this for a few years now, and there's a bunch of videos on YouTube with various people's projects.

For my engine the latest one is here.

An SVO is well suited to rendering very large landscapes, and I've been looking for ways to create content that is large enough, varied enough and interesting enough. I found L3DT (the Large 3D Terrain Generator) application which is very good for generating heightmaps, but I'd like to add a bit more to make them interesting, like trees and foliage, buildings and structures. This sounds like a fair bit of work, so I thought: Why not take an existing large, populated 3D world, designed by a team of experts and convert it instead?

Why Morrowind

Morrowind is a ten year old game now, well since superseded by Oblivion and Skyrim. But it has qualities that make it a good fit for this project:

1. The older engine is simpler, and has fewer pixel shaders etc

This is important. To convert the content into voxels, I need to be able to re-implement the original polygon rendering. (I convert triangles into voxels). The more complex the graphics engine, the harder it will be to do this.

2. It doesn't already have a built-in Level-Of-Detail algorithm

You can already stand on one side of Skyrim and look across practically the whole map (if you have a decent vantage point). So voxelising Skyrim wouldn't yield much of an improvement (in fact it would look worse - I'm not planning on re-implementing fancy skies, lighting, clouds etc).

Morrowind doesn't have a LOD algorithm so it can only render the level out to a certain distance. This means you normally can't see the whole island at the same time in the initial game. With my voxel based engine you will be able to, so the advantages should be evident.

3. Morrowind has giant mushrooms

No explanation needed..

4. Morrowind has open source rendering code

The original Morrowind code has not been opened up (as far as I know), but a number of people have reverse-engineered the file format over the years, and created rendering engines based on them.

In fact you can't Google very far without running into the OpenMW project, which re-implements not just the graphics engine (with improvements) but game-play as well. And because it's all Open Source, all the level loading and rendering code is there for reference.

How it will work

Voxel conversion

Conversion to voxels is a pre-processing step. I'll need to supply the Morrowind map to the engine as a "World", which can be split up into "Regions", where each region represents a cubic piece of the world. The engine will pass a "Renderer" to each region and tell it to use it to render itself. The trick is that the engine can pass in a special type of renderer, which instead of drawing polygons to the screen, will convert them into voxels, and build an octree.

From browsing the reverse engineered file format documentation, it appears that Morrowind is implemented as grid of "Cells", each of which is a 65x65 heightmap, plus a bunch of objects, like trees, rocks, houses. This sounds like a good candidate for a height-map "Region".