WebGL Screenspace Ambient Occlusion
The grass demo I did earlier used some Screenspace Ambient Occlusion. I thought it was a cool effect, and decided to research the topic futher. Scren-Space Ambient Occlusion is an incorrect aproximation to true ambient occlusion, and it has a couple problems, but it can be a useful technique.
This demo integrates a bunch of rendering techniques:
- Percentage Close filtered shadow mapping
- Screenspace Ambient Occlusion
- Procedurally generated sky
- Environment map lighting computed from the sky
- Diffuse texturemaps and specular maps
- Stochastic Sampling
- Bilateral gaussian blurring
Demo
You can try the live demo. The code is on github.
The demo allows you to tune the parameters of the rendering and adjust it to your liking.
Control
WASD for movement, click&hold for mouselook.
Screenshots
Evening
Reference without ssao
Critique: Don't overdo it
If carefully tuned and mixed with other lighting techniques SSAO can be quite useful. However it is quite easy to overdo the effect (a sin many AAA games commit these days). If you implement SSAO for your game, please keep in mind to give your artists control over the tuning of the effect.
References
I use a couple of different methods for SSAO.
- gd: Inspired by various sources, among them gamerendering
- gpg8: Inspired by Game Programming Gems 8 Chapter 1.2
- gp1: Inspired by GPU Pro 1 Chapter 2.1
Further research
It's worth checking out the following book chapters and links about the topic.
- Wikipedia: Screen Space Ambient Occlusion
- GPU Pro 2 Chapter 1.1: Temporal Screen-Space Ambient Occlusion
- Game Engine Gems 1 Chapter 18: Fast Scree-Space Ambient Occlusion and Indirect Lighting
- Real-Time Rendering Chapter 9.2: Ambient Occlusion
- GPU Gems 2 Chapter 14: Dynamic Ambient Occlusion and Indirect Lighting
- GPU Gems 3 Chapter 12: High-Quality Ambient Occlusion
- Ambient Occlusion in Frameranger
- Two Methods for Fast Ray-Cast Ambient Occlusion
- Ambient Occlusion Fields
- Realistic Ambient Occlusion In Real-Time
- strawberry on ambient occlusion
- Levelofdetail: The year SSAO broke
- oZone3D: Ambient Occlusion Lighting
Thanks
Simon Rozner was as kind as to design the city scape I'm using for test geometry. Thanks buddy!



