PlanarReflectorComponent class Rendering
A Component that renders a per-frame planar reflection of the scene for the mirror surface at its node.
Each frame the surface is visible, the engine renders one offscreen
capture of the scene from the view camera reflected across the surface's
plane, with the capture's near plane clamped to that plane so geometry
behind the mirror never appears. The plane passes through the node's
origin with localNormal (the local +Y by default) as its facing
direction, both taken through the node's world transform.
The capture reaches materials in this node's subtree that declare the
planar_reflection engine input in their .fmat (see MATERIALS.md),
which sample it projectively through GetPlanarReflection(). Give each
reflector group its own material instance; a material shared across
groups receives one group's capture arbitrarily.
A capture is a second scene submission. Its GPU fragment cost scales with resolutionScale, but the CPU and draw-call cost scale with scene complexity like any other view of the scene; bound it with layerMask. The capture reuses the frame's shadow atlas and runs without screen-space post-processing (no occlusion, reflections, bloom, depth of field, or god rays), and reflectors seen inside a capture draw without their own reflection (their base material look), so captures never recurse. Worst case is one extra scene render per reflection group per frame.
Captures follow the frame's primary view (the first screen view). Views
rendered to a RenderTexture composite the previous frame's capture, and
additional views reuse the primary view's capture.
Constructors
- PlanarReflectorComponent({double resolutionScale = 0.5, int layerMask = kRenderLayerAll, int reflectionGroupId = -1, double clipBias = 1e-3, Vector3? localNormal})
- Creates a planar reflector for the mirror surface at the owning node.
Properties
- clipBias ↔ double
-
World-space offset of the capture's clip plane in front of the mirror
plane, keeping the surface itself (and coplanar acne) out of the
capture. The default suits meter-scale scenes.
getter/setter pair
- enabled ↔ bool
-
Whether this component's update hook runs each frame.
getter/setter pairinherited
- hashCode → int
-
The hash code for this object.
no setterinherited
- isAttached → bool
-
Whether this component is currently attached to a node.
no setterinherited
- isLoaded → bool
-
Whether onLoad has completed.
no setterinherited
- isMounted → bool
-
Whether the owning node is part of a live scene graph.
no setterinherited
- layerMask ↔ int
-
A bitmask selecting which node layers render into the capture, the
same selection a
RenderView.layerMaskmakes. Defaults to every layer. Use it to keep expensive or irrelevant content out of the mirror.getter/setter pair - localNormal ↔ Vector3
-
The mirror plane's facing direction in the node's local space.
Defaults to
+Y(a floor mirror when the node is unrotated).getter/setter pair - node → Node
-
The node this component is attached to.
no setterinherited
- reflectionGroupId ↔ int
-
Reflectors sharing a non-negative group id share one capture per
frame; give co-planar surfaces (tiles of one floor) the same id so
they cost one scene render together. The default
-1gives this reflector its own capture. Surfaces in one group must be co-planar; the group's plane comes from one member.getter/setter pair - resolutionScale ↔ double
-
The capture's resolution relative to the view it follows, clamped to
0.1..1.0at capture time. Defaults to0.5(half resolution, a quarter of the fragment work), matching the screen-space reflection knob. Setting enabled false pauses capturing entirely and the surface falls back to its base look.getter/setter pair - runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
cloneFor(
Node cloneOwner) → Component? -
Returns a copy of this component for
cloneOwner, the Node.clone counterpart of the owning node, or null to not carry the component to clones (the default).inherited -
fixedUpdate(
double fixedDt) → void -
Called once per fixed physics step while the component is mounted,
enabled, and loaded.
fixedDtis the fixed timestep of the surrounding PhysicsWorld, not the frame interval.inherited -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
onAttach(
) → void -
Called when this component is added to a node.
inherited
-
onDetach(
) → void -
Called when this component is removed from a node.
inherited
-
onLoad(
) → Future< void> -
Optional asynchronous setup, such as loading an asset.
inherited
-
onMount(
) → void -
Called when the owning node enters a live scene graph.
override
-
onUnmount(
) → void -
Called when the owning node leaves a live scene graph.
override
-
toString(
) → String -
A string representation of this object.
inherited
-
update(
double deltaSeconds) → void -
Called once per frame while the component is mounted, enabled, and
loaded.
deltaSecondsis the elapsed time since the previous tick. A traversal visits each component at most once. Removing this component or an earlier sibling is safe. A component inserted before the current traversal position starts on the next frame. Reordering component or child lists during traversal is unsupported.inherited -
worldPlane(
) → Plane - The mirror plane in world space, derived from the node's transform: through the node's origin, facing localNormal under the node's rotation and scale.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited