Optional ReadonlycolorThe colour space the attachment's texels are in — §60a's "render targets carry color-space metadata" (R-15, 2026-08-08).
Defaults to "linear": everything this engine renders is linear-light
working-space content (§60a), so an off-screen target is by default an
intermediate surface in that pipeline rather than a presentable image. Tag
a target "srgb" when it is the destination of the output transform —
the surface §60a's final render-graph pass encodes into — so that
validateEffectRenderPass can tell an encode into an already-encoded
surface (a double encode) from an encode into a linear one.
Metadata, not behaviour: this tier's only colour format is rgba8 and the
bytes are whatever was written into them. What the tag changes is what the
graph accepts, which is where a colour-space mistake is catchable at
setup (§85) instead of visible as a washed-out frame.
Optional ReadonlydepthWhether the target carries a depth buffer. Defaults to true.
The default is true rather than false because the shared
Renderer.render contract clears depth for every view "whenever the
backend has a depth buffer", and the on-screen surface always has one: a
target that silently had none would make the same scene draw differently
off-screen — 3D geometry composited in submission order instead of by
depth — which is the class of difference a render-to-texture pass exists to
avoid. Pass false for a pass that is provably flat (a full-screen
composite, a 2D UI layer) and save the allocation.
The depth buffer is a renderbuffer unless RenderTargetOptions.depthTexture asks for the samplable form.
Optional ReadonlydepthWhether the depth attachment is a texture rather than a renderbuffer —
i.e. whether a later pass can sample the depth this pass wrote (§69;
R-18, 2026-08-09). Defaults to false.
const shadowMap = new RenderTarget({
width: 1024,
height: 1024,
depthTexture: true,
});
This is R-4's staged residue and §69's precondition: a shadow map is a depth attachment that something reads back, and a renderbuffer is by definition the attachment nothing reads. The two are the same surface to the pass writing it and different objects to the driver, which is why the choice is fixed at construction rather than discovered.
Requires RenderTargetOptions.depth; { depth: false, depthTexture: true } is refused (§85) rather than quietly promoted, because the two
options would be saying opposite things and guessing which one the author
meant is exactly the silent rewrite this engine does not do.
The backend allocates DEPTH_COMPONENT24 for a depth texture and
DEPTH_COMPONENT16 for a renderbuffer — the depth comparison a shadow
map performs is the one place in this engine where 16 bits shows as
banding, and 24-bit depth textures are required by WebGL 2 rather than
optional. That is a per-texel byte difference, which
RenderTarget.byteLength reports.
Sampling it from a material is not part of this tier — see the module
header for what that would additionally need. Within @fourjs/render-webgl
the attachment is reached through the backend's own render-target record,
which is how the shadow pipeline binds it.
Optional ReadonlyformatColour format of the attachment. Defaults to "rgba8", which is also the
only value this tier accepts — see RenderTargetFormat.
ReadonlyheightHeight in texels. A finite integer ≥ 1 (§85).
Optional ReadonlystencilWhether the target carries a stencil buffer (§67; R-7, 2026-08-11).
Defaults to false.
const masked = new RenderTarget({ width: 512, height: 512, stencil: true });
This is the off-screen counterpart of RendererOptions.stencil, and the
two exist for the same reason: §57's Material.stencil describes a test,
and a test needs a buffer to read. Off by default because a stencil buffer
is memory the target carries for its lifetime and an extra clear every view
issues.
Two constraints, both refusals rather than quiet promotions (§85):
depth, for depthTexture's reason and one more of its
own: the backend allocates the packed DEPTH24_STENCIL8 renderbuffer
WebGL 2 guarantees is framebuffer-complete, so the stencil arrives
attached to the depth buffer;depthTexture. That packed
attachment is a renderbuffer, and R-18's samplable depth attachment is a
DEPTH_COMPONENT24 texture; a surface has one depth attachment, so a
target cannot be both a shadow map and a masked surface. Asking for both
is refused where the mistake is, rather than resolved by a precedence
rule nobody would remember.The depth attachment's cost changes with it — 24-plus-8 bits occupy four bytes per texel where the plain renderbuffer occupies two — which RenderTarget.byteLength reports.
ReadonlywidthWidth in texels. A finite integer ≥ 1 (§85).
What a RenderTarget is asked for (§61's
RenderTargetOptions).