Render textures
A render texture is a camera's view drawn into a texture instead of onto the screen. That texture then becomes something you use elsewhere — a UI panel, a material map, a mirror, a minimap, a…
A camera renders into a texture you create
A render texture is just a GPU texture — the same kind a .texture asset uploads to — that starts empty and gets its pixels from a camera instead of a CPU upload. So you create the texture first (it owns its own size), then point a camera at it:
-- The texture the camera renders into — a GPU texture with no pixels yet.
local tex = renderer.texture.create({ width = 512, height = 512, name = "mirror" })
local e = entity.spawn("mirror_cam") -- returns the entity proxy directly
e.position = { 0, 3, 5 }
e.component.add("Camera", { priority = 5 })
local cam = e.component.get("Camera")
cam:setTargetTexture(tex) -- render into the texture (nil = back to the viewport)
cam:lookAt({ 0, 1, 0 }) -- aim it (entity id or {x, y, z})
A second camera like this renders a view distinct from the player's primary camera (which the scene already spawns — the scenes guide). Its Camera fields fov / near / far / priority and the renderLayers spec (e.g. "all !ui", where ui / sky / postProcess / EditorUI are built-in layers) control what and how it draws.
The camera only references the texture — it doesn't own it. The texture's lifetime is yours: free it with renderer.destroy(tex) when you're done (this reclaims the GPU texture and the camera's render scratch). Don't rely on the camera's despawn to clean it up.
Using the result
tex is a texture like any other; its tex.guid is what other things reference. Two common destinations:
-
In UI — the
viewportwidget takes the texture guid, giving you in-UI 3D views and minimaps (the ui guide):{ type = "viewport", props = { renderTarget = tex.guid } } -
On a surface — feed
tex.guidto a material as a texture so a mesh displays the rendered view (a screen, a mirror) (the materials guide):Material.setTexture("monitor_mat", "base_color_texture", tex.guid)
Building or reading textures directly
renderer.texture.create also builds a runtime GPU texture from raw pixels ({ rgba, width, height }) or from a .texture AssetRef's loaded CPU pixels; textureRef:load() reads a .texture asset's pixels on the CPU. renderer.destroy(handle) frees any of them.
Finding the rest
asset.inspect("@builtin::components.Camera") documents the Camera's render-to-texture surface (textureHandle, setTargetTexture, render, capture); lsp.methods("renderer") lists the renderer.texture API; the ui guide covers the viewport widget. The model to hold: a camera renders into a GPU texture, and that texture goes anywhere a texture goes — UI or materials. There is no separate "render target" concept; it's the same texture, just filled by a camera instead of an upload.