In Praxis: Lighting

The previous installment of In Praxis talked about how surfaces react to light. This post gives an overview of where that light comes from.

We have a single primary light source: the sun. As is common in real-time graphics, it is modeled as a directional light. Apart from any dynamic local light sources in the world, all light is somehow derived from the sun. For the shadowing of the sun we use fairly standard stable cascaded shadow maps combined with jittered sampling for smooth shadow edges. A neat little detail is increasing the shadow filter radius when the sun is partially occluded by clouds, giving a more diffuse look.

Diffusion of sunlight in cloudy conditions

An important secondary light source is the sky. Its color and intensity directly derive from the color and intensity of the sun, as well as the scattering properties of the atmosphere. We use the approach presented in [1] to inexpensively compute the amount of light scattered by the atmosphere into the camera. In addition to just a clear sky we also have a dynamically varying cloud cover. Both of these elements are rendered dynamically into an environment map, which is then projected into spherical harmonics. This ends up as the ambient light that affects the diffuse shading of surfaces. The result is that the ambient lighting matches the sky at different times of day and in different weather conditions. We also render another environment map with the sky as well as black silhouettes of large objects and use it for the glossy specular reflections on surfaces, as described in the previous post.

Directional ambient lighting alone would not look very realistic, so we have ambient occlusion to make objects fit better into their environment. For small-scale occlusion and occlusion from dynamic objects we use a screen-space method known as Horizon-Based Ambient Occlusion (HBAO) [2]. For large-scale occlusion we have a static 3D texture covering the entire game world, each voxel containing the approximate visibility of the sky from that voxel encoded in spherical harmonics. Obviously this can only include occlusion from static objects and only on a fairly large scale since the voxels are huge, but it works very well for ambient shadowing caused by buildings or major terrain formations. Being stored in a 3D volume rather than only on the surfaces of objects allows dynamic objects to be occluded by the static occluders, and also allows occlusion of the sky light for the volumetric stuff.

3D texture AO and HBAO in action

That’s another high-level look at the technical side of the game wrapped up. We are leaving the office for a few weeks to do some summer vacationing. Alpo will also become a daddy for the second time Any Day Now ™! But despite all that, feel free to ask about any details as usual. There may still be a chance for a reply.


[1] Bruneton, E. and Neyret, F., Precomputed Atmospheric Scattering, Computer Graphics Forum,Volume 27, Issue 4, pages 1079โ€“1086, June 2008.

[2] Bavoil, L., Dimitrov, R. and Sainz, M., Image-space horizon-based ambient occlusion, ACM SIGGRAPH 2008 talks, Article 22.


  • Trackback are closed
  • Comments (20)
    • Christoph
    • July 6th, 2012 4:54pm

    Have you considered GI approaches at any point? While certainly looking great for simple directional lighting, the past inventions in realtime GI solutions are a valuable addition for most game environments.

    PS: Congratulations ๐Ÿ˜‰ And enjoy your vacations.

  1. I really like what you’re doing (from the graphics style to the focus on developing with your music ^^)

    You said “[Static Ambient Occlusion] Being stored in a 3D Volume (…) also allows occlusion of the sky light for the volumetric stuff”.
    I’d be interested in hearing a little more about how you do it.

  2. This looks to be a very clever re-imagining of the “physical sun and sky” lighting set up in mental ray, but re purposed for real time. Its really impressive. I have some idea of how SSAO works in tandem with depth buffers and things, but I’ve never heard how HBAO works, how different is it visually and computationally?

    Awesome stuff guys.

      • Mikko Kallinen
      • July 16th, 2012 9:51pm

      The basic idea behind many cheap methods that get the “SSAO” label is to compute how much of a volume around the point being shaded is solid matter. That is not quite how light gets occluded in the real world.

      HBAO finds out the angle at which the horizon lies in a given direction around the point being shaded. Steeper angles result in more occlusion. It is a much better approximation to true ambient occlusion, but also more expensive.

      Of course both methods have the limitations imposed by their screen-space nature. Also, even true ambient occlusion is just an approximation of full global illumination, so we’re dealing with approximations of approximations…

    • Taylor
    • July 6th, 2012 7:16pm

    what you guys are doing is amazing. i cant quite understand everything in this post but i will come back and take notes on all of this when i get to this level. i know this is exactly what i want to do someday, except with my own BA idea. congrats to Alpo, it is incredible you are able to be apart of a project like this while makin babies. i can not wait to get this game and i hope you will both be playing my game in the future. thank you for all the inspiration.


    • brickmasterj
    • July 6th, 2012 8:53pm

    Awsome, but one question, will a version of Praxis be available for developers, or programmers somethime (most likely after the release of Reset of course)? Like what CryTek did with the CryENGINE 3.
    (Btw, just one more question: Windows only?)

      • Mikko Kallinen
      • July 16th, 2012 9:53pm

      At this point we’re not considering making Praxis available to others. Also we’re not considering platforms other than Windows. But we also never say never.

    • Suumas
    • July 22nd, 2012 1:24am

    How are you advancing on the Gameplay part?

    And when the Engine will be downloadable? Cause I really want to start an indie game with it ๐Ÿ™‚

    • Gameplay is advancing nicely! Praxis will propably not be downloadable at this stage, we’ll have to see how things develop after the release of Reset.

    • Bischinator
    • July 25th, 2012 8:09pm

    Please post some more screens of the reset editor in action.

    • Bischinator
    • July 25th, 2012 8:10pm

    Mikko Kallinen :
    But we also never say never.

    Bieber quote? ๐Ÿ™‚

      • Mikko Kallinen
      • July 25th, 2012 11:54pm

      Yeah, we’re trying to get him to do the soundtrack.

    • Lauri
    • August 7th, 2012 10:57pm

    What do you think, how powerful CPU & GPU will be needed to run this game in max settings and 1080p 60fps? Of course its too early to ask (I think), but I want to get some kind of fork for it.

    And will it be released in 2013?

    • Trying to keep the hardware requirements reasonable ๐Ÿ™‚ And yes, 2013 release is planned.

        • VMC
        • October 5th, 2012 10:10pm

        Please don’t go reasonable for the max graphics, that’s the beauty of pc’s compared to consoles ๐Ÿ™‚
        Who has a weaker machine will just lower the graphic settings.

    • Henrik
    • December 6th, 2012 11:30pm

    Hey, I was wondering if you could go into any more detail on the cloud system? Is it generated and updated dynamically? What does the representation look like, seems voxel based to me? Do you trace through it?

    Thanks! Stuff is looking awesome!

    • dnnkeeper
    • December 26th, 2014 3:25am

    How do you capture environment maps? Are they rendered per object every frame? How do you sample them to get blurry specular reflection of rough surfaces? Your work is outstanding! As a junior developer I’m very impressed and inspired. Thank you.

  3. I wish you’ll create more helpful articles in the future.Time of gathering is by all accounts something worth being thankful for however no understudy can use it.

  4. Thank you a lot for take the time for such a good information.