Friday, September 23, 2011

LL3DLGLD – 5 – (p)LOD

We need to add some final touches for this very early single level map geometry renderer: the wall layer must get as smart as the floor layer. This process involves basically doing what I did for floors again, but this time for walls. It is something that is some work, but not much new can be said about it.

So we’ll take a little detour and talk about LOD. Level of detail is a very important concept. It allows you to render the same entity with varying levels of detail so that you can use high detail when something is close and low detail when something is far. The high detail would not be visible on far objects and it just wastes processing time.

I have no idea what the standard way of doing LOD is and if there is some built in support in the GPU or one must do it all manually within the engine. One thing I do know: I can’t do LOD checks for every single entity (tree, plant, animal, dwarf, …) in the game world. Processing all these entities (which I have tens of thousands, if not hundreds of thousands on the same map) takes enough CPU time with all the things the game does even without trying to render them. Adding a new LOD check for each entity would be impossible unless using high end computers.

So I’ll do a LOD check for each section of the map. Maybe there is a standard way to assign a LOD factor to such a section. Something tried and true. I don’t know. So I’ll be using my own slightly heuristic methods. Method number one could be to measure the distance from the camera to the center of the section. Method number two could be to use the minimum distance from the camera to the four corners of the section. I will be using method number two. So here is only one section, very close to the camera:

As we move away, it becomes darker and darker:

In the final shot, it is almost black. Now if we render then entire 300x300 map, we get these results:

It will take some trial and error to determine how “dark” a section at a given distance should be. First, I must do something with this LOD information. Right now I am only computing it, but the possibilities are endless. Let’s take trees for example. At the highest LOD/closest section, the entire section could be rendered with full high polygon models for the trees. Sections that are a little more distant could be rendered with low poly trees. Even more distant section could be rendered only with two 3D stretched cubes, one for the trunk and one for the canopy, with very low resolution textures. Going even further: billboards. And the most distant sections won’t render trees at all. This is only an example. I don’t know yet how many levels of LOD I’ll be using and how much is overkill.

And now back to business! We take this very simple wall pattern:

Update the algorithm to handle holes like we did for the floors:

And use a better, but still placeholder cliff side border algorithm:

Here are a few extra shots:

No comments:

Post a Comment