'scene.enablePrePassRenderer is not a function' when creating a SSRRenderingPipeline?

Playground: Babylon.js Playground

In the Playground, the following is fine:

    // This creates a basic Babylon Scene object (non-mesh)
    var scene = new BABYLON.Scene(engine);

    // This creates and positions a free camera (non-mesh)
    var camera = new BABYLON.FreeCamera("camera1", new BABYLON.Vector3(0, 5, -10), scene);

    const ssr = new BABYLON.SSRRenderingPipeline
    (
        "ssr", // The name of the pipeline
        scene, // The scene to which the pipeline belongs
        [scene.activeCamera], // The list of cameras to attach the pipeline to
        false, // Whether or not to use the geometry buffer renderer (default: false, use the pre-pass renderer)
        BABYLON.Constants.TEXTURETYPE_UNSIGNED_BYTE, // The texture type used by the SSR effect (default: TEXTURETYPE_UNSIGNED_BYTE)
    );

But in my own project, even though the scene is properly initialized, the console returns ‘Uncaught TypeError: scene.enablePrePassRenderer is not a function’ inside the constructor of the SSRRenderingPipeline.

I have tried creating a brand new scene with no additional parameters, and toggling the froceGeometryBuffer parameter in the constructor, but none of those worked. It seems the constructor doesn’t recognize the scene, even though I can manually call that method myself.
I have no idea what could be causing this.

What are your imports? Seems the error comes from uncorrect or non-full import.

1 Like

Make sure you import prePassRendererSceneComponent (import "@babylonjs/Rendering/prePassRendererSceneComponent).

See also:

https://doc.babylonjs.com/setup/frameworkPackages/es6Support#faq

2 Likes

This was the right track, there were some imports missing that were causing secondary effects. I added

import "@babylonjs/core/Rendering/prePassRendererSceneComponent";
import "@babylonjs/core/Rendering/geometryBufferRendererSceneComponent";

to force babylon to register the scene’s rendering functions.

Thank you both for your time.

1 Like