summaryrefslogtreecommitdiff
path: root/workspaces/main/shaders/cnn/cnn_conv5x5.wgsl
diff options
context:
space:
mode:
Diffstat (limited to 'workspaces/main/shaders/cnn/cnn_conv5x5.wgsl')
-rw-r--r--workspaces/main/shaders/cnn/cnn_conv5x5.wgsl16
1 files changed, 8 insertions, 8 deletions
diff --git a/workspaces/main/shaders/cnn/cnn_conv5x5.wgsl b/workspaces/main/shaders/cnn/cnn_conv5x5.wgsl
index 15eaf96..bfb4ebb 100644
--- a/workspaces/main/shaders/cnn/cnn_conv5x5.wgsl
+++ b/workspaces/main/shaders/cnn/cnn_conv5x5.wgsl
@@ -53,6 +53,8 @@ fn cnn_conv5x5_with_coord(
}
// 5×5 variant for 7→4 channels (RGBD output)
+// Assumes 'tex' and 'original' are already normalized to [-1,1]
+// UV coordinates remain in [0,1] and are normalized internally
// weights: array<array<f32, 8>, 100> (25 positions × 4 channels, each with 7 weights + bias)
fn cnn_conv5x5_7to4(
tex: texture_2d<f32>,
@@ -64,8 +66,7 @@ fn cnn_conv5x5_7to4(
) -> vec4<f32> {
let step = 1.0 / resolution;
- let gray_01 = 0.2126*original.r + 0.7152*original.g + 0.0722*original.b;
- let gray = (gray_01 - 0.5) * 2.0;
+ let gray = 0.2126*original.r + 0.7152*original.g + 0.0722*original.b;
let uv_norm = (uv - 0.5) * 2.0;
var sum = vec4<f32>(0.0);
@@ -74,8 +75,7 @@ fn cnn_conv5x5_7to4(
for (var dy = -2; dy <= 2; dy++) {
for (var dx = -2; dx <= 2; dx++) {
let offset = vec2<f32>(f32(dx), f32(dy)) * step;
- let rgbd_01 = textureSample(tex, samp, uv + offset);
- let rgbd = (rgbd_01 - 0.5) * 2.0;
+ let rgbd = textureSample(tex, samp, uv + offset); // Already in [-1,1]
let inputs = array<f32, 7>(
rgbd.r, rgbd.g, rgbd.b, rgbd.a,
@@ -98,6 +98,8 @@ fn cnn_conv5x5_7to4(
}
// 5×5 variant for 7→1 channel (scalar output)
+// Assumes 'tex' and 'original' are already normalized to [-1,1]
+// UV coordinates remain in [0,1] and are normalized internally
// weights: array<array<f32, 8>, 25> (25 positions, each with 7 weights + bias)
fn cnn_conv5x5_7to1(
tex: texture_2d<f32>,
@@ -109,8 +111,7 @@ fn cnn_conv5x5_7to1(
) -> f32 {
let step = 1.0 / resolution;
- let gray_01 = 0.2126*original.r + 0.7152*original.g + 0.0722*original.b;
- let gray = (gray_01 - 0.5) * 2.0;
+ let gray = 0.2126*original.r + 0.7152*original.g + 0.0722*original.b;
let uv_norm = (uv - 0.5) * 2.0;
var sum = 0.0;
@@ -119,8 +120,7 @@ fn cnn_conv5x5_7to1(
for (var dy = -2; dy <= 2; dy++) {
for (var dx = -2; dx <= 2; dx++) {
let offset = vec2<f32>(f32(dx), f32(dy)) * step;
- let rgbd_01 = textureSample(tex, samp, uv + offset);
- let rgbd = (rgbd_01 - 0.5) * 2.0;
+ let rgbd = textureSample(tex, samp, uv + offset); // Already in [-1,1]
sum += weights[pos][0] * rgbd.r;
sum += weights[pos][1] * rgbd.g;