Update 15: SSAO Experiments

Small update this time. I have started working a day job again and so haven’t spent much time on the game. For a bit of fun I’ve been thinking about implementing screen space ambient occlusion, something I haven’t written before. As I’ve been developing and experimenting with the game I’ve noticed issues with my eye being unable identify height and depth of the tiles. Often 2 tiles will sit at different heights but the same orientation, meaning they will be lit exactly the same. Take a look at this example.

Screenshot_Sat_May__6_14_17_47_2017

The tile in middle is shaded the same as the tile behind. While it’s not difficult to understand what tile is where, It really shouldnt require any thinking. To solve this I started looking into ambient occlusion techniques, I had a form of AO in the game before using an AO value baked into the terrain verts. However, Now I have redone the terrain mesh system making that no longer an attractive option. The most common AO in games is SSAO (Screen Space Ambient Occlusion), there are different implementations but essentially you would use the positions and normals buffer to sample surrounding pixels and calculate if they occlude the current pixels.

I put together a shader which does just that. The results are decent however there is a significant performance hit. I’m using a half size AO buffer and 16 samples, then a 4×4 blur. Framerate goes from about 160 to just about keeping up at 60. I’m sure I could optimize further and improve the method, however I have played round tweaking parameter and even at high sample counts the results are not that great. I think I am going to take another look at baked AO.

Screenshot_Sat_May__6_13_31_49_2017

No SSAO

Screenshot_Sat_May__6_13_31_40_2017

SSAO After a lot of tweaking

Other changes:

  • Added a way to recompile shaders at runtime so I can make modifications to shader code and see results instantly (Very useful, should have done this ages ago!)
  • Improved pipeline for adding 3d models.
  • Made headway on ECS for managing game objects.
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s