summaryrefslogtreecommitdiff
path: root/cnn_v3/shaders/gbuf_pack.wgsl
diff options
context:
space:
mode:
Diffstat (limited to 'cnn_v3/shaders/gbuf_pack.wgsl')
-rw-r--r--cnn_v3/shaders/gbuf_pack.wgsl5
1 files changed, 3 insertions, 2 deletions
diff --git a/cnn_v3/shaders/gbuf_pack.wgsl b/cnn_v3/shaders/gbuf_pack.wgsl
index 777b4e5..5870938 100644
--- a/cnn_v3/shaders/gbuf_pack.wgsl
+++ b/cnn_v3/shaders/gbuf_pack.wgsl
@@ -60,8 +60,9 @@ fn pack_features(@builtin(global_invocation_id) id: vec3u) {
let depth_raw = load_depth(coord);
// Finite-difference depth gradient (central difference, clamped coords)
- let dzdx = (load_depth(coord + vec2i(1, 0)) - load_depth(coord - vec2i(1, 0))) * 0.5;
- let dzdy = (load_depth(coord + vec2i(0, 1)) - load_depth(coord - vec2i(0, 1))) * 0.5;
+ // tanh(10x) keeps typical gradients (±0.05–0.1) in [-1,1]; matches training normalization.
+ let dzdx = tanh((load_depth(coord + vec2i(1, 0)) - load_depth(coord - vec2i(1, 0))) * 5.0);
+ let dzdy = tanh((load_depth(coord + vec2i(0, 1)) - load_depth(coord - vec2i(0, 1))) * 5.0);
// Normal: stored as oct-encoded [0,1] in RG; extract just the encoded xy for feat_tex0
let normal_enc = nm.rg; // already in [0,1] — decode to get the xy for CNN input