rememberRenderTargetTexture

fun rememberRenderTargetTexture(scene: FilamentScene, cameraState: CameraState = rememberCameraState(), width: Int = 512, height: Int = 512, postProcessing: PostProcessing = PostProcessing(enabled = false), shadows: Shadows? = Shadows.Pcf, renderingEnabled: Boolean = true): 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(initialEye = Position(0f, 40f, 0f), initialTarget = Position(0f))
val mapTex = rememberRenderTargetTexture(scene, mapCam, width = 256, height = 256)

val screen = rememberMaterialInstance(screenMaterial, mapTex) {
mapTex?.let { setParameter("screen", it, TextureSampler(TextureSampler.MagFilter.LINEAR)) }
}
Plane(material = screen) // a screen showing the mini-map

Post-processing is off by default (PostProcessing(enabled = false)): a DEPTH attachment is used, and Filament ignores depth attachments when post-processing is on. Pass a fully enabled PostProcessing — the same type and nullability FilamentView takes — 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.

postProcessing

Post-processing configuration for the off-screen view. Defaults to PostProcessing(enabled = false), which skips the pass entirely — see the note above.

shadows

Shadow technique for the off-screen view, or null for none, as on FilamentView.

renderingEnabled

Redraw the texture on every display refresh. false stops once the current scene is in it and keeps that frame, as on FilamentView: for a thumbnail, or a monitor nobody sees.