Debug camera views
Debug camera views: capture pass=<name>
A debug camera view is a diagnostic render that content publishes and a capture selects by name. capture(pass = "lightmap") draws the scene the way that view defines instead of the final lit image, so you read a value straight off each surface. The built-in debug passes (normal, depth, albedo, ...) are engine-owned; a content view is one you register yourself, and it draws through the same render-feature machinery (topics/rendering-render-features).
A view is a render feature gated to a debug channel. A live viewport camera carries channel 0, so a view's pass is invisible on screen and runs only when a capture selects it. An always-registered view therefore costs nothing: its pass is skipped every frame until someone captures it.
Register the name, and give it a feature whose pass carries the view's channel:
local VIEW = "lightmap"
-- Register the name so `capture pass=lightmap` resolves. `ensure` runs when the
-- view is first selected, so the drawing feature is created on demand.
renderer.captureView.register(VIEW, {
description = "Each surface's sampled baked irradiance.",
ensure = ensureFeature,
})
-- The feature draws the opaque scene with a material that emits the value you
-- want to read, gated to this view's channel so it runs only for a capture that
-- selected the view.
return {
render = function(ctx)
ctx.enqueue {
kind = "geometry",
material = viewMaterial, -- a surface material emitting the value
geometry = "@geometry.opaque",
phase = "afterLighting",
debugChannel = renderer.captureView.channelId(VIEW),
}
end,
}
The material is an ordinary surface material (the shaders guide): its fragment() returns the number you want to see rather than a lit colour. Because the pass is gated to a content-view channel, the engine passes that fragment output straight through instead of substituting a built-in debug colour.
Several views ship this way, and renderer.captureView.list() enumerates whatever is registered — each with a description of what it draws.
capture(pass = "lightmap") shows each surface's sampled baked irradiance, so "did the bake reach this surface" becomes a question you answer by looking instead of by reasoning.
A pass that is part of the film
A Camera's postProcessing says whether that camera runs the post-process
chain. Some render features draw what the chain draws — the camera's
photographic finish rather than the scene: the lens flare lensFx
composites, the bokeh depthOfField gathers, the shutter smear
motionBlur sweeps. A pass declares that, and
the camera property answers for it too:
ctx.enqueue {
kind = "fragment", inputs = { src = outRt.guid },
phase = "afterLighting", order = 406,
postProcessing = true, -- part of the camera's photographic finish
}
A camera whose postProcessing is off runs neither the chain nor that pass, so
capture { postProcessing = false } hands back the scene with the whole finish
off it — which is what makes an ungraded frame comparable against a graded one,
and what keeps one session's half-tuned lens out of another session's evidence.
A camera keeping its chain draws the pass, and every viewport keeps its chain by
default.
Declare it for what the CAMERA does to the picture. A feature drawing the scene
itself — ambient occlusion, reflections, global illumination, the atmosphere
between the camera and a surface — leaves it out, so an ungraded frame is still
the scene as it is lit. (clearAir is the option that reaches the air; the
render-textures guide covers it.)
A pass that measures the presented picture
Some passes measure the picture a person is shown rather than drawing into it:
the exposure meter reads the scene's light once a frame and the exposure it
arrives at is what every camera applies, graded or not. A pass declaring
presented runs on the presented frame alone, whatever that camera's
postProcessing, and on no offscreen render (a capture, a render-to-texture
camera, an environment face):
ctx.enqueue {
kind = "compute", program = meterProgram,
inputs = { scene_color = "@scene.color" },
storage = { meter_out = tilesRt.guid },
order = 0,
presented = true, -- measures the view a person looks at
}
So the exposure meter reads the editor's ungraded camera in edit mode the way it reads the game's camera in play, and a capture or a camera drawing into a texture applies the exposure measured from the presented view instead of stepping the adaptation with a reading of its own.
Such a pass writes render targets of its own. Every view reads the frame's
@scene.* channels as the answer drawn for it, so a presented pass writing
one (through output, an outputs entry or a storage slot) is refused when
it is enqueued, naming where it writes.
A pass that is part of the air
A Camera's environment = "isolated" says that camera is lit and seen by
nothing the scene holds: not its sky, not its sun, and not the air between the
camera and a surface. A render feature drawing that air (height fog, aerial
perspective, the light a medium scatters toward the viewer) or a layer of the
scene's sky (a volumetric cloud layer) declares it on
every pass it enqueues for it, the passes marching the medium as well as the one
compositing it:
ctx.enqueue {
kind = "fragment", inputs = { src = fogRt.guid },
phase = "afterLighting", order = 110,
atmospherics = true, -- part of the scene's air
}
A camera stating an isolated environment skips those passes, so an asset preview, an item icon or a portrait reads the same in a fogged world as in a clear one; every camera drawing the scene runs them. Declare it for what the SCENE's air does to the picture. A feature drawing something a camera photographs, such as an outline, a gameplay overlay or a placed volume, leaves it out.
A pass that adds the scene's light
The light a scene holds reaches an isolated camera through no pass either. A render feature that adds that light to the picture (the light the scene's sky sends its surfaces, an image-based environment, a global illumination field, a radiance cache gathered from the views that draw the scene, the area lights and light sources a scene registers with a feature of its own) declares it on the passes that add it:
ctx.enqueue {
kind = "fragment", inputs = { src = skyLightRt.guid },
outputs = { { target = "@scene.color", blend = "additive" } },
phase = "afterLighting", order = 28,
sceneLight = true, -- light the scene holds
}
A camera stating an isolated environment skips those passes, so it is lit by its own layers' lights and the ambient it states alone, and a scene whose every light is off reads black through it. Declare it for light that comes from the SCENE. A feature lighting what one camera photographs with light of its own leaves it out.
capture(pass = "overdraw") shows how many fragments each pixel cost, counting every fragment the rasterizer produced including the ones the depth test later discards. Flat bands, so the count is read by naming a colour: black none, blue 1, cyan 2, green 3, yellow 4, orange 5-6, red 7-9, white 10+.
capture(pass = "zfighting") shows where two opaque surfaces own the same depth — dark grey for one surface, red for two, white for three or more. It is the view for a defect that has no still to look at: the depth buffer cannot separate coplanar surfaces, so which one wins flips per frame, and a capture shows whichever won, correctly shaded. The count comes from re-running the depth test the frame already resolved (lessEqual, writing no depth) over a band as deep as the frame's own depth rounding, with each surface at the depth bias its material states, so a pixel more than one surface reaches is a pixel that will shimmer in motion. Two surfaces a few millimetres apart at room scale, and an overlay its material lifts by a depthBias of -64 or more with a depthBiasSlope of -1 or more, read as one surface; a single red pixel where two surfaces cross is the crossing itself. Take it over a scene before calling the scene done.
capture(pass = "physics") shows the physics world as solid shaded colliders on black, coloured by what each one takes part in: blue static, orange dynamic, green kinematic, magenta and translucent for a sensor, with lightness separating the individual objects inside a family. The simulation collides with colliders rather than with what is drawn, and a collider that disagrees with its mesh is invisible in every other pass — so this is the view for something that behaves wrongly rather than looks wrongly. capture(pass = "physics_context") draws the same colliders over the scene's meshes in dim grey, which answers whether a collider sits where its model does.
Both are built on @builtin::systems.renderDiagnostics.countingView, which is the generic shape: count the fragments satisfying a depth predicate at each pixel, then colour the count. A diagnostic of your own is that call with a different predicate and a different zero_count_color.
A counting view fills, counts and reads back in three passes at afterLighting, and their order matters in a way worth knowing for any feature: afterLighting runs every geometry pass before any of its fragment passes, ordered by order within each kind. That is what lets a fragment pass sample what a geometry pass drew the same frame — and why a full-screen fill meant to go under a geometry pass has to be a geometry pass too. afterLighting and afterOpaqueLit (which runs its own geometry, draw and splat passes the same way, into the lit opaque scene ahead of the transparent phase) are the phases that draw geometry, draw and splat passes at all: one of those enqueued at another phase never runs.
What a pass reads, and when it exists
A pass declares what it reads (inputs) and what it writes (output /
outputs / storage), and the frame runs the declarations in that order. So a
pass whose input is a render target the same frame produces later samples the
target as the frame found it — the previous frame's contents for a target that
persists, an empty target for one just created — and renders anyway, at full
cost, over data nobody put there this frame.
renderer.passSchedule() reads the frame's declarations back and names those
reads:
for _, v in renderer.passSchedule().violations do
print(v.message)
end
-- pass 'blur_h' at afterLighting/order 40 reads render target
-- '4f2c…' on slot 'src', which is written by pass 'bright_pass' at
-- afterLighting/order 90 — later in the same frame …
Each finding also goes to the engine log the first time it appears, so a mis-ordered feature says so without anyone asking.
The frame's own buffers are read on the same terms. Bind @scene.motion,
@scene.color or any of their siblings on a pass that runs ahead of the one
writing that buffer and the read is reported the same way, naming the buffer —
what it samples there is the scene draw's own output rather than the previous
frame's, and the pass that was going to contribute to it has not run yet.
A history buffer, a temporal accumulation and the far half of a ping-pong all read a target one frame late on purpose. Declare the slot and the check leaves it alone:
ctx.enqueue {
kind = "compute", program = accumulate,
inputs = { history = historyRt.guid },
storage = { out = historyRt.guid },
readsPrevious = { "history" },
phase = "afterLighting", order = 200,
}
The declaration is per slot, so the pass's other inputs stay checked; a slot
named there that the pass binds no such resource to is reported in
unboundPrevious, since a renamed slot would otherwise quietly widen what the
declaration excuses. A resource no queued pass writes is never reported — a
camera rendering to texture and a compute dispatch both fill targets outside the
pass queue, and the scene draw fills the @scene.* buffers every frame.
The far half of a ping-pong needs the declaration for a second reason. A pass
sampling a render target that holds no picture, and that no pass wrote this
frame, is held back: it would read the target's cleared texels. A pair that
reads the half the frame before wrote, without naming that slot in
readsPrevious, holds itself back on its first frame, writes nothing, and so
never gives the half it reads a picture: neither pass runs again.
renderer.passSchedule().heldBack lists the passes the last drawn frame held
back, with the slot, the target, what became of its writer and how many drawn
frames in a row each has been held; one held 60 drawn frames in a row by a
writer that is not waiting on a pipeline is stated in the engine log, once.
A read the frame has only one order for is not reported either. Where the pass
that writes the resource consumes something the reading pass produces — a
compute pass reading @scene.motion into a target of its own, and a copy
reading that target back over @scene.motion — the reader runs first or the
writer has nothing to write. No reordering hands that reader the writer's
output, so the chain reads clean without a declaration.
The third list, unreachable, holds passes at a phase that does not run their
kind. Every phase drains its fragment and compute passes, while the geometry,
draw and splat drains are those of afterOpaqueLit and afterLighting alone — so a mask enqueued as a
geometry pass at afterOpaque sits in the queue and is never drawn, and
everything sampling it reads an empty target on every frame.
A pass reading a target its writer did not write this frame
A pass writing a render target can reach a frame and write nothing: its
compute program, effect or pipeline is still compiling (a look applied for the
first time, a material whose shader was just written), or something it binds is
unavailable at its seam (@scene.normal in the display stage). A pass reading
that target through an inputs slot outside readsPrevious then reads the
picture the last frame that wrote the target left in it, so a feature switching
its pass to a program still compiling keeps presenting its last picture until
the new one lands.
A target holds a picture once a writer has drawn into its texture: a pass
of the queue, a camera rendering to texture, a UI screen or panel rendered
into it, a video frame, or pixels of its own size and format uploaded under
its guid (renderer.texture.update). One no writer has drawn into since its
texture was allocated (a target just created, or resized to a size it has not
stood at) holds only its cleared texels, and no reader samples them:
- A pass reading it is held back for a frame in which its writer did not
write it, or in which no queued pass writes it at all: it records nothing,
the targets it writes count as unwritten for the passes after it, and when
its writer is waiting on a compile it waits with it, so both draw the frame
the compile lands. A chain held back this way ends at a scene channel, which
holds the frame's own picture whether or not a pass wrote it: the frame then
presents the scene as the stages before the feature drew it. A pass running
ahead of a queued pass of the same frame that writes the target (a history
the later pass fills) reads it as it stands, so the history starts from the
cleared texels. The
previousimage of a history target (renderer.texture.create { history = true }) holds the history on every render: what the view's previous render wrote, or transparent black where its state buffer says the history starts over, so a pass reading it always runs. - A material slot naming it, in the scene's own draw of an entity and in every
pass drawing with that material, draws the slot's declared default (the
default:of itsproperties.yamlentry), as a slot naming no texture does. From the frame after a writer first draws the target, the slot draws its picture.
A compute texture (compute.createTexture) holds what the dispatches that
wrote it left, and reads as it stands.
A texture made from its texels (renderer.texture.create { rgba = { 0, 0, 0, 0 }, width = 1, height = 1, srgb = false }) holds them from the moment it is made,
and reads as it stands. It is what a pass binds where a fixed value stands in
for an input the frame has no picture for: a one-texel zero in place of a table
no system of the scene builds, or of a G-buffer channel the render path does
not write.
A render target bound to a texture property with postprocess.setTexture is
read by the same rule. A fragment pass drawing with that effect is held back
like one reading the target through inputs. An effect running in the
post-process chain is left out of the chain for that frame, so the picture
passes it by as it would a disabled effect, and it draws again on the first
frame its target holds a picture. Each layer's effects are judged once the
passes that run ahead of that layer have run: a display effect after the
afterScenePost passes, an all effect after the afterUI passes. A feature
that binds a target on one render and enqueues the pass writing it from the
next has its effect left out of the chain until that pass has drawn the
target.
A pass that waits on its mask being drawn
A chain that reads a mask a geometry pass draws (a silhouette, a selection)
has nothing to do in a view where the mask's selection draws nothing: an
outlined entity holding no mesh, or one on a layer the camera leaves out. Each
pass of the chain names the mask in whenDrawn, and runs only in a view where
the geometry or draw pass writing that target as its output drew at least one
object into it this frame:
ctx.enqueue {
kind = "geometry", material = maskMat.guid, select = ids,
output = mask.guid, phase = "afterLighting", order = 0,
}
ctx.enqueue {
kind = "fragment", shader = "my_seed", inputs = { src = mask.guid },
output = seed.guid, whenDrawn = mask.guid,
phase = "afterLighting", order = 10,
}
Once every queued pass reading the mask states it, the geometry pass itself records nothing in such a view either, and builds no depth or motion target to draw with there.
A screen-sized target (renderer.texture.create { screen = true }) that every
queued pass names only as a mask's geometry pass or as a pass waiting on a
mask (the mask itself, and each target the chain writes and reads), where each
such mask is drawn only by geometry passes and read only by passes waiting on
it, holds memory only while a view draws one of those masks. Several chains
can share such a target (one flood field every group floods through); it then
hangs on each of their masks. Once no view has drawn any of them for sixty
frames the renderer gives the target's texture back, and the next view that
draws one makes it again at the size that view stands at, so a chain over
entities that draw nothing (an editor hint on an entity with no mesh) costs no
memory. A target given back stays given back while no pass names it, and
comes back once a pass names it some other way. The handle stays yours
throughout: renderer.texture.isResident and the resident field of
renderer.texture.list() read false while it holds no texture, and a
renderer.texture.readback of it is refused, naming why. A target any pass
reads without waiting on such a mask keeps its texture, and so does one a pass
binds as storage or reads as the previous frame's contents (readsPrevious),
since what it carries from frame to frame is the point of it.
A target only a fragment or compute pass fills records nothing drawn, so a wait
on it is never met: renderer.passSchedule().unmetWhenDrawn names every pass
whose whenDrawn target no geometry or draw pass writes ahead of it.
A pass written for the passes that read what it writes
Some passes exist only to hand a later pass something: a compute pass that
keeps a channel steady over several frames, and the restatement copying what
it kept back over the scene's own channel. On a frame where nothing after
them reads that channel they cost their whole target for no reader. Each such
pass names, in whenRead, the @scene.* channels and render targets it is
written for, and the frame leaves it out wherever no pass reads what it leaves
in one of them:
local readers = { "@scene.normal", "@scene.material" }
ctx.enqueue {
kind = "compute", program = keepProgram.guid,
inputs = { scene_normal = "@scene.normal", history = kept.previous.guid },
storage = { kept_out = kept.guid }, readsPrevious = { "scene_normal" },
whenRead = readers, phase = "afterLighting", order = 601,
}
ctx.enqueue {
kind = "fragment", inputs = { src = kept.guid },
outputs = { { target = "@scene.normal", blend = "replace" } }, restates = true,
whenRead = readers, phase = "afterLighting", order = 601,
}
A reader is a pass binding the channel or target as an input or as a storage
texture at a later phase, at a later order inside the phase, or at the same
order enqueued later. A pass ahead of it reads what an earlier frame left
there: a render target through any input or storage binding, since a target
keeps its contents from frame to frame, and a channel through an input named
in its readsPrevious or a storage binding, since a G-buffer read ahead of
the shading holds the previous frame's surfaces (a screen-space reflection
trace at afterDepthPrepass is one). The scene depth is laid again by every
render ahead of its first phase, so a pass ahead of one naming @scene.depth
reads this render's own depth, and only a reader after it keeps that pass.
After it, the scene depth has readers beyond those bindings, and each of them
keeps a pass naming @scene.depth: a fragment pass whose effect samples
scene_depth, a raster pass testing
against the scene's depth, a geometry or draw pass drawing into the scene's
own target or with a material including zero::scene_depth, and, after every
pass, an effect of the post-process chain sampling the depth, a dispatch
binding its copy, or a temporal upscaler. The two passes above read only each
other, so they are left out together. A history target
that only passes the frame leaves out name is not carried through that frame,
so the first render that runs them again starts its history over: its state
buffer reads as holding no history. renderer.passSchedule().unread lists the
passes the last drawn frame left out, each with its whenRead.
Restating @scene.depth also restates the camera: the passes after it read
@frame.camera and the post framework's engine.view_proj with no sub-pixel
offset. A temporal reconstruction whose depth restatement is left out on a
frame still hands those passes the camera its picture samples through, with a
pass restating the camera alone, which draws nothing and reads no input:
ctx.enqueue { kind = "fragment", output = "@frame.camera", restates = true,
phase = "afterLighting", order = 601 }
The first pass of a phase restating the camera (alone, or with the depth)
divides the phase in two. afterLighting runs its geometry, draw and splat
passes ahead of its fragment, compute and raster passes, and it does so once
for the passes ordered at or before the restatement and once more for the
passes ordered after it. A pass ordered after the restatement so runs after
it: a geometry pass of the postTemporal stage or a later one drawing into a
target of its own (output, a mask a fragment pass then samples) rasterizes
through the camera with no sub-pixel offset, so its mask holds still under a
still camera, as the picture it is laid over does. A geometry or draw pass
naming no output draws into the scene's own picture, depth-tested against
the depth the raster left: it runs in the first part wherever it is ordered,
at the raster's sub-pixel offset, and the reconstruction resolves it with the
rest of the scene. The built-in temporal antialiasing lays its resolved
picture at afterLighting 601 and restates at 602, so every pass after the
restatement reads that picture.
A pass that shades only what its mask's objects cover
A fragment pass draws one triangle over its target, so a chain over a mask
shades the whole view however small the objects in the mask are. A pass that
states whenDrawn can also state drawnMargin: it then shades only the screen
rectangle the objects drawn into that target cover for the camera being drawn,
grown by drawnMargin pixels of the pass's own output on each side.
ctx.enqueue {
kind = "fragment", shader = "my_seed", inputs = { src = mask.guid },
output = seed.guid, whenDrawn = mask.guid, drawnMargin = 12,
phase = "afterLighting", order = 10,
}
A pixel outside the rectangle is not shaded. A pass replacing a render target
through output leaves those pixels cleared, and every other write (a blend, a
replace of the frame's own picture, an outputs entry) leaves them as the
target stood. Size each margin to what the effect reaches. A pass that reads
its input s pixels away from the pixel it shades is exact only s pixels
further inside its rectangle than the pass it reads, so in a chain written over
one rectangle the last pass is exact inside it to the depth of the steps
summed: the margin is what the last pass reaches plus that depth. Within those
margins the chain draws the image the unconfined chain draws, and
renderer.feature.shaded() reads the area it shades. A drawn object whose
bounds do not describe what it rasterizes (a skinned mesh, one with no bounds,
one crossing the camera plane) widens the rectangle to the whole target.