Resources, targets and drawBuffers
A texture is a resource that can store data. Writing a draw's output into it also requires a drawing target and a mapping between shader outputs and target attachments.
Resource declarations describe storage
A resource ID refers to the same object throughout configuration. Format, size and lifetime determine how that object is created and managed. The current public resource kinds are texture2D, textureCube and buffer.
The following resource object fragment illustrates field relationships. It is not a complete shader pack:
{
"id": "example:scene/color",
"kind": "texture2D",
"lifetime": "persistent",
"size": { "mode": "viewport" },
"format": "rgba8"
}This declares a persistent color resource that follows the viewport size. It does not identify a writer or establish a sampling input for any Program.
Source: Resources and reconstructable examples in the v5 author guide · f8aaa5c4
Separate the four layers
| Layer | Question it answers |
|---|---|
| Resource | Which object stores the data? |
| Target / attachment topology | Which color or depth attachments belong to this draw target? |
GLSL output location | At which output location does the fragment shader write data? |
drawBuffers | Which color output mappings are active for this call? |
Attachment layout and active draw buffers are separate layers. A target with several color attachments does not require every draw to write all of them. Selecting an active output does not create a missing resource or attachment.
A depth attachment has a separate role in depth testing and related depth operations. It cannot be used directly as an ordinary color output location.
Multiple color outputs: MRT
MRT allows a draw to produce multiple color results. A pack might write final color, encoded normals and material information to separate color attachments.
Normal and material encodings are the pack's own conventions: consumers must decode what producers encode. These illustrations do not establish a fixed G-buffer format supplied by the host.
After declaring multiple layout(location = ...) out variables in GLSL, check the configured target layout, active drawBuffers, formats and actual driver capabilities. Being able to write those variables in source completes only part of the work.
Source: Scene ABI and MRT examples in the v3/v4 guide · f8aaa5c4
Connect writes and sampling separately
When post-processing reads the previous step's color, trace this path:
Producing command → named resource → later command's input binding → samplerThe target determines writes; a binding connects a resource to a shader input. Giving a resource a name similar to a uniform does not establish that sampling relationship.
Also check that resource dimensions are correct, whether data must be retained, whether the producer is enabled by the current options and whether the call has any read/write hazards.
Troubleshooting order
If the screen is black or an attachment lacks its expected contents, check:
- The resource exists and its format suits the intended use.
- A command in the active graph writes that resource.
- Target attachments match output locations, and
drawBuffersenables the intended outputs. - The consumer binds the same resource with the correct view / history.
- Actual driver evidence is available for GLSL, framebuffer and device results.
Use Analyzer to locate configuration and offline interface problems, then validate on the actual graphics driver.