summaryrefslogtreecommitdiff
path: root/cnn_v3/shaders/gbuf_view.wgsl
diff options
context:
space:
mode:
authorskal <pascal.massimino@gmail.com>2026-03-23 00:26:52 +0100
committerskal <pascal.massimino@gmail.com>2026-03-23 00:26:52 +0100
commit1470dd240f48652d1fe97957fe44a49b0e1ee9a6 (patch)
treec202e36a2aaed35fd8bc111457bcba89c7db8658 /cnn_v3/shaders/gbuf_view.wgsl
parent12d5d5f1762a0c00405950b6ff5e564880f0ff36 (diff)
wip(cnn_v3): shadow→dif intermediate + scene tweaks + migration plan
- gbuf_shadow.wgsl: normal bias 0.05→0.02 - gbuf_pack.wgsl: compute dif=diffuse*shadow, drop shadow from t1.z, store dif in t1.w (INTERMEDIATE — incorrect packing, see migration plan) - gbuf_deferred.wgsl: read dif from t1.w.x (matches intermediate packing) - gbuf_view.wgsl: expand to 4×6 grid, show dif.r/g/b in row 5 (INTERMEDIATE — to be reverted to 4×5 with ch18=dif) - gbuffer_effect.cc: add small hovering sphere (r=0.6) above scene; swap cube/sphere positions; both spheres pulsate - docs/GBUF_DIF_MIGRATION.md: full migration plan with checklist handoff(Claude): intermediate commit — GBUF_DIF_MIGRATION.md §Current State describes what is wrong and the full implementation checklist (5 steps).
Diffstat (limited to 'cnn_v3/shaders/gbuf_view.wgsl')
-rw-r--r--cnn_v3/shaders/gbuf_view.wgsl20
1 files changed, 12 insertions, 8 deletions
diff --git a/cnn_v3/shaders/gbuf_view.wgsl b/cnn_v3/shaders/gbuf_view.wgsl
index 3e7d1ff..d53b6f6 100644
--- a/cnn_v3/shaders/gbuf_view.wgsl
+++ b/cnn_v3/shaders/gbuf_view.wgsl
@@ -1,5 +1,5 @@
-// G-buffer channel visualization — 4×5 grid of 20 feature channels.
-// Takes feat_tex0 (rgba32uint, ch 0-7 f16) and feat_tex1 (rgba32uint, ch 8-19 unorm8).
+// G-buffer channel visualization — 4×6 grid of 23 feature channels.
+// Takes feat_tex0 (rgba32uint, ch 0-7 f16) and feat_tex1 (rgba32uint, ch 8-22 unorm8).
// Outputs tiled channel view to a standard rgba8unorm render target.
//
// Channel layout (row×col):
@@ -7,7 +7,8 @@
// Row 1: ch4(nrm.y) ch5(depth) ch6(dzdx) ch7(dzdy)
// Row 2: ch8(matid) ch9(prv.r) ch10(prv.g) ch11(prv.b)
// Row 3: ch12(m1.r) ch13(m1.g) ch14(m1.b) ch15(m2.r)
-// Row 4: ch16(m2.g) ch17(m2.b) ch18(shdw) ch19(trns)
+// Row 4: ch16(m2.g) ch17(m2.b) ch18(trns) ch19(spare)
+// Row 5: ch20(dif.r) ch21(dif.g) ch22(dif.b) ch23(spare)
#include "debug/debug_print"
@@ -29,12 +30,12 @@ fn fs_main(@builtin(position) pos: vec4f) -> @location(0) vec4f {
let uv = pos.xy / u.resolution;
let COLS = 4.0;
- let ROWS = 5.0;
+ let ROWS = 6.0;
let col = u32(uv.x * COLS);
let row = u32(uv.y * ROWS);
let ch = row * 4u + col;
- if (col >= 4u || ch >= 20u) {
+ if (col >= 4u || ch == 19u || ch >= 23u) {
return vec4f(0.05, 0.05, 0.05, 1.0);
}
@@ -71,7 +72,8 @@ fn fs_main(@builtin(position) pos: vec4f) -> @location(0) vec4f {
var bytes: vec4f;
if (comp_idx == 0u) { bytes = unpack4x8unorm(t.x); }
else if (comp_idx == 1u) { bytes = unpack4x8unorm(t.y); }
- else { bytes = unpack4x8unorm(t.z); }
+ else if (comp_idx == 2u) { bytes = unpack4x8unorm(t.z); }
+ else { bytes = unpack4x8unorm(t.w); }
var ba = array<f32, 4>(bytes.x, bytes.y, bytes.z, bytes.w);
v = ba[sub];
}
@@ -120,8 +122,10 @@ fn fs_main(@builtin(position) pos: vec4f) -> @location(0) vec4f {
case 15u: { out = debug_str(out, pos.xy, origin, vec4u(0x6D322E72u, 0u, 0u, 0u), 4u); } // m2.r
case 16u: { out = debug_str(out, pos.xy, origin, vec4u(0x6D322E67u, 0u, 0u, 0u), 4u); } // m2.g
case 17u: { out = debug_str(out, pos.xy, origin, vec4u(0x6D322E62u, 0u, 0u, 0u), 4u); } // m2.b
- case 18u: { out = debug_str(out, pos.xy, origin, vec4u(0x73686477u, 0u, 0u, 0u), 4u); } // shdw
- default: { out = debug_str(out, pos.xy, origin, vec4u(0x74726E73u, 0u, 0u, 0u), 4u); } // trns
+ case 18u: { out = debug_str(out, pos.xy, origin, vec4u(0x74726E73u, 0u, 0u, 0u), 4u); } // trns
+ case 20u: { out = debug_str(out, pos.xy, origin, vec4u(0x6469662Eu, 0x72000000u, 0u, 0u), 5u); } // dif.r
+ case 21u: { out = debug_str(out, pos.xy, origin, vec4u(0x6469662Eu, 0x67000000u, 0u, 0u), 5u); } // dif.g
+ default: { out = debug_str(out, pos.xy, origin, vec4u(0x6469662Eu, 0x62000000u, 0u, 0u), 5u); } // dif.b
}
return out;
}