Creates a new instance of ForwardRenderPipeline.
Collection of tags associated with this object
Static
Readonly
InvalidInvalid object UID constant
Static
currentCurrent maximum object count for UID generation
Gets the unique object identifier
The object's UID
Gets the unique name of this object
The unique name string
Internal
Copies tag data from another RnObject instance to this object
The source RnObject to copy tags from
Gets the initial expression used for buffer clearing and setup.
The initial expression, or undefined if not available
Gets the tone mapping expression used for HDR to LDR conversion.
The tone mapping expression, or undefined if not available
Checks if this object has all the specified tags with exactly matching values
Object containing tag names as keys and expected values
True if all specified tags exist with matching values, false otherwise
Checks if the object's combined tag string contains all the provided search strings. This allows for flexible searching within tag names and values.
Array of strings that must all be present in the combined tag string
True if all strings are found in the combined tag string, false otherwise
Resizes the rendering pipeline to match new canvas dimensions.
New width of the rendering canvas
New height of the rendering canvas
A Result indicating success or failure of the resize operation
This method handles canvas resizing by destroying existing resources and recreating them with the new dimensions. It automatically handles WebXR canvas sizing when in VR mode.
The method preserves all current pipeline settings (shadow, bloom, etc.) during resize.
window.addEventListener('resize', () => {
const result = pipeline.resize(window.innerWidth, window.innerHeight);
if (result.isErr()) {
console.error('Resize failed:', result.getErr());
}
});
Sets the contribution factor for diffuse IBL lighting.
Contribution factor (0.0 to 1.0 or higher for over-exposure effects)
This method controls how much the diffuse IBL texture contributes to the final lighting. A value of 0.0 disables diffuse IBL, while 1.0 provides full contribution. Values greater than 1.0 can be used for artistic over-exposure effects.
// Reduce ambient lighting
pipeline.setDiffuseIBLContribution(0.5);
// Disable diffuse IBL
pipeline.setDiffuseIBLContribution(0.0);
// Over-expose for artistic effect
pipeline.setDiffuseIBLContribution(2.0);
Sets the expressions to be rendered by the pipeline.
Array of expressions containing render passes and entities to render
Configuration options for expression setup
Whether to enable transmission rendering for transparent objects (default: true)
This method configures the expressions for both opaque and transparent rendering. When transmission is enabled, transparent objects are rendered in a separate pass to support advanced material effects like glass and water.
The method automatically clones expressions for transparent rendering and configures shadow expressions if shadow mapping is enabled.
const expressions = [sceneExpression, uiExpression];
pipeline.setExpressions(expressions, { isTransmission: true });
Sets the rotation of the IBL environment in radians.
Rotation angle in radians
This method allows rotating the IBL environment to match the desired lighting direction. This is useful when the IBL doesn't align with the scene's lighting requirements or for artistic control over the environment lighting.
// Rotate IBL by 90 degrees
pipeline.setIBLRotation(Math.PI / 2);
// Rotate IBL by 180 degrees
pipeline.setIBLRotation(Math.PI);
// Animate IBL rotation
let rotation = 0;
setInterval(() => {
rotation += 0.01;
pipeline.setIBLRotation(rotation);
}, 16);
Sets the IBL (Image-Based Lighting) cube textures for realistic lighting.
Diffuse IBL cube texture for ambient lighting
Specular IBL cube texture for reflections
Optional
sheen: CubeTextureOptional sheen IBL cube texture for fabric-like materials
IBL textures provide realistic lighting by using pre-computed environment maps. The diffuse texture provides ambient lighting, while the specular texture provides reflections and specular highlights.
The sheen texture is optional and used for materials with fabric-like properties.
const diffuseCube = new Rn.CubeTexture();
diffuseCube.baseUriToLoad = './assets/ibl/diffuse/diffuse';
diffuseCube.hdriFormat = Rn.HdriFormat.RGBE_PNG;
const specularCube = new Rn.CubeTexture();
specularCube.baseUriToLoad = './assets/ibl/specular/specular';
specularCube.hdriFormat = Rn.HdriFormat.RGBE_PNG;
specularCube.mipmapLevelNumber = 10;
pipeline.setIBLTextures(diffuseCube, specularCube);
Sets the contribution factor for specular IBL reflections.
Contribution factor (0.0 to 1.0 or higher for over-exposure effects)
This method controls how much the specular IBL texture contributes to reflections and specular highlights. A value of 0.0 disables specular IBL, while 1.0 provides full contribution. Values greater than 1.0 can create over-exposed reflections.
// Subtle reflections
pipeline.setSpecularIBLContribution(0.3);
// No reflections
pipeline.setSpecularIBLContribution(0.0);
// Enhanced reflections
pipeline.setSpecularIBLContribution(1.5);
Sets the tone mapping algorithm used for HDR to LDR conversion.
The tone mapping algorithm to use
Tone mapping is essential for converting high dynamic range rendering results to low dynamic range output that can be displayed on standard monitors.
Available tone mapping algorithms:
// Use ACES tone mapping for cinematic look
pipeline.setToneMappingType(Rn.ToneMappingType.ACES_Hill);
// Use Reinhard for classic look
pipeline.setToneMappingType(Rn.ToneMappingType.Reinhard);
// Use Khronos PBR neutral for accurate colors
pipeline.setToneMappingType(Rn.ToneMappingType.KhronosPbrNeutral);
Initializes the rendering pipeline with the specified configuration.
The width of the rendering canvas in pixels
The height of the rendering canvas in pixels
Configuration options for the pipeline
Whether to enable bloom post-processing effect (default: false)
Whether to enable shadow mapping (default: false)
Whether to use simplified rendering without post-processing (default: false)
Size of the shadow map texture in pixels (default: 1024)
A Result indicating success or failure of the setup operation
This method must be called before using any other pipeline methods. It creates all necessary frame buffers, render targets, and expressions based on the provided configuration.
The method automatically detects WebXR capabilities and configures multi-view rendering when appropriate for VR applications.
const result = await pipeline.setup(1920, 1080, {
isShadow: true,
isBloom: true,
shadowMapSize: 2048
});
if (result.isErr()) {
console.error('Pipeline setup failed:', result.getErr());
}
Starts the main rendering loop with the provided draw function.
A Result indicating success or failure of starting the render loop
This method begins the continuous rendering loop using the system's render loop mechanism. The provided function will be called every frame with the current frame object.
The method automatically handles shadow system updates, expression management, and frame processing.
const result = pipeline.startRenderLoop((frame) => {
// Update scene
Rn.System.process(frame);
// Custom per-frame logic
updateAnimations();
handleInput();
});
if (result.isErr()) {
console.error('Failed to start render loop:', result.getErr());
}
Attempts to set a tag on this object. If the tag already exists, it will be replaced.
The tag object containing the name and value to set
True if the tag was successfully set, false if the tag name contains invalid characters
Attempts to set a unique name for this object
The desired unique name
If true, appends UID to make name unique when conflicts occur; if false, fails on conflict
True if the name was successfully set, false if there was a conflict and toAddNameIfConflict was false
Static
_resetStatic
getStatic
getStatic
searchSearches for the first object that has a specific tag with the given value
The tag name to search for
The tag value to match
WeakRef to the first matching object, or undefined if not found
A forward rendering pipeline that provides advanced rendering features including shadows, bloom, tone mapping, and IBL.
Remarks
ForwardRenderPipeline is a comprehensive rendering solution that handles multi-pass rendering setups with features like MSAA, shadow mapping, bloom effects, and tone mapping. It supports both regular rendering and WebXR multi-view rendering for VR applications.
The pipeline automatically manages frame buffers, render targets, and expression chains to provide a complete rendering solution similar to Unity's Universal Render Pipeline (URP).
Example