itch.io is community of indie game creators and players

Devlogs

More ambient occlusions optimizations

Vorxel
A downloadable game

I got to thinking about the GLSL voxel level ambient occlusion code and realized that the biggest bottleneck in performance with it is determining adjacent voxels in order to calculate how much ambient occlusion darkness to apply to the current fragment.  The old approach has always been to look at neighboring voxels.  That's fairly fast for neighboring voxels in the same voxel volume, but still has some overhead and even more so if neighboring voxels are not in the same voxel volume.  I improved performance on both accounts previously with a caching mechanism for volume indices to avoid unnecessary repeated queries of the tetrahexacontree and I also added voxel bits which indicate if a voxel side even requires ambient occlusion calculations to be done.

Better rendering performance is usually always about making the GPU do less (without sacrificing visual quality).  So with that thought in mind, I realized if each voxel were to have neighboring voxel adjacency bits and these bits are only calculated once or recalculated when one or more respective voxels are changed, a significant performance gain could be had with rendering voxel level ambient occlusion.  As before, voxels sides which don't need voxel level ambient occlusion are trivially rejected and rendered without voxel ambient occlusion.

? In this test scene, I now get better frame rates with voxel level ambient occlusion on rather than off because my video card goes into a higher performance mode (GPU clock speed stepping) with the little extra "push".

Voxel level ambient occlusion off:

Voxel level ambient occlusion on:

P.S.  Previously I was seeing a little better frames per second over all, but then there was some screen tearing which I fixed that was due to a synchronization issue.

P.S. P.S. Voxels are now 64-bit integers (GLSL uint64_t) with the extra 20-bits required for this optimization.  I'm using 16-bits for color and 1-bit for interior (or hidden) property.  This still leaves 27-bits free in each voxel for opacity, reflectivity, face normals (face normals can be calculated from voxel face and its adjacency bits in shader if need be) and/or other voxel properties I may come up with.  Before voxels were 32-bit integers.

Read comments (10)