Wednesday, May 2, 2007

Thinking backwards.

I’ve come up with a solution to the vexing problem of polygon count. (I’m sure I’m not the first to do it, so I’m not making any claims of ownership.)

The problem is this: let’s say you’ve got a 2 mile by 2 mile landscape and, to get it looking right, it takes half a million polygons. Okay, that’s a lot, but you can handle it.

Now you want to zoom out to 4 miles by 4 miles. If you want to maintain the same resolution, you now need two million polys.

Now zoom out to 20 miles by 20. Now you need 200 million polygons! That’s crazy talk.

And yet, in the opening shot, I want to do just that kind of pull-back: from showing about 5 miles of landscape to showing the entire earth. How was I going to manage that without a bunch of hokey-looking fades and convenient cloud banks?

And that’s when it occurred to me to do the whole thing backwards.

I’m creating the landscape using a ‘displacement map.’ That’s a grayscale image where brightness corresponds to height. White is high; black is low.

The landscape object, itself, is just a flat mesh of square polygons. The Lightwave renderer distorts this mesh based on the displacement map.

So if I shrink the displacement map, the landscape features shrink, which looks exactly the same as the camera moving away. Likewise, if I rotate the displacement map, it looks like the camera’s spinning around. The actual landscape ‘object’, such as it is, never moves at all. Nor does the camera.

This picture may give you some idea of what I’m talking about. It’s part of a screen shot from LightWave 3D. That tilted, black and white rectangle, is the displacement map. The much smaller green rectangle is the actual landscape object. As I move the displacement map, the landscape rolls across the landscape object.



I even linked the ‘sun’ light and some clouds to the displacement map so that, as it moves, so do they.

I’ve done some tests zooming in and out by a factor of ten, with some clouds flying by, and they look pretty encouraging.

And the whole things uses the one high-resolution mesh.

You can see an early test here.

No comments: