Let Me Tell You About WANG TILES

Recently, at work, I had a problem for which Wang tiles were the suggested answer. I’d never had a chance to use them for something before but after seeing them in operation, I now want to use them for everything, forever. (Disclaimer: I started this article a couple of months ago and shelved it. I’m no longer quite so excited about Wang tiles but they’re pretty good)

Continue reading

Not dead, just doing unglamorous things

It’s been over a month but there hasn’t been much to say about the features I’ve been working on, they’re necessary rather than exciting. Here’s what I’ve been up to:

On the Visibly Improving (i.e. D3D 9) branch

House with a shadow

Shadows! The sun now casts shadows on everything. For now, they’re a fairly standard implementation of split-frustum (or cascaded) shadow maps, which is to say that I render three or four depth-maps from the sun’s perspective, all the same resolution but with each map containing a larger and more distant chunk of the main camera’s view frustum. It’s looking decent but has a few downsides:

Continue reading

A proper sky and some proper environment lighting

One of the big things that’s been letting me down is my background. Until now, I’d been using a low-res, low dynamic range cube that I rendered out of Terragen a few years ago, and to make it not look like a painted backdrop I was running it through some fairly suspect code to push the brightness up on it, which was doing things like making any true white parts of the image infinitely bright, not to mention really drawing attention to the fact that I’d been fool enough to save it as a jpeg.

Vizpeople mainly sells cutout people for architectural visualisations, but offer some really good panoramic skies without too many near objects, so one quick panorama-support shader and some tweaking of the sun colour makes things a lot nicer.

House with an HDR sky
But that’s not all. Continue reading

Hills that look like hills

Progress report: Hills now look quite a bit more like hills.

As mentioned previously, the hills were looking pretty awful – even a 2048×2048 texture, when stretched over miles of landscape, has pixels larger than a house. Instead of using such a texture directly, it makes more sense to tile a smaller texture repeatedly over the landscape. To add variation, one can use a landscape-wide single-channel image to blend between two different textures.  As it happens, the author of the height field I’m using for the hills (virtual-lands-3d.com) provided the hill model with a map named “flows” and a map named “rough” which seemed to correspond to fertile areas and rocky areas. After a little tweaking of their levels, I merged them into a two channel texture.

Two channel blending map

Which I'm also considering just hanging somewhere because it looks cool

This technique pretty much solved the problems with variation in the distance, but then so could the “one big texture” approach if I didn’t care about problems up-close. The problem being that “half dirt, half grass” under this scheme means you get a semitransparent layer of grass everywhere.

Grey-brown hills with green streaksDirt overlaid with a transparent layer of grass

Continue reading

Non-pretty Beginnings

For the last several years, I’ve been working on a game engine. For a while it was a university project, for a while it was going to be for a different game, but for most of its life, its only purpose has been to be a kind of testbed so I could get a grip on how a game engine hangs together and hopefully stay abreast of new technology. On one hand, I’ve learned a lot. On the other hand, me being my only audience has led to problems. The engine is now seven or eight years old and the best screenshots I have from it look like this:

Ugly render of a house

Elven building downloaded from 3d-source.com, and not yet done justice

Essentially I’ve done a lot of plumbing work and have very little to show for it.  The plan from here on out is to start fixing this scene (and maybe some others) while posting every new development to the blog so that I have an (at least theoretical) audience that I don’t want to disappoint.  Besides just screenshots I’m planning to actually explain what I’m doing and why, though since I’m uncertain whether I’m writing for the benefit of people I know outside the industry so they understand what I do with my life, people I know in the industry so they understand what I do with my spare time, random passing programmers brought here by a keyword, or just to straighten my own thoughts out on a subject (see “explain it to the bear“), the writing style may be a little varied.

The first stage of this epic task is probably going to be dealing with the shockingly ugly hills. They’re currently just a very large object with a not nearly large enough texture stretched over it. While it’s not a particularly exciting technical task, I’ll feel a lot happier once it’s blending between a few different tiled textures.