Class GeometryBufferRenderer
Index
Constructors
Properties
Accessors
Methods
Constructors
constructor
-
new GeometryBufferRenderer(
scene: Scene,
ratioOrDimensions?: number | { height: number; width: number },
depthFormat?: number,
textureTypesAndFormats?: {
[key: number]: IGeometryBufferTextureTypeAndFormat;
},
): GeometryBufferRendererCreates 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
- scene: Scene
Properties
excluded Skinned Meshes From Velocity
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).
generate Irradiance With Scatter Mask
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.
generate Normals In World Space
Gets or sets a boolean indicating if normals should be generated in world space (default: false, meaning normals are generated in view space)
Optionalmesh Blend Tag Provider
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.
Optionalobject Id Provider
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.
use Specific Clear For Depth Texture
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.
Static ReadonlyDEPTH_ TEXTURE_ TYPE
Constant used to retrieve the depth texture index in the G-Buffer textures array using getIndex(GeometryBufferRenderer.DEPTH_TEXTURE_INDEX)
StaticForce GLSL
Force all the standard materials to compile to glsl even on WebGPU engines. False by default. This is mostly meant for backward compatibility.
Static ReadonlyIRRADIANCE_ TEXTURE_ TYPE
Constant used to retrieve the irradiance texture index in the G-Buffer textures array using getIndex(GeometryBufferRenderer.IRRADIANCE_TEXTURE_TYPE)
Static ReadonlyMESH_ BLEND_ TAG_ TEXTURE_ TYPE
Constant used to retrieve the packed mesh-blending tag texture index in the G-Buffer textures array.
Static ReadonlyNORMAL_ TEXTURE_ TYPE
Constant used to retrieve the normal texture index in the G-Buffer textures array using getIndex(GeometryBufferRenderer.NORMAL_TEXTURE_INDEX)
Static ReadonlyOBJECT_ ID_ TEXTURE_ TYPE
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.
Static ReadonlyPOSITION_ TEXTURE_ TYPE
Constant used to retrieve the position texture index in the G-Buffer textures array using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
Static ReadonlyREFLECTIVITY_ TEXTURE_ TYPE
Constant used to retrieve the reflectivity texture index in the G-Buffer textures array using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
Static ReadonlySCREENSPACE_ DEPTH_ TEXTURE_ TYPE
Constant used to retrieve the screen-space depth texture index in the G-Buffer textures array using getIndex(GeometryBufferRenderer.SCREENSPACE_DEPTH_TEXTURE_TYPE)
Static ReadonlyVELOCITY_ LINEAR_ TEXTURE_ TYPE
Constant used to retrieve the linear velocity texture index in the G-Buffer textures array using getIndex(GeometryBufferRenderer.VELOCITY_LINEAR_TEXTURE_TYPE)
Static ReadonlyVELOCITY_ TEXTURE_ TYPE
Constant used to retrieve the velocity texture index in the G-Buffer textures array using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
Accessors
enable Depth
-
get enableDepth(): boolean
Returns boolean
a boolean indicating if object's depths are enabled for the G buffer.
-
set enableDepth(enable: boolean): void
Sets whether or not object's depths are enabled for the G buffer.
Parameters
- enable: boolean
Returns void
enable Irradiance
-
get enableIrradiance(): boolean
Gets a boolean indicating if objects irradiance are enabled in the G buffer.
Returns boolean
-
set enableIrradiance(enable: boolean): void
Sets whether or not objects irradiance are enabled for the G buffer.
Parameters
- enable: boolean
Returns void
enable Mesh Blending Tag
-
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
enable Normal
-
get enableNormal(): boolean
Returns boolean
a boolean indicating if object's normals are enabled for the G buffer.
-
set enableNormal(enable: boolean): void
Sets whether or not object's normals are enabled for the G buffer.
Parameters
- enable: boolean
Returns void
enable Object Id
-
get enableObjectId(): boolean
Gets whether object IDs are enabled for the G buffer.
Returns boolean
-
set enableObjectId(enable: boolean): void
Sets whether object IDs are enabled for the G buffer.
Object ID rendering currently requires a single-sample G buffer. Object ID rendering is not supported when the G buffer is linked to the PrePassRenderer.
Parameters
- enable: boolean
Returns void
enable Position
-
get enablePosition(): boolean
Returns boolean
a boolean indicating if objects positions are enabled for the G buffer.
-
set enablePosition(enable: boolean): void
Sets whether or not objects positions are enabled for the G buffer.
Parameters
- enable: boolean
Returns void
enable Reflectivity
-
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
enable Screenspace Depth
-
get enableScreenspaceDepth(): boolean
Sets whether or not objects screenspace depth are enabled for the G buffer.
Returns boolean
-
set enableScreenspaceDepth(enable: boolean): void
Parameters
- enable: boolean
Returns void
enable Velocity
-
get enableVelocity(): boolean
Returns boolean
a boolean indicating if objects velocities are enabled for the G buffer.
-
set enableVelocity(enable: boolean): void
Sets whether or not objects velocities are enabled for the G buffer.
Parameters
- enable: boolean
Returns void
enable Velocity Linear
-
get enableVelocityLinear(): boolean
Returns boolean
a boolean indicating if object's linear velocities are enabled for the G buffer.
-
set enableVelocityLinear(enable: boolean): void
Sets whether or not object's linear velocities are enabled for the G buffer.
Parameters
- enable: boolean
Returns void
is Supported
-
get isSupported(): boolean
Gets whether or not G buffer are supported by the running hardware. This requires draw buffer supports
Returns boolean
normals Are Unsigned
-
get normalsAreUnsigned(): boolean
Gets a boolean indicating if normals are encoded in the [0,1] range in the render target. If true, you should do
normal = normal_rt * 2.0 - 1.0to get the right normalReturns boolean
ratio
-
get ratio(): number
Gets the ratio used by the buffer during its creation. How big is the buffer related to the main canvas.
Returns number
render List
-
Gets the render list (meshes to be rendered) used in the G buffer.
Returns Nullable<AbstractMesh[]>
-
Set the render list (meshes to be rendered) used in the G buffer.
Parameters
- meshes: Nullable<AbstractMesh[]>
Returns void
render Transparent Meshes
-
get renderTransparentMeshes(): boolean
Gets or sets a boolean indicating if transparent meshes should be rendered
Returns boolean
-
set renderTransparentMeshes(value: boolean): void
Parameters
- value: boolean
Returns void
samples
-
get samples(): number
Gets the number of samples used to render the buffer (anti aliasing).
Returns number
-
set samples(value: number): void
Sets the number of samples used to render the buffer (anti aliasing).
Parameters
- value: number
Returns void
scene
-
Gets the scene associated with the buffer.
Returns Scene
shader Language
-
get shaderLanguage(): ShaderLanguage
Gets the shader language used in this material.
Returns ShaderLanguage
Methods
dispose
-
Disposes the renderer and frees up associated resources.
Returns void
get G Buffer
get Texture Index
-
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
- textureType: number
is Ready
-
Checks whether everything is ready to render a submesh to the G buffer.
Parameters
- subMesh: SubMesh
the submesh to check readiness for
- useInstances: boolean
is the mesh drawn using instance or not
Returns boolean
true if ready otherwise false
- subMesh: SubMesh
This renderer is helpful to fill one of the render target with a geometry buffer.