API

Interface IShadowGenerator

Interface to implement to create a shadow generator compatible with BJS.

interface IShadowGenerator {
    doNotSerialize?: boolean;
    id: string;
    bindShadowLight(lightIndex: string, effect: Effect): void;
    dispose(): void;
    forceCompilation(
        onCompiled?: (generator: IShadowGenerator) => void,
        options?: Partial<{ useInstances: boolean }>,
    ): void;
    forceCompilationAsync(
        options?: Partial<{ useInstances: boolean }>,
    ): Promise<void>;
    getShadowMap(): Nullable<RenderTargetTexture>;
    getTransformMatrix(): Matrix;
    isReady(
        subMesh: SubMesh,
        useInstances: boolean,
        isTransparent: boolean,
    ): boolean;
    prepareDefines(defines: MaterialDefines, lightIndex: number): void;
    recreateShadowMap(): void;
    serialize(): any;
}

Implemented by

Index
doNotSerialize?: boolean

Specifies if the ShadowGenerator should be serialized, true to skip serialization. Note a ShadowGenerator will not be serialized if its light has doNotSerialize=true

id: string

Gets or set the id of the shadow generator. It will be the one from the light if not defined

  • Binds the shadow related information inside of an effect (information like near, far, darkness... defined in the generator but impacting the effect). It implies the uniforms available on the materials are the standard BJS ones.

    Parameters

    • lightIndex: string

      Index of the light in the enabled light list of the material owning the effect

    • effect: Effect

      The effect we are binding the information for

    Returns void

  • Forces all the attached effect to compile to enable rendering only once ready vs. lazily compiling effects.

    Parameters

    • OptionalonCompiled: (generator: IShadowGenerator) => void

      Callback triggered at the and of the effects compilation

    • Optionaloptions: Partial<{ useInstances: boolean }>

      Sets of optional options forcing the compilation with different modes

    Returns void

  • Forces all the attached effect to compile to enable rendering only once ready vs. lazily compiling effects.

    Parameters

    • Optionaloptions: Partial<{ useInstances: boolean }>

      Sets of optional options forcing the compilation with different modes

    Returns Promise<void>

    A promise that resolves when the compilation completes

  • Determine whether the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).

    Parameters

    • subMesh: SubMesh

      The submesh we want to render in the shadow map

    • useInstances: boolean

      Defines whether will draw in the map using instances

    • isTransparent: boolean

      Indicates that isReady is called for a transparent subMesh

    Returns boolean

    true if ready otherwise, false