Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Reflection Probe

Reflection probe is an object that allows "capturing" a scene content in a cube texture, that can later be used to render reflections and be used as a source of ambient lighting for a scene.

Update Mode

Reflection probe can be updated either once or every frame. The default mode is [UpdateMode::Once]. If you need dynamic reflections, then use [UpdateMode::EachFrame] mode. However, it may lead to performance issues.

Performance

Reflection probe renders the scene six times which is quite slow. In most cases, it does not matter because most of the probes can be updated just once (static probes). Such probes can have increased resolution.

Dynamic probes are the heaviest and require careful performance tweaking. There should be a balance between the resolution and the speed. Reflection probes does frustum culling, so some part of the scene geometry can be excluded. This functionality can be tweaked by setting the far clipping plane distance to lower values to prevent the probe to render distant objects.

Interaction With Cameras

When rendering, the engine will automatically pick a reflection probe for a camera. It is done by a simple point-box intersection test. This reflection probe will then be used for rendering using the camera.

Example

The following example creates a new reflection probe 20 units wide in all directions, centered at (0.0, 10.0, 0.0) point with a rendering position offset by 10 units along X axis.

#![allow(unused)]
fn main() {
fn create_probe(graph: &mut Graph) -> Handle<Node> {
    ReflectionProbeBuilder::new(
        BaseBuilder::new().with_local_transform(
            TransformBuilder::new()
                // The center of the probe's bounding box is located 10 units above the ground.
                .with_local_position(Vector3::new(0.0, 10.0, 0.0))
                // The size of the probe's bounding box is 20 units.
                .with_local_scale(Vector3::repeat(20.0))
                .build(),
        ),
    )
    // Set resolution of the probe.
    .with_resolution(256)
    // The probe will capture the scene once it is created.
    .with_update_mode(UpdateMode::Once)
    // Set the capture point slightly off-center. The probe will capture the scene at
    // (10.0, 10.0, 0.0) point.
    .with_rendering_local_position(Vector3::new(10.0, 0.0, 0.0))
    .build(graph)
}
}