API

Class GeometryBufferRenderer

This renderer is helpful to fill one of the render target with a geometry buffer.

Index
  • Creates a new G Buffer for the scene

    Parameters

    • scene: Scene

      The scene the buffer belongs to

    • ratioOrDimensions: number | { height: number; width: number } = 1

      How big is the buffer related to the main canvas (default: 1). You can also directly pass a width and height for the generated textures

    • depthFormat: number = Constants.TEXTUREFORMAT_DEPTH16

      Format of the depth texture (default: Constants.TEXTUREFORMAT_DEPTH16)

    • OptionaltextureTypesAndFormats: { [key: number]: IGeometryBufferTextureTypeAndFormat }

      The types, formats and optional sampling modes of textures to create as render targets. If not provided, all textures will be RGBA and float or half float, depending on the engine capabilities.

    Returns GeometryBufferRenderer

excludedSkinnedMeshesFromVelocity: AbstractMesh[] = []

Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process). Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).

generateIrradianceWithScatterMask: boolean = false

This will store a mask in the alpha channel of the irradiance texture to indicate which pixels have scattering and should be taken into account when applying image-based lighting.

generateNormalsInWorldSpace: boolean = false

Gets or sets a boolean indicating if normals should be generated in world space (default: false, meaning normals are generated in view space)

Provides the packed mesh-blending tag written for each rendered mesh.

Tags must be 0 or contain a group ID between 1 and 63 in their low six bits. Tag 0 disables mesh blending. By default, meshes use their meshBlendingTag property. Instances and thin instances use the source mesh tag. The provider runs in the render hot path and receives the source mesh for instanced draws. It should avoid allocations and return a consistent value for a mesh during a render.

Provides the object ID written for each rendered mesh.

IDs must be integers between 0 and 0xFFFFFF. ID 0 is reserved for background or excluded meshes. Instances use the ID of their source mesh. The default is the mesh unique ID. Default IDs are only stable for the lifetime of the current scene and should not be persisted. The provider runs in the render hot path and may be called multiple times for the same mesh in a frame.

useSpecificClearForDepthTexture: boolean = false

If set to true (default: false), the depth texture will be cleared with the depth value corresponding to the far plane (1 in normal mode, 0 in reverse depth buffer mode) If set to false, the depth texture is always cleared with 0.

DEPTH_TEXTURE_TYPE: 0

Constant used to retrieve the depth texture index in the G-Buffer textures array using getIndex(GeometryBufferRenderer.DEPTH_TEXTURE_INDEX)

ForceGLSL: boolean = false

Force all the standard materials to compile to glsl even on WebGPU engines. False by default. This is mostly meant for backward compatibility.

IRRADIANCE_TEXTURE_TYPE: 7

Constant used to retrieve the irradiance texture index in the G-Buffer textures array using getIndex(GeometryBufferRenderer.IRRADIANCE_TEXTURE_TYPE)

MESH_BLEND_TAG_TEXTURE_TYPE: 9

Constant used to retrieve the packed mesh-blending tag texture index in the G-Buffer textures array.

NORMAL_TEXTURE_TYPE: 1

Constant used to retrieve the normal texture index in the G-Buffer textures array using getIndex(GeometryBufferRenderer.NORMAL_TEXTURE_INDEX)

OBJECT_ID_TEXTURE_TYPE: 8

Constant used to retrieve the object ID texture index in the G-Buffer textures array. Object IDs are stored as 24-bit unsigned integers encoded in the RGB channels.

POSITION_TEXTURE_TYPE: 2

Constant used to retrieve the position texture index in the G-Buffer textures array using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)

REFLECTIVITY_TEXTURE_TYPE: 4

Constant used to retrieve the reflectivity texture index in the G-Buffer textures array using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)

SCREENSPACE_DEPTH_TEXTURE_TYPE: 5

Constant used to retrieve the screen-space depth texture index in the G-Buffer textures array using getIndex(GeometryBufferRenderer.SCREENSPACE_DEPTH_TEXTURE_TYPE)

VELOCITY_LINEAR_TEXTURE_TYPE: 6

Constant used to retrieve the linear velocity texture index in the G-Buffer textures array using getIndex(GeometryBufferRenderer.VELOCITY_LINEAR_TEXTURE_TYPE)

VELOCITY_TEXTURE_TYPE: 3

Constant used to retrieve the velocity texture index in the G-Buffer textures array using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)

  • get enableMeshBlendingTag(): boolean

    Gets whether packed mesh-blending tags are enabled for the G buffer.

    Returns boolean

  • set enableMeshBlendingTag(enable: boolean): void

    Sets whether packed mesh-blending tags are enabled for the G buffer.

    Mesh-blending tags use a single-sample R8UI color attachment and are supported on WebGL2 and WebGPU. Transparent rendering remains controlled by renderTransparentMeshes. Applications are responsible for ensuring that transparent draws do not invalidate the SceneColor and geometry-input correspondence required by the mesh-blending pass. On WebGL2, transparent rendering with this output requires per-target blend parameters.

    Enabling or disabling this output rebuilds the renderer's targets. The application retains ownership of the GeometryBufferRenderer and of every post process that consumes the output.

    Parameters

    • enable: boolean

    Returns void

  • get enableReflectivity(): boolean

    Gets a boolean indicating if objects reflectivity are enabled in the G buffer.

    Returns boolean

  • set enableReflectivity(enable: boolean): void

    Sets whether or not objects reflectivity are enabled for the G buffer. For Metallic-Roughness workflow with ORM texture, we assume that ORM texture is defined according to the default layout: pbr.useRoughnessFromMetallicTextureAlpha = false; pbr.useRoughnessFromMetallicTextureGreen = true; pbr.useMetallnessFromMetallicTextureBlue = true;

    Parameters

    • enable: boolean

    Returns void

  • Returns the index of the given texture type in the G-Buffer textures array

    Parameters

    • textureType: number

      The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX

    Returns number

    the index of the given texture type in the G-Buffer textures array