Sunday, February 20, 2011

28 - Failing in three dimensions

So for the first time I am going to show the 3D engine. Grass isn't textured yet, there is no lighting and shadows and I don't have enough models and the ones I do have have been hastily created and not that pretty:

The above view was somewhat of a default, where you have a good overview because you are supposed to interact with the map using a mouse or keyboard. But the advantage of a 3D engine is that you can change your view point. You can zoom in and tilt the camera:

Or you can zoom out a lot and even see the cliff side in the distance. Rock are not textured, but color coded for my convenience:

Here is another example, when I scroll back:

And, of course, you can scroll and tilt in such a way that you can see the entire map up to the horizon. The number of objects is staggering (and there is no sky box yet):

Here is what happens when you cut out a complex shape from the wall. When something gets covered up, you can always scroll a little to free up the view, but thing around the middle tend not to get covered up:

So if you are seeing this pictures and think that they are ugly, you are probably right. I think that it is both ugly and fixable so it won't be ugly forever.

The good news is that I am very happy with the way the engine works technically.

The bad news is that it is extremely slow. There were a few performance problems from the beginning, but the real problems started when I replaced the placeholder cubes with real models. As can be seen in pictures, there can be thousands of object on screen at once. And while in those screenshots I have around 60 FPS, there are two things to take into consideration:
  • those screenshots were taken after the static scene has lingered on for a while, after all the tricks and hacks to make it faster have kicked in. When actually playing and interacting with the map, I have more like 20-30 FPS.
  • I have a very good graphics card. I can imagine it becoming unplayable on a “normal” graphics card.

The main culprit is the number of objects. There are limits on the number of objects you can have and those limits are quite harsh. Ever wondered why maps in games tend to be a small number of large and relatively uniform meshes put in a matrix? There are a few things that I can still try. I'll try using a mesh merger, converting let's say 1000 trees or bushes into 10 meta-trees and bushes. But if this does not give any good results, I am afraid I can't continue the 3D engine. If it fails I'll re-enable the isometric one and focus on that a bit until I read more about 3D engines.

Another concern is the complexity of objects. Since everything is so small, it ts very hard to create something that looks good. You have to have a number of polygons as small as possible and textures made specially to highlight the detail in small objects, with broad features. It is a lot simpler to make something like this in 2D, where you can add borders.

I really don't know which way to go right now. 3D still offers advantages, but I am starting to get the feeling that 3D is not that well suited for this kind of game, where you need to be zoomed out and show a huge number of small items that still need to be instantly recognizable at a glance form a tactical view. 2D is well suited for these goals, but you need to add a few techniques to combat obstruction caused by high items and you can not change around the camera.

The good part is that I still have time to experiment around. There is no pressure from a studio or publisher or anything, so I can make a few mistakes or have a few failed attempts before I create something successful.


  1. How does Minecraft manage it? You could check out this code -

    You could modify the game to make full use of the 3D graphics by having Dungeon Keeper sized chunks, instead of tiny cubes.

  2. To Kurt:
    I have no idea how Minecraft does it. But the problem is not the cubes, but the meshes. Everything will have a full 3D mesh with textures and there are just thousands of objects that can be visible at once.

  3. I think that it could be solved using LOD for the meshes, mipmapping for textures, some kind of chunk occlusion for the chunks that are not on the view or even using LOD with very low detail when things are not being seen, and for the objects data, you could use chunks with octree, so everything would have his own space and when you go to a upper view, everything is rendered very fast.

    So, theoretically, no more problems, just a lot of coding.

  4. Minecraft has much less to worry about, and you can see the lag when you look down into the ground in the game.
    May I suggest you use something such as the view angles the game "Stronghold 1" uses? It gives you a top down view for planning and mapping stuff out while it still gives you several static angles to rotate around objects.

  5. Yes, LOD switching is the only way to go with this. This type of problem can also be fixed with DirectX's new dynamic tessellation methods. I have been looking into it but I need a newer graphics card to program it. Unfortunately you would be cutting your potential market using this, but in the future this will be the answer. For now you can have the game produce smaller less complected meshes before the game runs which it will switch to when you are far away from the object, or create them once and save them to a file along with your original mesh. I'm sure there are many other ways but I am sure with your talent you can pull off 3D. Good luck.

  6. To make my opinion clearer...

    Using Octree Chunks for the world, like 4 or 8 chunks, and every "piece" of the world, is one of the octree nodes, so in that way, you would have the coordinates for every piece and at the same time it would render very fast when the camera is distant, i dunno if it would be needed, but combining that octree rendering with LOD in every mesh, even the dwarves, and mipmapping for every single texture, there's no way that it would slow down, you could even run it on a SNES, maybe not on the SNES, but wouldn't be a problem for any PC above the K6 II.

    My crap Celeron sometimes do wonders with games from 2010, but suffers in a lot of games from 2003/05.

    The computer isn't very important, everything depends on the way the engine is made. Or how it cheats on us.

  7. To make Dwarves and whatnot more recognizable at a glance, would it be possible to say... Mouse over them, and it will have a little blurb? Like this:
    Sloppy mock-up, but putting your mouse over something would pull up its name, a small picture of it, etc. If there was a dwarf walking around, you could mouse over and it would tell you the Dwarf's name and current job.

  8. Why don't you keep the isometric style view, but to work around the problem of things getting hidden, have 4 different viewing angles (North, South, East, West)? This is what a lot of older city building games did, like Ceaser 3.

  9. To alucinor:

    This feature was present in the isometric engine and did not get lost in the 3D conversion. The difference is that you do no mouse over, you click. See post "24 – Random stone explosion", last picture for the little status window that pops up when clicking on different objects.