A Screen Space Ambient Occlusion (SSAO) shader material.

Hierarchy

  • ShaderMaterial
    • SSAOMaterial

Implements

Constructors

Properties

Accessors

Methods

Constructors

  • Constructs a new SSAO material.

    Parameters

    • camera: Camera

      A camera.

    Returns SSAOMaterial

Properties

alphaHash: boolean

Enables alpha hashed transparency, an alternative to .transparent or .alphaTest. The material will not be rendered if opacity is lower than a random threshold. Randomization introduces some grain or noise, but approximates alpha blending without the associated problems of sorting. Using TAARenderPass can reduce the resulting noise.

alphaToCoverage: boolean

Enables alpha to coverage. Can only be used with MSAA-enabled rendering contexts (meaning when the renderer was created with antialias parameter set to true). Enabling this will smooth aliasing on clip plane edges and alphaTest-clipped edges.

false
blendAlpha: number

Represents the alpha value of the constant blend color. This property has only an effect when using custom blending with ConstantAlphaFactor or OneMinusConstantAlphaFactor.

0
blendColor: Color

Represent the RGB values of the constant blend color. This property has only an effect when using custom blending with ConstantColorFactor or OneMinusConstantColorFactor.

0x000000
blendDst: BlendingDstFactor

Blending destination. It's one of the blending mode constants defined in Three.js. Default is OneMinusSrcAlphaFactor.

THREE.OneMinusSrcAlphaFactor
blendDstAlpha: number

The tranparency of the .blendDst. Default is null.

null
blendEquation: BlendingEquation

Blending equation to use when applying blending. It's one of the constants defined in Three.js. Default is AddEquation.

THREE.AddEquation
blendEquationAlpha: number

The tranparency of the .blendEquation. Default is null.

null
blending: Blending

Which blending to use when displaying objects with this material. Default is NormalBlending.

THREE.NormalBlending
blendSrc:
    | 200
    | 201
    | 202
    | 203
    | 204
    | 205
    | 206
    | 207
    | 208
    | 209
    | 210
    | 211
    | 212
    | 213
    | 214

Blending source. It's one of the blending mode constants defined in Three.js. Default is SrcAlphaFactor.

THREE.SrcAlphaFactor
blendSrcAlpha: number

The tranparency of the .blendSrc. Default is null.

null
clipIntersection: boolean

Changes the behavior of clipping planes so that only their intersection is clipped, rather than their union. Default is false.

false
clipping: boolean
false
clippingPlanes: Plane[]

User-defined clipping planes specified as THREE.Plane objects in world space. These planes apply to the objects this material is attached to. Points in space whose signed distance to the plane is negative are clipped (not rendered). See the WebGL / clipping /intersection example. Default is null.

null
clipShadows: boolean

Defines whether to clip shadows according to the clipping planes specified on this material. Default is false.

false
colorWrite: boolean

Whether to render the material's color. This can be used in conjunction with a mesh's .renderOrder property to create invisible objects that occlude other objects. Default is true.

true
defaultAttributeValues: any
{ 'color': [ 1, 1, 1 ], 'uv': [ 0, 0 ], 'uv1': [ 0, 0 ] }
defines: {
    [key: string]: any;
}
{}
depthFunc: DepthModes

Which depth function to use. Default is LessEqualDepth. See the depth mode constants for all possible values.

THREE.LessEqualDepth
depthTest: boolean

Whether to have depth test enabled when rendering this material. When the depth test is disabled, the depth write will also be implicitly disabled.

true
depthWrite: boolean

Whether rendering this material has any effect on the depth buffer. Default is true. When drawing 2D overlays it can be useful to disable the depth writing in order to layer several things together without creating z-index artifacts.

true
dithering: boolean

Whether to apply dithering to the color to remove the appearance of banding. Default is false.

false
extensions: {
    clipCullDistance: boolean;
    multiDraw: boolean;
}
{
* clipCullDistance: false,
* multiDraw: false
* }
fog: boolean
false
forceSinglePass: boolean
false
fragmentShader: string
glslVersion: GLSLVersion
null
id: number

Unique number of this material instance.

index0AttributeName: string
undefined
isMaterial: true

Read-only flag to check if a given object is of type Material.

This is a constant value

true

isShaderMaterial: true

Read-only flag to check if a given object is of type ShaderMaterial.

This is a constant value

true

lights: boolean
false
linewidth: number
1
name: string

Material name. Default is an empty string.

''
opacity: number

Opacity. Default is 1.

1
polygonOffset: boolean

Whether to use polygon offset. Default is false. This corresponds to the POLYGON_OFFSET_FILL WebGL feature.

false
polygonOffsetFactor: number

Sets the polygon offset factor. Default is 0.

0
polygonOffsetUnits: number

Sets the polygon offset units. Default is 0.

0
precision: "highp" | "mediump" | "lowp"

Override the renderer's default precision for this material. Can be "highp", "mediump" or "lowp". Defaults is null.

null
premultipliedAlpha: boolean

Whether to premultiply the alpha (transparency) value. See WebGL / Materials / Transparency for an example of the difference. Default is false.

false
shadowSide: Side

Defines which of the face sides will cast shadows. Default is null. If null, the value is opposite that of side, above.

null
side: Side

Defines which of the face sides will be rendered - front, back or both. Default is THREE.FrontSide. Other options are THREE.BackSide and THREE.DoubleSide.

THREE.FrontSide

stencilFail: StencilOp

Which stencil operation to perform when the comparison function returns false. Default is KeepStencilOp. See the stencil operation constants for all possible values.

THREE.KeepStencilOp
stencilFunc: StencilFunc

The stencil comparison function to use. Default is AlwaysStencilFunc. See stencil operation constants for all possible values.

THREE.AlwaysStencilFunc
stencilFuncMask: number

The bit mask to use when comparing against the stencil buffer. Default is 0xFF.

0xff
stencilRef: number

The value to use when performing stencil comparisons or stencil operations. Default is 0.

0
stencilWrite: boolean

Whether rendering this material has any effect on the stencil buffer. Default is false.

false
stencilWriteMask: number

The bit mask to use when writing to the stencil buffer. Default is 0xFF.

0xff
stencilZFail: StencilOp

Which stencil operation to perform when the comparison function returns true but the depth test fails. Default is KeepStencilOp. See the stencil operation constants for all possible values.

THREE.KeepStencilOp
stencilZPass: StencilOp

Which stencil operation to perform when the comparison function returns true and the depth test passes. Default is KeepStencilOp. See the stencil operation constants for all possible values.

THREE.KeepStencilOp
toneMapped: boolean

Defines whether this material is tone mapped according to the renderer's WebGLRenderer.toneMapping toneMapping setting. It is ignored when rendering to a render target or using post processing.

true
transparent: boolean

Defines whether this material is transparent. This has an effect on rendering as transparent objects need special treatment and are rendered after non-transparent objects. When set to true, the extent to which the material is transparent is controlled by setting it's .opacity property.

false
type: string
'ShaderMaterial'
uniforms: {
    [uniform: string]: IUniform;
}
{}
uniformsGroups: UniformsGroup[]
uniformsNeedUpdate: boolean
false
userData: Record<string, any>

An object that can be used to store custom data about the Material. It should not hold references to functions as these will not be cloned.

{}
uuid: string

UUID of this material instance. This gets automatically assigned, so this shouldn't be edited.

version: number

This starts at 0 and counts how many times .needsUpdate is set to true.

0
vertexColors: boolean

Defines whether vertex coloring is used. Default is false.

false
vertexShader: string
visible: boolean

Defines whether this material is visible. Default is true.

true
wireframe: boolean
false
wireframeLinewidth: number
1

Accessors

  • get alphaTest(): number
  • Gets the alpha value to be used when running an alpha test. Default is 0.

    Returns number

    0
    
  • set alphaTest(value): void
  • Sets the alpha value to be used when running an alpha test. Default is 0.

    Parameters

    • value: number

    Returns void

    0
    
  • get bias(): number
  • The depth bias. Range: [0.0, 1.0].

    Returns number

  • set bias(arg): void
  • Parameters

    • arg: number

    Returns void

  • set depthBuffer(arg): void
  • The depth buffer.

    Parameters

    • arg: Texture

      The buffer.

    Returns void

  • set depthPacking(arg): void
  • The depth packing strategy.

    Parameters

    • arg: DepthPackingStrategies

      The depth packing strategy.

    Returns void

  • get distanceFalloff(): number
  • The occlusion distance falloff. Range: [0.0, 1.0].

    Returns number

  • set distanceFalloff(arg): void
  • Parameters

    • arg: number

    Returns void

  • get distanceScaling(): boolean
  • Indicates whether distance-based radius scaling is enabled.

    Returns boolean

  • set distanceScaling(arg): void
  • Parameters

    • arg: boolean

    Returns void

  • get distanceThreshold(): number
  • The occlusion distance threshold. Range: [0.0, 1.0].

    Returns number

  • set distanceThreshold(arg): void
  • Parameters

    • arg: number

    Returns void

  • get fade(): number
  • The depth fade factor.

    Returns number

  • set fade(arg): void
  • Parameters

    • arg: number

    Returns void

  • get intensity(): number
  • The intensity.

    Returns number

    Use SSAOEffect.intensity instead.

  • set intensity(arg): void
  • Parameters

    • arg: number

    Returns void

  • get minRadiusScale(): number
  • The minimum radius scale for distance scaling. Range: [0.0, 1.0].

    Returns number

  • set minRadiusScale(arg): void
  • Parameters

    • arg: number

    Returns void

  • set needsUpdate(value): void
  • Specifies that the material needs to be updated, WebGL wise. Set it to true if you made changes that need to be reflected in WebGL. This property is automatically set to true when instancing a new material.

    Parameters

    • value: boolean

    Returns void

    false
    
  • set noiseTexture(arg): void
  • The noise texture.

    Parameters

    • arg: Texture

      The texture.

    Returns void

  • set normalBuffer(arg): void
  • The normal buffer.

    Parameters

    • arg: Texture

      The buffer.

    Returns void

  • set normalDepthBuffer(arg): void
  • The combined normal-depth buffer.

    Parameters

    • arg: Texture

      The buffer.

    Returns void

  • get proximityFalloff(): number
  • The occlusion proximity falloff. Range: [0.0, 1.0].

    Returns number

  • set proximityFalloff(arg): void
  • Parameters

    • arg: number

    Returns void

  • get proximityThreshold(): number
  • The occlusion proximity threshold. Range: [0.0, 1.0].

    Returns number

  • set proximityThreshold(arg): void
  • Parameters

    • arg: number

    Returns void

  • get radius(): number
  • The occlusion sampling radius. Range: [0.0, 1.0].

    Returns number

  • set radius(arg): void
  • Parameters

    • arg: number

    Returns void

  • get rings(): number
  • The sampling spiral ring count.

    Returns number

  • set rings(arg): void
  • Parameters

    • arg: number

    Returns void

  • get samples(): number
  • The sample count.

    Returns number

  • set samples(arg): void
  • Parameters

    • arg: number

    Returns void

  • get worldDistanceFalloff(): number
  • The occlusion distance falloff in world units.

    Returns number

  • set worldDistanceFalloff(value): void
  • Parameters

    • value: number

    Returns void

  • get worldDistanceThreshold(): number
  • The occlusion distance falloff. The occlusion distance threshold in world units.

    Returns number

  • set worldDistanceThreshold(value): void
  • Parameters

    • value: number

    Returns void

  • get worldProximityFalloff(): number
  • The occlusion proximity falloff in world units.

    Returns number

  • set worldProximityFalloff(value): void
  • Parameters

    • value: number

    Returns void

  • get worldProximityThreshold(): number
  • The occlusion proximity threshold in world units.

    Returns number

  • set worldProximityThreshold(value): void
  • Parameters

    • value: number

    Returns void

Methods

  • Adds a listener to an event type.

    Type Parameters

    • T extends "dispose"

    Parameters

    • type: T

      The type of event to listen to.

    • listener: EventListener<{
          dispose: {};
      }[T], T, SSAOMaterial>

      The function that gets called when the event is fired.

    Returns void

  • Adopts the settings of the given camera.

    Parameters

    • camera: Camera

      A camera.

    Returns void

  • Return a new material with the same parameters as this material.

    Returns this

  • Copy the parameters from the passed material into this material.

    Parameters

    • material: Material

    Returns this

  • In case onBeforeCompile is used, this callback can be used to identify values of settings used in onBeforeCompile, so three.js can reuse a cached shader or recompile the shader as needed.

    Returns string

  • Fire an event type.

    Type Parameters

    • T extends "dispose"

    Parameters

    • event: BaseEvent<T> & {
          dispose: {};
      }[T]

      The event that gets fired.

    Returns void

  • Frees the GPU-related resources allocated by this instance. Call this method whenever this instance is no longer used in your app.

    Material textures must be disposed of by the dispose() method of Texture.

    Returns void

  • Returns the depth bias.

    Returns number

    The bias.

    Use bias instead.

  • Returns the depth fade factor.

    Returns number

    The fade factor.

    Use fade instead.

  • Returns the intensity.

    Returns number

    The intensity.

    Use intensity instead.

  • Returns the minimum radius scale for distance scaling.

    Returns number

    The minimum radius scale.

    Use minRadiusScale instead.

  • Returns the occlusion sampling radius.

    Returns number

    The radius.

    Use radius instead.

  • Returns the amount of spiral turns in the occlusion sampling pattern.

    Returns number

    The radius.

    Use rings instead.

  • Returns the amount of occlusion samples per pixel.

    Returns number

    The sample count.

    Use samples instead.

  • Checks if listener is added to an event type.

    Type Parameters

    • T extends "dispose"

    Parameters

    • type: T

      The type of event to listen to.

    • listener: EventListener<{
          dispose: {};
      }[T], T, SSAOMaterial>

      The function that gets called when the event is fired.

    Returns boolean

  • Indicates whether distance-based radius scaling is enabled.

    Returns boolean

    Whether distance scaling is enabled.

    Use distanceScaling instead.

  • An optional callback that is executed immediately before the shader program is compiled. This function is called with the shader source code as a parameter. Useful for the modification of built-in materials. Unlike properties, the callback is not supported by .clone(), .copy() and .toJSON(). This callback is only supported in WebGLRenderer (not WebGPURenderer).

    Parameters

    • parameters: WebGLProgramParametersWithUniforms

      WebGL program parameters

    • renderer: WebGLRenderer

      WebGLRenderer context that is initializing the material

    Returns void

  • An optional callback that is executed immediately before the material is used to render a 3D object. Unlike properties, the callback is not supported by .clone(), .copy() and .toJSON(). This callback is only supported in WebGLRenderer (not WebGPURenderer).

    Parameters

    • renderer: WebGLRenderer
    • scene: Scene
    • camera: Camera
    • geometry: BufferGeometry<NormalBufferAttributes>
    • object: Object3D<Object3DEventMap>
    • group: Group<Object3DEventMap>

    Returns void

  • Parameters

    • object: Object3D<Object3DEventMap>
    • parameters: WebGLProgramParametersWithUniforms
    • renderer: WebGLRenderer

    Returns void

    onBuild() has been removed.

  • Removes a listener from an event type.

    Type Parameters

    • T extends "dispose"

    Parameters

    • type: T

      The type of the listener that gets removed.

    • listener: EventListener<{
          dispose: {};
      }[T], T, SSAOMaterial>

      The listener function that gets removed.

    Returns void

  • Sets the depth bias.

    Parameters

    • value: number

      The bias.

    Returns void

    Use bias instead.

  • Sets the depth buffer.

    Parameters

    • buffer: Texture

      The depth texture.

    • OptionaldepthPacking: DepthPackingStrategies

      The depth packing strategy.

    Returns void

    Use depthBuffer and depthPacking instead.

  • Sets the occlusion distance cutoff.

    Parameters

    • threshold: number

      The distance threshold. Range [0.0, 1.0].

    • falloff: number

      The falloff. Range [0.0, 1.0].

    Returns void

    Use distanceThreshold and distanceFalloff instead.

  • Enables or disables distance-based radius scaling.

    Parameters

    • value: boolean

      Whether distance scaling should be enabled.

    Returns void

    Use distanceScaling instead.

  • Sets the depth fade factor.

    Parameters

    • value: number

      The fade factor.

    Returns void

    Use fade instead.

  • Sets the intensity.

    Parameters

    • value: number

      The intensity.

    Returns void

    Use intensity instead.

  • Sets the minimum radius scale for distance scaling.

    Parameters

    • value: number

      The minimum radius scale.

    Returns void

    Use minRadiusScale instead.

  • Sets the noise texture.

    Parameters

    • value: Texture

      The texture.

    Returns void

    Use noiseTexture instead.

  • Sets the normal buffer.

    Parameters

    • value: Texture

      The buffer.

    Returns void

    Use normalBuffer instead.

  • Sets the combined normal-depth buffer.

    Parameters

    • value: Texture

      The buffer.

    Returns void

    Use normalDepthBuffer instead.

  • Sets the occlusion proximity cutoff.

    Parameters

    • threshold: number

      The range threshold. Range [0.0, 1.0].

    • falloff: number

      The falloff. Range [0.0, 1.0].

    Returns void

    Use proximityThreshold and proximityFalloff instead.

  • Sets the occlusion sampling radius.

    Parameters

    • value: number

      The radius. Range [1e-6, 1.0].

    Returns void

    Use radius instead.

  • Sets the amount of spiral turns in the occlusion sampling pattern.

    Parameters

    • value: number

      The radius.

    Returns void

    Use rings instead.

  • Sets the amount of occlusion samples per pixel.

    Parameters

    • value: number

      The sample count.

    Returns void

    Use samples instead.

  • Sets the size of this object.

    Parameters

    • width: number

      The width.

    • height: number

      The height.

    Returns void

  • Sets the texel size.

    Parameters

    • x: number

      The texel width.

    • y: number

      The texel height.

    Returns void

    Use setSize() instead.

  • Sets the properties based on the values.

    Parameters

    • parameters: ShaderMaterialParameters

    Returns void

  • Convert the material to three.js JSON format.

    Parameters

    • Optionalmeta: JSONMeta

      Object containing metadata such as textures or images for the material.

    Returns ShaderMaterialJSON