Saturday, September 24, 2011

LL3DLGLD – 6 – So close

The first stage of my investigation and research is slowly coming to an end. There is one more thing to do before starting stage two: optimizing the hell out of double strips. My performance is not as good as it should be. I have a floor layer that has a top surface, a bottom surface and side surfaces when needed. Sides are optimized (only added where needed), but only one by one, not as a strips. Then I have a wall layer with the same structure. The problem is that if in the same cell we have both a floor and a wall block, the top side of the floor and the bottom side of wall are identical and neither should be created. The bottom side of the wall is invisible normally because it is facing away the camera, but to better illustrate my point, I’ll make it face the camera and remove the side surfaces so you can see what is going on inside:

The extra redundant layer is clearly visible. First, we optimize away this layer. My maps are random, so I can’t give the exact same shot twice, but this one is close enough:

If everything behaves as expected, I have practically reduced to half the number of polygons the wall layers uses (only top + bottom) if the entire floor is intact. But there is still a problem. I may be no longer rendering extra wall bottoms, but I am still rendering extra floor tops. Let’s fix this:

And now, for the final shot, with all sides rendered as needed:

Performance has definitely improved, but there are two downsides. First, I am doing a lot more CPU work while determining what part of the mesh to create. So my map scroll/camera rotate operations are not as smooth as they used to be. This can be improved a lot by creating better algorithms. The second problem is that the visual artifacts have become more apparent and some new ones have appeared. I though it was the same problem that is causing the artifacts mentioned in the previous post (and it may be so), but upon further investigation it seems that an extra strip is added sometimes on top of an existing one. I tried to fix it, but kind of ruined it, so I reverted. Anyway, these problems are not that severe. Quite normal actually for something hacked together in a few days while still learning.

I can’t just stop on this note, so I’ll leave you with an early preview of things to come:

And finally, a close-up:

Performance has degraded considerably, but the trees are really poorly optimized. But the new experimental engine can render pretty much as much as it could the first time I presented a 3D engine, but only render. Last time you could interact with the world normally. I am working just on rendering right now. But the big difference is the performance: while the performance is pretty bad, it is at least a hundred times better than last time. Last time it was so bad, I had to abandon the 3D engine because it was unplayable. A GeForce 8800 GT was struggling to keep a double digit framerate.

So the new engine looks promising!


  1. Yeah, another Minecraft :)
    Just kidding...

  2. hmm... i hope you know what you do. i prefer good 2d instead of poor 3d and when you imlement many features and stuff you have to create them all as 3d models. This'll need lot of time. anyway... good luck

  3. To Phil:

    You may or may not be joking, but there are a few key differences between Minecraft and DwarvesH that I think are important enough to keep them as completely separate entities without any relationship to each other:
    - Minecraft is a first person experience where you control your avatar and have free movement and can do anything. DwarveshH will be using a topdown/isometric camera angle where you issue orders to a squad of workers. Optionally, you will be able to pause the action and dive into first person mode and walk around your fortress.
    - Minecraft is formed out of cubes. DwarvesH is not really formed out of cubes. Walls and floors are organized as rectangular entities to keep things simple, but the rest of the world is polygonal. And in the future I might add a little bit of noise and elevation even to flat surfaces when the camera is close enough. And the key part of not having cubes is that you do not interact with the world by placing or removing cubes. You do not punch a tree and get a tree cube. A dwarf will work for hours to chop down a tree and convert it into logs. You do not put a few cubes in the shape of a house and call it a house. Dwarves need boulders, bricks, logs for roof suspension, etc...
    - DwarvesH is a micro natural environment simulator, with a fair bit of botanical and geological accuracy. Not too much, just enough to keep the world from seeming like a random height map.

    To Mokota:
    Well, my graphics weren't really good in 2D either :). Stonesense stuff was nice, so were my new trees, but the rest was ugly. But the engine was good, up to the point I tried to add free form zoom. That was a total disaster and that is when I decided that I need to use 3D. My 3D world is pretty ugly, but I am not any using models right now. Everything except for 3 textures is procedurally generated.

  4. Of cause, I know. Just the pics look quite similar (for me as a person which never played Minecraft)

    I have to say that I agree with Mokota. It's far more time intensive to create the graphics in 3D (especially for user mods) and you have to look always for the vertex count of your model.
    It's like when you compare Stonesense and Overseer in DF, I would prefer Stonesense.