Difference between revisions of "Screen Space Ambient Occlusion (SSAO)"

From Valve Developer Community
Jump to: navigation, search
m
(Bold.)
 
(86 intermediate revisions by 8 users not shown)
Line 1: Line 1:
<!-- removed 'candidate for speedy deletion' tag because it does not fall under the candidates for speedy deletion rules -->
+
{{stub}}
{{note|This is not a feature of the Source Engine, it is a shader which NVidia cards will sometimes apply.}}
+
[[File:AmbientOcclusionExample.jpg|right|210px|thumb|An example of traditional ''prerendered'' ambient occlusion in Blender 3D. SSAO attempts to mimic this look in real-time.]]
  
[[{{ns:6}}:Prop ragdoll.jpg|thumb|400px|SSAO in game - the shading effect is highly visible between Breen and the table, but also appears in the corners of the room. Note the edge "glow" bug around Breen's arm.]]
+
{{note | Not to be confused with baked ambient occlusion on models!}}
  
'''Ambient Occlusion (AO)''' is a type of [[lighting]] technique applied in-game to create more realistic lighting. AO simulates soft shadows created by two surfaces that are close together. Ambient occlusion in games is normally accomplished through '''[[Wikipedia:Screen Space Ambient Occlusion|Screen Space Ambient Occlusion]]''', which is a simplified way to fake realistic AO with shaders in a process fast enough for real-time rendering. SSAO is a [[DirectX]] 9.0c shader, so it will only be available on fairly modern video cards.
+
{{TODO|Expand the article to include different methods of SSAO. The method described is one of many.}}<br>
  
Ambient occlusion is currently only available for NVidia cards using the NVidia drivers. It is very resource-intensive and will cause a significant reduction in framerate on older video cards.
+
'''Screen Space Ambient Occlusion''' ('''SSAO''') works by examining an onscreen pixel, and then comparing its location in a [[depth buffer]] to the pixels around it. Pixels which are close together but not coplanar (on the same face) are shaded to simulate soft shadows. To maintain playable framerates, it is not possible to sample every pixel every frame, so random sampling is used, which will inevitably create noise/grain which may be more noticeable with movement. To counter this, the SSAO pass is often blurred to remove such grain.
  
SSAO causes several rendering bugs which are common to nearly all games which offer SSAO.
+
As with traditional AO, SSAO is completely independent of the normal lighting system. This means that both the performance and appearance of the shader are unaffected by the lights used in a level.
[[{{ns:6}}:Ao_renderbug_trees.jpg|thumb|right|300px|The shadows being rendered on top of fog are noticable on distant trees.]]
 
{{bug|SSAO often creates a small visual error where the very edge of an object is not shaded, causing an apparent glow.}}
 
{{bug|SSAO is rendered ''on top of fog and smoke'', even if the smoke is closer to the player than the source of the shading, causing the fog/smoke to look lumpy. This may give distant trees a frosted look.}}
 
  
==Supported games==
+
The depth buffer is measured from the camera, and so SSAO is view-dependent - the size and locations of the "shadows" created by SSAO may change as the player moves the camera around. Additionally, the shading may look different along the edges of the screen - this can be combated by rendering additional information outside of the current camera's bounds.
All [[Source]] engine games except [[Portal]] support ambient occlusion. This may be because AO would not render correctly through Portals.
 
  
==Enabling ambient occlusion==
+
==Source Filmmaker==
[[{{ns:6}}:EnableAO.png|thumb|right|300px|Enabling AO in NVidia control panel]]
+
[[Source Filmmaker]] includes an SSAO option (labelled "Ambient Occlusion"), accessible by right-clicking on the viewport. The default setting is very grainy. {{todo|Adjust number of samples?}}
Ambient occlusion cannot be controlled through the video options within a Source game. AO can be turned on with NVidia cards using the NVidia drivers.
+
 
 +
== SSAO in the Source Engine ==
 +
{{Note|For faked Ambient Occlusion per model within the Source Engine, see [[$ambientocclusion]].}}
 +
{{Note|A post process SSAO shader currently ships with the [[Source_shader_editor| Source Shader Editor]].}}
 +
{{TODO|Write a tutorial on creating an SSAO shader and implementing it into the engine. See [[Shader Authoring]].}}
 +
{{Note|I am currently writing a tutorial on implementing SSAO into Source Engine [http://www.moddb.com/games/lost-squad/tutorials/source-engine-implementing-simple-ssao-shader-part-1 here] (DmitRex).}}
 +
 
 +
==External links==
 +
*[[Wikipedia:Ambient occlusion]]
 +
*[[Wikipedia:Screen Space Ambient Occlusion]]

Latest revision as of 09:48, 25 February 2018

An example of traditional prerendered ambient occlusion in Blender 3D. SSAO attempts to mimic this look in real-time.
Note: Not to be confused with baked ambient occlusion on models!

To do: Expand the article to include different methods of SSAO. The method described is one of many.

Screen Space Ambient Occlusion (SSAO) works by examining an onscreen pixel, and then comparing its location in a depth buffer to the pixels around it. Pixels which are close together but not coplanar (on the same face) are shaded to simulate soft shadows. To maintain playable framerates, it is not possible to sample every pixel every frame, so random sampling is used, which will inevitably create noise/grain which may be more noticeable with movement. To counter this, the SSAO pass is often blurred to remove such grain.

As with traditional AO, SSAO is completely independent of the normal lighting system. This means that both the performance and appearance of the shader are unaffected by the lights used in a level.

The depth buffer is measured from the camera, and so SSAO is view-dependent - the size and locations of the "shadows" created by SSAO may change as the player moves the camera around. Additionally, the shading may look different along the edges of the screen - this can be combated by rendering additional information outside of the current camera's bounds.

Source Filmmaker

Source Filmmaker includes an SSAO option (labelled "Ambient Occlusion"), accessible by right-clicking on the viewport. The default setting is very grainy. To do: Adjust number of samples?

SSAO in the Source Engine

Note:For faked Ambient Occlusion per model within the Source Engine, see $ambientocclusion.
Note:A post process SSAO shader currently ships with the Source Shader Editor.

To do: Write a tutorial on creating an SSAO shader and implementing it into the engine. See Shader Authoring.

Note:I am currently writing a tutorial on implementing SSAO into Source Engine here (DmitRex).

External links