If you recall back in Part 6 I introduced shadowing, and then I did some tests on the terrain to see how it looks at various resolutions. I’ve noticed that most of the problem with the lower resolutions is not that the hills look undefined or blocky, but that the lighting looks bad. The light and dark side of hills get blurred, and shadows become big dark blobs.
Notice how the shadows are kind of vague blobs of darkness. I’ve turned down the the resolution on the terrain, and the result was that the shadows became undefined.
But keeping the high polygon count just to preserve the lighting just doesn’t make any sense. Polygons are there to give the thing shape, and if you’re adding polygons just so you can have little areas of light and dark, you’re probably doing something wrong. That’s a job for textures.
You remember in Part 7 I added zone textures. I can very easily add the lighting and shadows to these textures as well. The results are very nice:
Amazingly, this image and the previous are of the same scene from the same point of view, and they even have exactly the same polygon count. This is a 2 million polygon terrain that has been reduced to a mere 12,000 polygons! Back in part 7 I concluded polygon counts this low were unworkable because the terrain looked too simple. This sidesteps the problem by drawing a texture with lots of subtle lighting and shadowing effects. Nothing is left out. So what we have are 12,000 polygons being drawn with a texture generated with 2 million polygons worth of detail. All of the smaller hills you see are just shading: the surface itself is totally flat at this distance. As you get closer, polygons will be added that will make those areas more detailed. Here is the same view again, only showing the polygons that make up the terrain:
The circled area is a large quad (a pair of triangles). See how that area still has little shadows and lighting changes? Those would have been turned into a big ‘ol hazy dark blob using the old system.
With this feature in place, I can afford to keep the polygon count low. Also, remember how I was crying about sending vertex data back in part 4? Well, now I don’t have to send the lighting data with each vertex. As far As OpenGL is concerened, I’m drawing a flat white unlit terrain with a texture on it. This is about the fastest way you can draw textured polygons.
Let’s look at another before and after:
But of course, as Mark would tell you, we don’t so much solve problems as we trade one set of problems for another with the hope that the new set of problems is more favorable than the old. The drawback is this: The lighting goes on the texture, so if I change the lighting (like, sunset, sunrise, etc) it will have no effect whatsoever on the terrain unless I rebuild all of the terrain textures. However, these improvements are so great that I intend to keep them, even if it means I have to give up on smooth day/night changes.
Here is a view of the same scene, only from ground level. Just a few years ago this would have been passable as a first-person view, although the ground looks a little blurry by today’s standards. Still, this looks very nice. Makes me want to replace the “fly around” style movement with standard first-person movement so I can run around and jump on these hills. :)
My test machine is a 1Ghz with 512MB of memory. My video card is a GeForce 5200. So far, the engine runs nice and smooth on this system. I think we’re nearing the end of the project. There are only a few items left on my goal list at this point.
Dead or Alive 5 Last Round
I'm not surprised a fighting game has an absurd story. I just can't figure out why they bothered with the story at all.
Two minutes of fun at the expense of a badly-run theme park.
The Strange Evolution of OpenGL
Sometimes software is engineered. Sometimes it grows organically. And sometimes it's thrown together seemingly at random over two decades.
The Gradient of Plot Holes
Most stories have plot holes. The failure isn't that they exist, it's when you notice them while immersed in the story.
Juvenile and Proud
Yes, this game is loud, crude, childish, and stupid. But it it knows what it wants to be and nails it. And that's admirable.