SSAOEffect
Extends:
Indirect Implements:
A Screen Space Ambient Occlusion effect.
Based on "Scalable Ambient Obscurance" by Morgan McGuire et al. and "Depth-aware upsampling experiments" by Eleni Maria Stea: https://research.nvidia.com/publication/scalable-ambient-obscurance https://eleni.mutantstargoat.com/hikiko/on-depth-aware-upsampling
The view position calculation is based on a shader by Norbert Nopper: https://github.com/McNopper/OpenGL/blob/master/Example28/shader/ssao.frag.glsl
Constructor Summary
| Public Constructor | ||
| public |
constructor(camera: Camera, normalBuffer: Texture, options: Object) Constructs a new SSAO effect. |
|
Member Summary
| Public Members | ||
| public get |
color: Color The color of the ambient occlusion. |
|
| public set |
|
|
| public get |
Indicates whether depth-aware upsampling is enabled. |
|
| public set |
|
|
| public get |
this get was deprecated.
Indicates whether distance-based radius scaling is enabled. |
|
| public set |
|
|
| public get |
The intensity. |
|
| public set |
|
|
| public get |
The luminance influence factor. |
|
| public set |
|
|
| public set |
|
|
| public get |
normalBuffer: Texture Sets the normal buffer. |
|
| public set |
|
|
| public get |
this get was deprecated. Use ssaoMaterial.radius instead.
The occlusion sampling radius. |
|
| public set |
|
|
| public get |
this get was deprecated. Use ssaoMaterial.rings instead.
The amount of spiral turns in the occlusion sampling pattern. |
|
| public set |
|
|
| public get |
this get was deprecated. Use ssaoMaterial.samples instead.
The amount of occlusion samples per pixel. |
|
| public set |
|
|
| public get |
The SSAO material. |
|
Method Summary
| Public Methods | ||
| public |
getColor(): Color this method was deprecated. Use color instead.
Returns the color of the ambient occlusion. |
|
| public |
this method was deprecated. Use resolution instead.
Returns the resolution settings. |
|
| public |
this method was deprecated. Use ssaoMaterial instead.
Returns the SSAO material. |
|
| public |
initialize(renderer: WebGLRenderer, alpha: Boolean, frameBufferType: Number) Performs initialization tasks. |
|
| public |
this method was deprecated. Use depthAwareUpsampling instead.
Indicates whether depth-aware upsampling is enabled. |
|
| public |
setColor(value: Color) this method was deprecated. Use color instead.
Sets the color of the ambient occlusion. |
|
| public |
this method was deprecated. Use depthAwareUpsampling instead.
Enables or disables depth-aware upsampling. |
|
| public |
setDepthTexture(depthTexture: Texture, depthPacking: DepthPackingStrategies) Sets the depth texture. |
|
| public |
setDistanceCutoff(threshold: Number, falloff: Number) this method was deprecated. Use ssaoMaterial instead.
Sets the occlusion distance cutoff. |
|
| public |
setProximityCutoff(threshold: Number, falloff: Number) this method was deprecated. Use ssaoMaterial instead.
Sets the occlusion proximity cutoff. |
|
| public |
Sets the size. |
|
| public |
Updates this effect. |
|
Inherited Summary
| From class Effect | ||
| public get |
inputColorSpace: ColorSpace this get is experimental.
The input color space. |
|
| public set |
mainCamera: Camera Sets the main camera. |
|
| public set |
mainScene: Scene Sets the main scene. |
|
| public get |
outputColorSpace: ColorSpace this get is experimental.
The output color space. |
|
| protected set |
inputColorSpace: ColorSpace this set is experimental.
|
|
| protected set |
outputColorSpace: ColorSpace this set is experimental.
|
|
| public |
The blend mode of this effect. |
|
| public |
Preprocessor macro definitions. |
|
| public |
WebGL extensions that are required by this effect. |
|
| public |
The name of this effect. |
|
| public |
Shader uniforms. |
|
| protected |
renderer: WebGLRenderer this member was deprecated.
The renderer. |
|
| public |
dispose() Performs a shallow search for properties that define a dispose method and deletes them. |
|
| public |
Returns the effect attributes. |
|
| public |
this method was deprecated. Use blendMode instead.
Returns the blend mode. |
|
| public |
getDefines(): Map<String, String> this method was deprecated. Use defines instead.
Returns the preprocessor macro definitions. |
|
| public |
this method was deprecated. Use extensions instead.
Returns the WebGL extensions that are required by this effect. |
|
| public |
Returns the fragment shader. |
|
| public |
this method was deprecated. Use name instead.
Returns the name of this effect. |
|
| public |
getUniforms(): Map<String, Uniform> this method was deprecated. Use uniforms instead.
Returns the uniforms of this effect. |
|
| public |
Returns the vertex shader. |
|
| public |
initialize(renderer: WebGLRenderer, alpha: Boolean, frameBufferType: Number) Performs initialization tasks. |
|
| public |
setDepthTexture(depthTexture: Texture, depthPacking: DepthPackingStrategies) Sets the depth texture. |
|
| public |
setRenderer(renderer: WebGLRenderer) this method was deprecated.
Sets the renderer. |
|
| public |
Updates the size of this effect. |
|
| public |
Updates this effect by performing supporting operations. |
|
| protected |
setAttributes(attributes: EffectAttribute) Sets the effect attributes. |
|
| protected |
Informs the associated EffectPass that this effect requires a shader recompilation. |
|
| protected |
setFragmentShader(fragmentShader: String) Sets the fragment shader. |
|
| protected |
setVertexShader(vertexShader: String) Sets the vertex shader. |
|
Public Constructors
public constructor(camera: Camera, normalBuffer: Texture, options: Object) source
Constructs a new SSAO effect.
Override:
Effect#constructorParams:
| Name | Type | Attribute | Description |
| camera | Camera |
|
The main camera. |
| normalBuffer | Texture |
|
A texture that contains the scene normals. |
| options | Object |
|
The options. |
| options.blendFunction | BlendFunction |
|
The blend function of this effect. |
| options.distanceScaling | Boolean |
|
Deprecated. |
| options.depthAwareUpsampling | Boolean |
|
Enables or disables depth-aware upsampling. Has no effect if WebGL 2 is not supported. |
| options.normalDepthBuffer | Texture |
|
Deprecated. |
| options.samples | Number |
|
The amount of samples per pixel. Should not be a multiple of the ring count. |
| options.rings | Number |
|
The amount of spiral turns in the occlusion sampling pattern. Should be a prime number. |
| options.worldDistanceThreshold | Number |
|
The world distance threshold at which the occlusion effect starts to fade out. |
| options.worldDistanceFalloff | Number |
|
The world distance falloff. Influences the smoothness of the occlusion cutoff. |
| options.worldProximityThreshold | Number |
|
The world proximity threshold at which the occlusion starts to fade out. |
| options.worldProximityFalloff | Number |
|
The world proximity falloff. Influences the smoothness of the proximity cutoff. |
| options.distanceThreshold | Number |
|
Deprecated. |
| options.distanceFalloff | Number |
|
Deprecated. |
| options.rangeThreshold | Number |
|
Deprecated. |
| options.rangeFalloff | Number |
|
Deprecated. |
| options.minRadiusScale | Number |
|
The minimum radius scale. |
| options.luminanceInfluence | Number |
|
Determines how much the luminance of the scene influences the ambient occlusion. |
| options.radius | Number |
|
The occlusion sampling radius, expressed as a scale relative to the resolution. Range [1e-6, 1.0]. |
| options.intensity | Number |
|
The intensity of the ambient occlusion. |
| options.bias | Number |
|
An occlusion bias. Eliminates artifacts caused by depth discontinuities. |
| options.fade | Number |
|
Influences the smoothness of the shadows. A lower value results in higher contrast. |
| options.color | Color |
|
The color of the ambient occlusion. |
| options.resolutionScale | Number |
|
The resolution scale. |
| options.resolutionX | Number |
|
The horizontal resolution. |
| options.resolutionY | Number |
|
The vertical resolution. |
| options.width | Number |
|
Deprecated. Use resolutionX instead. |
| options.height | Number |
|
Deprecated. Use resolutionY instead. |
TODO:
- Move normalBuffer to options.
Public Members
public set color source
public get depthAwareUpsampling: Boolean source
Indicates whether depth-aware upsampling is enabled.
public set depthAwareUpsampling source
public get distanceScaling: Boolean source
Indicates whether distance-based radius scaling is enabled.
public set distanceScaling source
public set intensity source
public set luminanceInfluence source
public set normalBuffer source
public get radius: Number source
The occlusion sampling radius.
public set radius source
public get rings: Number source
The amount of spiral turns in the occlusion sampling pattern.
public set rings source
public get samples: Number source
The amount of occlusion samples per pixel.
public set samples source
Public Methods
public getColor(): Color source
Returns the color of the ambient occlusion.
Return:
| Color | The color. |
public getResolution(): Resolution source
Returns the resolution settings.
public getSSAOMaterial(): SSAOMaterial source
Returns the SSAO material.
public initialize(renderer: WebGLRenderer, alpha: Boolean, frameBufferType: Number) source
Performs initialization tasks.
Override:
Effect#initializepublic isDepthAwareUpsamplingEnabled(): Boolean source
Indicates whether depth-aware upsampling is enabled.
public setColor(value: Color) source
Sets the color of the ambient occlusion. Set to null to disable colorization.
Params:
| Name | Type | Attribute | Description |
| value | Color | The color. |
public setDepthAwareUpsamplingEnabled(value: Boolean) source
Enables or disables depth-aware upsampling.
Params:
| Name | Type | Attribute | Description |
| value | Boolean | Whether depth-aware upsampling should be enabled. |
public setDepthTexture(depthTexture: Texture, depthPacking: DepthPackingStrategies) source
Sets the depth texture.
Override:
Effect#setDepthTextureParams:
| Name | Type | Attribute | Description |
| depthTexture | Texture | A depth texture. |
|
| depthPacking | DepthPackingStrategies |
|
The depth packing. |
public setDistanceCutoff(threshold: Number, falloff: Number) source
Sets the occlusion distance cutoff.
public setProximityCutoff(threshold: Number, falloff: Number) source
Sets the occlusion proximity cutoff.
public update(renderer: WebGLRenderer, inputBuffer: WebGLRenderTarget, deltaTime: Number) source
Updates this effect.
Override:
Effect#updateParams:
| Name | Type | Attribute | Description |
| renderer | WebGLRenderer | The renderer. |
|
| inputBuffer | WebGLRenderTarget | A frame buffer that contains the result of the previous pass. |
|
| deltaTime | Number |
|
The time between the last frame and the current one in seconds. |
