summaryrefslogtreecommitdiff
path: root/cnn_v3/shaders/gbuf_pack.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_pack.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_pack.wgsl')
-rw-r--r--cnn_v3/shaders/gbuf_pack.wgsl11
1 files changed, 7 insertions, 4 deletions
diff --git a/cnn_v3/shaders/gbuf_pack.wgsl b/cnn_v3/shaders/gbuf_pack.wgsl
index 333589c..dd8d73b 100644
--- a/cnn_v3/shaders/gbuf_pack.wgsl
+++ b/cnn_v3/shaders/gbuf_pack.wgsl
@@ -86,6 +86,9 @@ fn pack_features(@builtin(global_invocation_id) id: vec3u) {
let mat_id_u8 = nm.b; // mat_id already in [0,1]
let shadow = textureLoad(gbuf_shadow, coord, 0).r;
let transp = textureLoad(gbuf_transp, coord, 0).r;
+ let nor = oct_decode_unorm(nm.rg);
+ let diffuse = max(0.0, dot(nor, vec3f(0.408, 0.816, 0.408)));
+ let dif = diffuse * shadow;
let prev = textureSampleLevel(prev_cnn, bilinear_sampler, uv, 0.0).rgb;
// MIP 1: 2×2 box filter (half resolution context)
@@ -103,13 +106,13 @@ fn pack_features(@builtin(global_invocation_id) id: vec3u) {
// Texture 1: 4 u32, each = pack4x8unorm of four u8 values
// [0] mat_id | prev.r | prev.g | prev.b
// [1] mip1.r | mip1.g | mip1.b | mip2.r
- // [2] mip2.g | mip2.b | shadow | transp
- // [3] spare (0)
+ // [2] mip2.g | mip2.b | transp | (spare)
+ // [3] dif.r | dif.g | dif.b | (spare) — dif = diffuse*shadow (scalar, stored in all 3)
let t1 = vec4u(
pack4x8unorm(vec4f(mat_id_u8, prev.r, prev.g, prev.b)),
pack4x8unorm(vec4f(mip1.r, mip1.g, mip1.b, mip2.r)),
- pack4x8unorm(vec4f(mip2.g, mip2.b, shadow, transp)),
- 0u
+ pack4x8unorm(vec4f(mip2.g, mip2.b, transp, 0.0)),
+ pack4x8unorm(vec4f(dif, dif, dif, 0.0))
);
textureStore(feat_tex1, coord, t1);
}