ScreenSpaceReflectionPostProcess

The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals). Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.

Hierarchy

Index

Constructors

constructor

Find examples in Playground
  • Creates a new instance of ScreenSpaceReflectionPostProcess.

    Parameters

    • name: string

      The name of the effect.

    • scene: Scene

      The scene containing the objects to calculate reflections.

    • options: number | PostProcessOptions

      The required width/height ratio to downsize to before computing the render pass.

    • camera: Nullable<Camera>

      The camera to apply the render pass to.

    • Optional samplingMode: number

      The sampling mode to be used when computing the pass. (default: 0)

    • Optional engine: Engine

      The engine which the post process will be applied. (default: current engine)

    • Optional reusable: boolean

      If the post process can be reused on the same frame. (default: false)

    • Optional textureType: number

      Type of textures used when performing the post process. (default: 0)

    • Optional blockCompilation: boolean

      If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)

    • Optional forceGeometryBuffer: boolean

      If this post process should use geometry buffer instead of prepass (default: false)

    Returns ScreenSpaceReflectionPostProcess

Properties

adaptScaleToCurrentViewport

Find examples in Playground
adaptScaleToCurrentViewport: boolean

Modify the scale of the post process to be the same as the viewport (default: false)

alphaConstants

Find examples in Playground
alphaConstants: Color4

Sets the setAlphaBlendConstants of the babylon engine

alphaMode

Find examples in Playground
alphaMode: number

Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)

alwaysForcePOT

Find examples in Playground
alwaysForcePOT: boolean

Force textures to be a power of two (default: false)

animations

Find examples in Playground
animations: Animation[]

Animations to be used for the post processing

autoClear

Find examples in Playground
autoClear: boolean

If the buffer needs to be cleared before applying the post process. (default: true) Should be set to false if shader will overwrite all previous pixels.

clearColor

Find examples in Playground
clearColor: Color4

Clear color to use when screen clearing

enablePixelPerfectMode

Find examples in Playground
enablePixelPerfectMode: boolean

Enable Pixel Perfect mode where texture is not scaled to be power of 2. Can only be used on a single postprocess or on the last one of a chain. (default: false)

forceFullscreenViewport

Find examples in Playground
forceFullscreenViewport: boolean

Force the postprocess to be applied without taking in account viewport

height

Find examples in Playground
height: number

Height of the texture to apply the post process on

inspectableCustomProperties

Find examples in Playground
inspectableCustomProperties: IInspectable[]

List of inspectable custom properties (used by the Inspector)

see

https://doc.babylonjs.com/how_to/debug_layer#extensibility

name

Find examples in Playground
name: string

Name of the PostProcess.

nodeMaterialSource

Find examples in Playground
nodeMaterialSource: Nullable<NodeMaterial>

Gets the node material used to create this postprocess (null if the postprocess was manually created)

onActivateObservable

Find examples in Playground
onActivateObservable: Observable<Camera>

An event triggered when the postprocess is activated.

onAfterRenderObservable

Find examples in Playground
onAfterRenderObservable: Observable<Effect>

An event triggered after rendering the postprocess

onApplyObservable

Find examples in Playground
onApplyObservable: Observable<Effect>

An event triggered when the postprocess applies its effect.

onBeforeRenderObservable

Find examples in Playground
onBeforeRenderObservable: Observable<Effect>

An event triggered before rendering the postprocess

onSizeChangedObservable

Find examples in Playground
onSizeChangedObservable: Observable<PostProcess>

An event triggered when the postprocess changes its size.

reflectionSpecularFalloffExponent

Find examples in Playground
reflectionSpecularFalloffExponent: number

Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.

renderTargetSamplingMode

Find examples in Playground
renderTargetSamplingMode: number

Sampling mode used by the shader See https://doc.babylonjs.com/classes/3.1/texture

roughnessFactor

Find examples in Playground
roughnessFactor: number

Gets or sets the factor applied when computing roughness. Default value is 0.2.

scaleMode

Find examples in Playground
scaleMode: number

Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)

Value Type Description
1 SCALEMODE_FLOOR engine.scalemode_floor
2 SCALEMODE_NEAREST engine.scalemode_nearest
3 SCALEMODE_CEILING engine.scalemode_ceiling

step

Find examples in Playground
step: number

Gets or sets the step size used to iterate until the effect finds the color of the reflection's pixel. Typically in interval [0.1, 1.0]

strength

Find examples in Playground
strength: number

Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.

threshold

Find examples in Playground
threshold: number

Gets or sets a reflection threshold mainly used to adjust the reflection's height.

uniqueId

Find examples in Playground
uniqueId: number

Gets or sets the unique id of the post process

width

Find examples in Playground
width: number

Width of the texture to apply the post process on

Accessors

aspectRatio

Find examples in Playground
  • get aspectRatio(): number

enableSmoothReflections

Find examples in Playground
  • get enableSmoothReflections(): boolean
  • set enableSmoothReflections(enabled: boolean): any
  • Gets wether or not smoothing reflections is enabled. Enabling smoothing will require more GPU power and can generate a drop in FPS.

    Returns boolean

  • Sets wether or not smoothing reflections is enabled. Enabling smoothing will require more GPU power and can generate a drop in FPS.

    Parameters

    • enabled: boolean

    Returns any

inputTexture

Find examples in Playground
  • The input texture for this post process and the output texture of the previous post process. When added to a pipeline the previous post process will render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.

    Returns InternalTexture

  • The input texture for this post process and the output texture of the previous post process. When added to a pipeline the previous post process will render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.

    Parameters

    Returns any

isSupported

Find examples in Playground
  • get isSupported(): boolean

onActivate

Find examples in Playground
  • set onActivate(callback: Nullable<function>): any

onAfterRender

Find examples in Playground
  • set onAfterRender(callback: function): any

onApply

Find examples in Playground
  • set onApply(callback: function): any

onBeforeRender

Find examples in Playground
  • set onBeforeRender(callback: function): any

onSizeChanged

Find examples in Playground
  • set onSizeChanged(callback: function): any

reflectionSamples

Find examples in Playground
  • get reflectionSamples(): number
  • set reflectionSamples(samples: number): any
  • Gets the number of samples taken while computing reflections. More samples count is high, more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].

    Returns number

  • Sets the number of samples taken while computing reflections. More samples count is high, more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].

    Parameters

    • samples: number

    Returns any

samples

Find examples in Playground
  • get samples(): number
  • set samples(n: number): any

smoothSteps

Find examples in Playground
  • get smoothSteps(): number
  • set smoothSteps(steps: number): any
  • Gets the number of samples taken while smoothing reflections. More samples count is high, more the post-process will require GPU power and can generate a drop in FPS. Default value (5.0) work pretty well in all cases but can be adjusted.

    Returns number

  • Gets the number of samples taken while smoothing reflections. More samples count is high, more the post-process will require GPU power and can generate a drop in FPS. Default value (5.0) work pretty well in all cases but can be adjusted.

    Parameters

    • steps: number

    Returns any

texelSize

Find examples in Playground

Methods

activate

Find examples in Playground
  • Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable. When this post process is used in a pipeline, this is call will bind the input texture of this post process to the output of the previous.

    Parameters

    • camera: Nullable<Camera>

      The camera that will be used in the post process. This camera will be used when calling onActivateObservable.

    • Optional sourceTexture: Nullable<InternalTexture>

      The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)

    • Optional forceDepthStencil: boolean

      If true, a depth and stencil buffer will be generated. (default: false)

    Returns InternalTexture

    The target texture that was bound to be written to.

apply

Find examples in Playground

dispose

Find examples in Playground
  • dispose(camera?: Camera): void

getCamera

Find examples in Playground

getClassName

Find examples in Playground
  • getClassName(): string
  • Gets a string identifying the name of the class

    Returns string

    "ScreenSpaceReflectionPostProcess" string

getEffect

Find examples in Playground

getEffectName

Find examples in Playground
  • getEffectName(): string

getEngine

Find examples in Playground

isReady

Find examples in Playground
  • isReady(): boolean

isReusable

Find examples in Playground
  • isReusable(): boolean

markTextureDirty

Find examples in Playground
  • markTextureDirty(): void

restoreDefaultInputTexture

Find examples in Playground
  • restoreDefaultInputTexture(): void

serialize

Find examples in Playground
  • serialize(): any

setPrePassRenderer

Find examples in Playground

shareOutputWith

Find examples in Playground

updateEffect

Find examples in Playground
  • updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: function, onError?: function, vertexUrl?: string, fragmentUrl?: string): void
  • Updates the effect with the current post process compile time values and recompiles the shader.

    Parameters

    • Optional defines: Nullable<string>

      Define statements that should be added at the beginning of the shader. (default: null)

    • Optional uniforms: Nullable<string[]>

      Set of uniform variables that will be passed to the shader. (default: null)

    • Optional samplers: Nullable<string[]>

      Set of Texture2D variables that will be passed to the shader. (default: null)

    • Optional indexParameters: any

      The index parameters to be used for babylons include syntax "#include[0..varyingCount]". (default: undefined) See usage in babylon.blurPostProcess.ts and kernelBlur.vertex.fx

    • Optional onCompiled: function

      Called when the shader has been compiled.

        • Parameters

          Returns void

    • Optional onError: function

      Called if there is an error when compiling a shader.

        • (effect: Effect, errors: string): void
        • Parameters

          • effect: Effect
          • errors: string

          Returns void

    • Optional vertexUrl: string

      The url of the vertex shader to be used (default: the one given at construction time)

    • Optional fragmentUrl: string

      The url of the fragment shader to be used (default: the one given at construction time)

    Returns void

useOwnOutput

Find examples in Playground
  • useOwnOutput(): void
  • Reverses the effect of calling shareOutputWith and returns the post process back to its original state. This should be called if the post process that shares output with this post process is disabled/disposed.

    Returns void

Static Parse

Find examples in Playground
  • Creates a material from parsed material data

    Parameters

    • parsedPostProcess: any

      defines parsed post process data

    • scene: Scene

      defines the hosting scene

    • rootUrl: string

      defines the root URL to use to load textures

    Returns Nullable<PostProcess>

    a new post process

Generated using TypeDoc