• Public
  • Public/Protected
  • All

Class ComputeEffect

Effect wrapping a compute shader and let execute (dispatch) the shader


  • ComputeEffect




  • Creates a compute effect that can be used to execute a compute shader


    • baseName: any

      Name of the effect

    • options: IComputeEffectCreationOptions

      Set of all options to create the effect

    • engine: Engine

      The engine the effect is created for

    • Optional key: string

      Effect Key identifying uniquely compiled shader variants

    Returns ComputeEffect


definesSearch playground for defines

defines: string

String container all the define statements that should be set on the shader.

nameSearch playground for name

name: any

Name of the effect.

onBindObservableSearch playground for onBindObservable

onBindObservable: Observable<ComputeEffect>

Observable that will be called when effect is bound.

onCompileObservableSearch playground for onCompileObservable

onCompileObservable: Observable<ComputeEffect>

Observable that will be called when the shader is compiled. It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.

onCompiledSearch playground for onCompiled

onCompiled: Nullable<(effect: ComputeEffect) => void>

Callback that will be called when the shader is compiled.

onErrorSearch playground for onError

onError: Nullable<(effect: ComputeEffect, errors: string) => void>

Callback that will be called if an error occurs during shader compilation.

onErrorObservableSearch playground for onErrorObservable

onErrorObservable: Observable<ComputeEffect>

Observable that will be called if an error occurs during shader compilation.

uniqueIdSearch playground for uniqueId

uniqueId: number

Unique ID of the effect.

Static LogShaderCodeOnCompilationErrorSearch playground for LogShaderCodeOnCompilationError

LogShaderCodeOnCompilationError: boolean

Enable logging of the shader code when a compilation error occurs



  • get computeSourceCode(): string
  • Gets the compute shader source code of this effect

    Returns string


  • get key(): string
  • Unique key for this effect

    Returns string


  • get rawComputeSourceCode(): string
  • Gets the compute shader source code before it has been processed by the preprocessor

    Returns string


disposeSearch playground for dispose

  • dispose(): void
  • Release all associated resources.

    Returns void

executeWhenCompiledSearch playground for executeWhenCompiled

  • executeWhenCompiled(func: (effect: ComputeEffect) => void): void
  • Adds a callback to the onCompiled observable and call the callback immediately if already ready.


    Returns void

getCompilationErrorSearch playground for getCompilationError

  • getCompilationError(): string
  • The error from the last compilation.

    Returns string

    the error string.

getEngineSearch playground for getEngine

  • The engine the effect was initialized with.

    Returns Engine

    the engine.

getPipelineContextSearch playground for getPipelineContext

  • The pipeline context for this effect

    Returns Nullable<IComputePipelineContext>

    the associated pipeline context

isReadySearch playground for isReady

  • isReady(): boolean
  • If the effect has been compiled and prepared.

    Returns boolean

    if the effect is compiled and prepared.

Static RegisterShaderSearch playground for RegisterShader

  • RegisterShader(name: string, computeShader: string): void
  • This function will add a new compute shader to the shader store


    • name: string

      the name of the shader

    • computeShader: string

      compute shader content

    Returns void


  • Constructor
  • Property
  • Method
  • Property
  • Method
  • Inherited property
  • Inherited method
  • Static property
  • Static method