Light Probes and Ambient Occlusion

This month was excellent in terms of new things I learned. Finally, for the first time in my life, I was able to precompute Ambient Occlusion atlas for my scene, I implemented it with Embree and Micrrosoft’s UVAtlas, it worked like a charm, The algorithm is pretty easy:

  • pass shapes you want to have in UV space,
  • rasterize Atlas with texture coordinates as position in shaded and save positions and normals to the output texture
  • load shapes in Embree (beware, you have to pretransform positions, rtcSetGeometryTransform will not work as you expect)
  • for every pixel in texture run intersection (warning - rtcOccluded1 would not work with your “usual” expectations, check Embree’s demo - RTCRay wants you to set tnear and tfar as a part of the vector)

To use new atlases I had to add static/dynamic object type, that worked but that’s too early for me to use this as a part of the pipe, I am still on a really fresh API, later I probably will return to this when I want to add some GI in static objects which should be in batches - objects should be in one UV space. I definitely can make lightmaps based on this code, but that will be a little later, cause I’m not sure I will need this in my game.

This task really got me a good example of how to use graphics and compute shader + read/write and different flows, I definitely will be using my new expertise in the next tasks - irradiance probes and etc…

Research about Mirror’s Edge went well, most of the materials were about the remake, but that gave me good references for my future research, seems like they use extensively SH for small objects and one huge lightmap for the zone in the map.

Right now I have a few ways to go and I’m not sure which one I will choose, I have to refactor some stuff again (I believe we should refactor as much as we can, at least at the beginning, huge tails in C++ hurt more than in other modern languages). The first way is about lighting in the scene, I have to check how I can auto-generate probes in the scene and save them, that’s important for SH and Irradiance caching. The next one is about light caching, while lightmaps are good, but I want to know how to use other techniques too. And the last one is about how to load/unload scenes on PC and consoles - that’s a completely unknown place for me, but an interesting one :)

I think that’s it so far, everyone who is in search - be strong and have good luck :)

Huge thanks to everyone who shared code in next repos: https://github.com/microsoft/UVAtlas https://github.com/prideout/aobaker https://github.com/ands/lightmapper https://github.com/TheRealMJP/BakingLab