diff options
Diffstat (limited to 'workspaces/main/shaders')
| -rw-r--r-- | workspaces/main/shaders/cnn/cnn_conv3x3.wgsl | 2 | ||||
| -rw-r--r-- | workspaces/main/shaders/cnn/cnn_conv5x5.wgsl | 56 |
2 files changed, 2 insertions, 56 deletions
diff --git a/workspaces/main/shaders/cnn/cnn_conv3x3.wgsl b/workspaces/main/shaders/cnn/cnn_conv3x3.wgsl index ebb87b5..96ddf5b 100644 --- a/workspaces/main/shaders/cnn/cnn_conv3x3.wgsl +++ b/workspaces/main/shaders/cnn/cnn_conv3x3.wgsl @@ -144,5 +144,5 @@ fn cnn_conv3x3_7to1( } } - return sum; // Output in [-1,1], needs denormalization + return sum; // Output in [-1,1] } diff --git a/workspaces/main/shaders/cnn/cnn_conv5x5.wgsl b/workspaces/main/shaders/cnn/cnn_conv5x5.wgsl index bfb4ebb..5136740 100644 --- a/workspaces/main/shaders/cnn/cnn_conv5x5.wgsl +++ b/workspaces/main/shaders/cnn/cnn_conv5x5.wgsl @@ -1,57 +1,3 @@ -// 5x5 convolution with 25 samples -// Applies mat4 weights per sample - -fn cnn_conv5x5( - tex: texture_2d<f32>, - samp: sampler, - uv: vec2<f32>, - resolution: vec2<f32>, - weights: array<mat4x4<f32>, 25>, - bias: vec4<f32> -) -> vec4<f32> { - let step = 1.0 / resolution; - var sum = bias; - var idx = 0; - - for (var dy = -2; dy <= 2; dy++) { - for (var dx = -2; dx <= 2; dx++) { - let offset = vec2<f32>(f32(dx), f32(dy)) * step; - let sample = textureSample(tex, samp, uv + offset); - sum += weights[idx] * sample; - idx++; - } - } - - return sum; -} - -fn cnn_conv5x5_with_coord( - tex: texture_2d<f32>, - samp: sampler, - uv: vec2<f32>, - resolution: vec2<f32>, - rgba_weights: array<mat4x4<f32>, 25>, - coord_weights: mat2x4<f32>, - bias: vec4<f32> -) -> vec4<f32> { - let step = 1.0 / resolution; - var sum = bias; - - sum += coord_weights * uv; - - var idx = 0; - for (var dy = -2; dy <= 2; dy++) { - for (var dx = -2; dx <= 2; dx++) { - let offset = vec2<f32>(f32(dx), f32(dy)) * step; - let rgba = textureSample(tex, samp, uv + offset); - sum += rgba_weights[idx] * rgba; - idx++; - } - } - - return sum; -} - // 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 @@ -135,5 +81,5 @@ fn cnn_conv5x5_7to1( } } - return sum; + return sum; // Output in [-1,1] } |
