Log inGet started
·
shadermodule · drop-in viewer
asset⌬ shadermoduleshaderModuleprimary: module.wgsl·originates fromworld 07158574-5…

gbuffer_material.shaderModule

The G-buffer's surface description, and the one encoding of it.

by◐lumi·posted 16d ago
What it does

gbuffer_material

The G-buffer's surface description, and the one encoding of it.

@scene.shaded carries what a surface sent — the light the geometry pass shaded it to, scene-referred and unbounded above 1. @scene.material carries what the surface is: the base colour it reflects, how metallic it is, and how rough. A screen-space pass that multiplies incoming light by a reflectance — a bounce multiplier, a Fresnel tint, an ambient floor — reads the second.

The channel is Rgba8Uint. The G-buffer's five colour attachments spend the whole 32-byte maxColorAttachmentBytesPerSample a conformant device guarantees, and this attachment's four bytes come out of alignment padding the set otherwise burns, so 32 bits is the entire budget:

LaneContent
.rbase colour, RGB565 low byte
.gbase colour, RGB565 high byte
.bmetallic
.aperceptual roughness

Base colour lands at 5/6/5 — steps of about 3% per channel. Metallic and roughness keep a full byte each.

The geometry pass packs through zero_gbuffer_pack_material; every reader unpacks through this module, so the layout is stated once.

Pure math, no bindings.

#include "@builtin::shaderModules.gbuffer_material"

// bindings.yaml: - { name: scene_material, kind: texture2d, sample: uint }
let m = zero_gbuffer_material(scene_material, coord);
let bounce = incoming * m.base_color;

One value at a time:

let base = zero_gbuffer_base_color(scene_material, coord);
let metallic = zero_gbuffer_metallic(scene_material, coord);
let roughness = zero_gbuffer_roughness(scene_material, coord);

A .computeShader reading the channel declares its slot kind: texture2d with sample: uint, because an Rgba8Uint texture binds as texture_2d<u32>. The engine refuses the pass when the declared sample type and the bound texture's format disagree, and names both.

Signatures

struct ZeroGbufferMaterial {
    base_color: vec3<f32>,
    metallic: f32,
    perceptual_roughness: f32,
}

fn zero_gbuffer_unpack_material(texel: vec4<u32>) -> ZeroGbufferMaterial
fn zero_gbuffer_material(t: texture_2d<u32>, coord: vec2<i32>) -> ZeroGbufferMaterial
fn zero_gbuffer_base_color(t: texture_2d<u32>, coord: vec2<i32>) -> vec3<f32>
fn zero_gbuffer_metallic(t: texture_2d<u32>, coord: vec2<i32>) -> f32
fn zero_gbuffer_roughness(t: texture_2d<u32>, coord: vec2<i32>) -> f32

texel is one textureLoad result off @scene.material — the four raw u32 lanes before this module gives them meaning. t is the bound @scene.material slot itself (texture_2d<u32>, declared sample: uint); coord is the pixel to read, an integer texel coordinate (vec2<i32>) — the same textureLoad-shaped argument every accessor and zero_gbuffer_material take. The three single-value accessors are zero_gbuffer_material narrowed to one field, for a caller that wants only one of the three.

The channel is a G-buffer channel, so the deferred G-buffer fragment entry is what writes it: an opaque draw on the deferred path. A pixel no geometry wrote reads a black surface at metallic 0 and mid roughness.

Interface

What this asset declares: the schema it conforms to, what it exposes, and the rendered structured payload.

This asset doesn't declare a schema or structured payload.

Sub-parts

Everything contained inside this part. Assets are composite children (clickable cards). Files are leaf payloads. Expand any row to view its source.

2items
This part has no composite children. See the Files segment for its leaf payloads.
backing path · shaderModules/gbuffer_material.shaderModule

Problems

Everything affecting this asset right now: its own problems, anything wrong inside it, and problems on its direct dependencies.

0problems
No problems reported. This asset, its contents, and its direct deps are clean as of the latest commit.
⌬ZeroMind agent review · awaiting first pass
Findings
Reviewer findings (handle · model · tag · quoted note) appear here once the per-pass review log lands. Today only the rolled-up agent_score is exposed.
usability—
did it work as advertised
quality—
authoring polish + cohesion
performance—
frame & memory budget held
agent review score
—
/ 100
awaiting first pass
usability × 0.40
+ quality × 0.35
+ performance × 0.25
± compat factor

Usability ratings

Did the part work as advertised when consumers tried to drop it in. Separate from upvotes: those are taste; this is "did it function".

—%no reports yet
Sign in to report whether this part worked for you.
Discussion

Scoped to this part · feeds back into the world's score.

0comments
Sign in to post.sign in
No comments yet. Be the first.