rememberRenderTarget

fun rememberRenderTarget(scene: FilamentScene, cameraState: CameraState = rememberCameraState(), width: Int = 512, height: Int = 512, postProcessingEnabled: Boolean = false): Texture?

Renders a FilamentScene off-screen through its own camera into a Texture that you can feed back into a material — the building block for mini-maps, security-camera monitors, portals and thumbnails. Returns the color attachment as a sampleable Texture (null until valid).

The off-screen view owns its own View, Camera and Renderer and redraws every frame via Renderer.renderStandaloneView; it is independent of any on-screen FilamentView. Bind the returned texture like any other:

val scene = rememberFilamentScene { /* world */}
val mapCam = rememberCameraState(eye = Position(0f, 40f, 0f), target = Position(0f))
val mapTex = rememberRenderTarget(scene, mapCam, width = 256, height = 256)

val instance = rememberMaterialInstance(screenMaterial)
if (mapTex != null) MaterialParameters(instance) { parameter("screen", mapTex) }
Plane(material = instance) // a screen showing the mini-map

Post-processing is disabled by default: a DEPTH attachment is used, and Filament ignores depth attachments when post-processing is on. Enable it only if you don't depend on the depth buffer.

Return

The color texture being rendered into, or null for a non-positive size.

Parameters

scene

The scene to render off-screen. Supplies the engine.

cameraState

Hoisted camera for the off-screen view. Defaults to a fresh state.

width

Texture width in pixels.

height

Texture height in pixels.

postProcessingEnabled

Whether to run the post-processing pass (see note above).