Screen Space Ambient Occlusion (SSAO): Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
(Shouldn't need to explain myself with this one. Do not remove it, instead let the Valve staff sort it out. It's being added with the agreement of 8 different people who are willing to discuss it.)
No edit summary
 
(23 intermediate revisions by 9 users not shown)
Line 1: Line 1:
{{prod|Article does not cover any existing engine features and serves no use for people interested in creating mods for the source Engine. Descriptions are incorrect or inaccurate in many places. Article has caused a long and painful edit war. Needs review of Valve staff. Perhaps consider rewrite or merge?}}
{{stub}}
{{TODO|Add more information about standard Ambient Occlusion, and split Screen Space Ambient Occlusion from the main article.}}
{{Todo|Document about HBAO, alternative to SSAO which can be forced through GPU driver control panel (or NVIDIA Profile Inspector).}}
[[{{ns:6}}:Screen space ambient occlusion.jpg|thumb|400px|Screen Space Ambient Occlusion applied to a typical 3D scene, as demonstrated in [[Wikipedia:CryEngine 2|CryEngine 2]].]]
[[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.]]
'''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. Typically AO is rendered in realtime through '''[[Wikipedia:Screen Space Ambient Occlusion|Screen Space Ambient Occlusion (SSAO)]]''', a shading method which is able to closely simulate the effects of real AO with little loss of performance.


SSAO works by examining an onscreen pixel, and then comparing its location in the 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 Gaussian blurred to remove such grain.
{{note | Not to be confused with baked ambient occlusion on models!}}


The depth buffer is measured from the camera, and as a result SSAO is viewing-angle dependent - the shading may look different depending on where the camera is located. This can be combated by rendering additional information outside of the current camera's bounds.
{{TODO|Expand the article to include different methods of SSAO. The method described is one of many.}}<br>


=SSAO in the Source Engine=
'''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.
{{Note|For faked Ambient Occlusion per model within the Source Engine, see [[$ambientocclusion]].}}
{{TODO|Write a tutorial on how to increase the drawn depth in Source's depth buffer. SSAO will only work 128 units ahead unless this is done first.}}
<br>{{TODO|Write a tutorial on creating an SSAO shader and implementing it into the engine. See [[Shader Authoring]].}}


=Forcing SSAO on via ENBSeries ''(Shader Injection)''=
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}}:Enbseries.jpg|thumb|right|450px|ENBSeries off (left) and on (right).]]
{{Warning|Not an official engine feature. May cause performance or compatibility issues. Valve is not responsible for any problems ENBSeries may cause.}}
{{Warning|'''ENBSeries has been known to cause issues with [[VAC]]. Refrain from using it in multiplayer games, and always play with -insecure as a launch option'''}}
[http://enbdev.com/index_en.html ENBSeries], a pass-thru DX9 DLL created by Boris Vorontsov, is capable of injecting shaders into renderers that call upon it in realtime. This means that ENBSeries can add custom bloom effects, SSAO, Global Illumination, and other advanced effects at the cost of performance.


To enable it, download the [http://enbdev.com/ss_hl2_en.htm Half-Life 2 specific version] from the ENBSeries website, and place it's config file and d3d9.dll file next to the main executable of whichever Source game you've chosen to run it on. Once ingame, you'll be able to toggle it on/off by pressing shift+F12 ''(Default)'', and adjust the quality of it's effects in it's main ini file.
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.


=Forcing SSAO on via Nvidia's Drivers ''(Shader Overlay)''=
==Source Filmmaker==
{{Warning|Not an official engine feature. May cause performance or compatibility issues. Valve is not responsible for any problems this driver feature may cause.}}
[[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?}}
[[{{ns:6}}:EnableAO.png|thumb|left|150px|Enabling AO in Nvidia control panel]]
Nvidia's drivers feature a method that allows for SSAO to be forced on in almost any game, thanks to a clever method of hooking into the current render process and retrieving the current scene's depth buffer through the video driver. Enabling this driver feature is as simple as turning it on within Nvidia's driver control panel.


==Supported games==
== SSAO in the Source Engine ==
[[{{ns:6}}:Prop ragdoll.jpg|thumb|right|250px|Nvidia's SSAO implementation in game - the shading effect is highly visible between Breen and the table, and in the corners of the room. Note the edge "glow" bug around Breen's arm.]]
* The original release of {{dota2|4}} aswell as {{sfm|1}}, and all games on {{titanfall|4}} branch are the only {{src|4}} games and software that support SSAO.
All [[Source]] engine games except [[Portal]] have driver profiles to enable Nvidia's SSAO. SSAO in Portal can be forced on by editing Portal's driver profile with an external application such as nHancer.
* However, as SSAO is a post-processing effect, you can use third-party software (ReShade), or [[Source Shader Editor]] to add SSAO. Alternatively, it is possible to use the superior HBAO ambient occlusion, which can be forced through GPU driver control panel (or by using NVIDIA Profile Inspector).
{{Note|For baked Ambient Occlusion maps 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).}}


==Graphical Bugs==
==External links==
[[{{ns:6}}:Ao_renderbug_trees.jpg|thumb|left|200px|The shadows being rendered on top of fog are noticable on distant trees.]]
*[[Wikipedia:Ambient occlusion]]
Nvidia's SSAO implmentation was designed to be general purpose, and as such, does not take a lot of Source's stock effects into account during it's calculations. This leads to bleeding in scenes with heavy fog, which can be seen on the picture below. As a fault of the actual SSAO shader, Ghosting and other related artifacts, pictured on the image above, can occur. It is recommended that you use a more modern SSAO implementation that takes the scene's normals into account if you intend to design your own shader for use in Source.
*[[Wikipedia:Screen Space Ambient Occlusion]]

Latest revision as of 21:47, 8 February 2025

Stub

This article or section is a stub. You can help by expanding it.

Todo: Document about HBAO, alternative to SSAO which can be forced through GPU driver control panel (or NVIDIA Profile Inspector).
An example of traditional prerendered ambient occlusion in Blender 3D. SSAO attempts to mimic this look in real-time.
Note.pngNote: Not to be confused with baked ambient occlusion on models!
Todo: 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.

Todo: Adjust number of samples?

SSAO in the Source Engine

  • The original release of Dota 2 Dota 2 aswell as Source Filmmaker, and all games on Titanfall Titanfall branch are the only Source Source games and software that support SSAO.
  • However, as SSAO is a post-processing effect, you can use third-party software (ReShade), or Source Shader Editor to add SSAO. Alternatively, it is possible to use the superior HBAO ambient occlusion, which can be forced through GPU driver control panel (or by using NVIDIA Profile Inspector).
Note.pngNote:For baked Ambient Occlusion maps per model within the Source Engine, see $ambientocclusion.
Note.pngNote:A post process SSAO shader currently ships with the Source Shader Editor.
Todo: Write a tutorial on creating an SSAO shader and implementing it into the engine. See Shader Authoring.
Note.pngNote:I am currently writing a tutorial on implementing SSAO into Source Engine here (DmitRex).

External links