Development Blog #2

Hello and welcome back to my development block. Today we did a lot of testing.

The first thing are the ramps. Ok, if you have played the game you perhaps know that there are two different types of blocks: solid and voxels. The ramps where originally created only to work with solid blocks. Now we tried to adapt them to the voxels. The result can be seen here:


Then I was send into the forest to record new bird and environment sounds. But it seems that today was the „fathers take there children to the forest“ day. Ok it took me a while to find a good place were only the birds could be heard. But as I started to record there was some crazy bird who was really annoying. And I wanted to record background sounds but this wasn’t clearly the case. This bird ruined everything. So I moved on but this crazy bird seem to follow me or it was another bird who made the same sound. Ahhh! But I think I catched some good sounds.

Then I went back to my Mac and dealed with a bug in the grass growing algorithm. Normally when you remove dirt the grass should regrow. But nothing happened. So I inspected the „slow voxel update“ code. This part of the game does things like grass growing, plant growing, fire simulation, heat simulation and the removal of trees when the player removed wood from them. In this case the heat simulation algorithm fighted with the grass growing algorithm. I repaired this and also checked the general update algorithm. Here is a screenshot of the regrowing grass:

Regrowing Grass

And I also corrected an error where the axe was shown in the 3D view after loading even if something else was selected. Then I moved the position where the hints for the player are displayed to the bottom. And I also found a bug in the new glass rendering system. Screenshots from this will be published later!

And the camp fire: I promised to one of the users to add a camp fire. So here is it:

Camp fire

This item can be crafted out of stone, wood and a little bit of coal. And the lighting radius is the biggest in the game. So this is now the strongest light source except for the sun of course.

Then I realised that the pickaxe does not completely receive the light of the camp fire:

Bug in pick axe

To understand why this is the case you must remember that I use a deferred rendering system.  A stupid deferred rendering system uses spheres around the light sources. These spheres are rendered with a lighting shader. But I did not liked this approach as this needs a lot of polygons. My system uses instead the bounding box of the light source and then projects it into screen space. From this bounding box a bounding rectangle is calculated. This is the part of the screen where the lighting shader must be applied. It would now be easy to paint this without the depth buffer but I did not wanted this. Imagine for example a light source behind a wall. Without a depth buffer it would be rendered. This of course would not be visible as the shader would detected that the surface does not need to receive light. But it costs GPU cycles! So additional to the bounding rectangle the system also calculates the minimum z value and then renders the bounding rectangle into the 3D view.

Now what is the minimum z-distance of the light source if you are stand right next to it? It is zero of course. But normally everything behind the near plane is clipped away. And this is the case if you render a bounding rectangle with zero z-distance. It simply lies behind the near view plane. To prevent this the game moves the z position of the bounding rectangle a little bit above the view plane and then renders it. But this was in this case to much. So the parts of the axe which where nearer to the view plane than the minimum z-distance did not receive any light. I corrected the threshold and now it works fine:

corrected axe

But such errors are very hard to find.

But the next bug is already waiting. The depth maps are not updated when you place something into the world. This means that new blocks do not create shadows which is very annoying. And the crazy thing is that the engine correctly triggers the depth map update process. And when I make a „screenshot“ of the generated depth map it all looks correct. New blocks are displayed there. The new blocks appear in the OpenGL framebuffer but not in the dynamic texture which was bound to it. Ok perhaps I need an OpenGL debugger.

So that’s it for today!