diff options
| author | skal <pascal.massimino@gmail.com> | 2026-02-15 18:52:48 +0100 |
|---|---|---|
| committer | skal <pascal.massimino@gmail.com> | 2026-02-15 18:52:48 +0100 |
| commit | d4b67e2f6ab48ab9ec658140be4f1999f604559a (patch) | |
| tree | 2502b0dc89748f7cfe674d3c177bd1528ce1c231 /workspaces/main/shaders/cnn/cnn_layer.wgsl | |
| parent | 161a59fa50bb92e3664c389fa03b95aefe349b3f (diff) | |
archive(cnn): move CNN v1 to cnn_v1/ subdirectory
Consolidate CNN v1 (CNNEffect) into dedicated directory:
- C++ effect: src/effects → cnn_v1/src/
- Shaders: workspaces/main/shaders/cnn → cnn_v1/shaders/
- Training: training/train_cnn.py → cnn_v1/training/
- Docs: doc/CNN*.md → cnn_v1/docs/
Updated all references:
- CMake source list
- C++ includes (relative paths: ../../cnn_v1/src/)
- Asset paths (../../cnn_v1/shaders/)
- Documentation cross-references
CNN v1 remains active in timeline. For new work, use CNN v2 with
enhanced features (7D static, storage buffer, sigmoid activation).
Tests: 34/34 passing (100%)
Diffstat (limited to 'workspaces/main/shaders/cnn/cnn_layer.wgsl')
| -rw-r--r-- | workspaces/main/shaders/cnn/cnn_layer.wgsl | 55 |
1 files changed, 0 insertions, 55 deletions
diff --git a/workspaces/main/shaders/cnn/cnn_layer.wgsl b/workspaces/main/shaders/cnn/cnn_layer.wgsl deleted file mode 100644 index cbd1686..0000000 --- a/workspaces/main/shaders/cnn/cnn_layer.wgsl +++ /dev/null @@ -1,55 +0,0 @@ -// CNN layer shader - uses modular convolution snippets -// Supports multi-pass rendering with residual connections -// DO NOT EDIT - Generated by train_cnn.py - -@group(0) @binding(0) var smplr: sampler; -@group(0) @binding(1) var txt: texture_2d<f32>; - -#include "common_uniforms" -#include "cnn_activation" -#include "cnn_conv3x3" -#include "cnn_conv5x5" -#include "cnn_weights_generated" - -struct CNNLayerParams { - layer_index: i32, - blend_amount: f32, - _pad: vec2<f32>, -}; - -@group(0) @binding(2) var<uniform> uniforms: CommonUniforms; -@group(0) @binding(3) var<uniform> params: CNNLayerParams; -@group(0) @binding(4) var original_input: texture_2d<f32>; - -@vertex fn vs_main(@builtin(vertex_index) i: u32) -> @builtin(position) vec4<f32> { - var pos = array<vec2<f32>, 3>( - vec2<f32>(-1.0, -1.0), vec2<f32>(3.0, -1.0), vec2<f32>(-1.0, 3.0) - ); - return vec4<f32>(pos[i], 0.0, 1.0); -} - -@fragment fn fs_main(@builtin(position) p: vec4<f32>) -> @location(0) vec4<f32> { - // Match PyTorch linspace - let uv = (p.xy - 0.5) / (uniforms.resolution - 1.0); - let original_raw = textureSample(original_input, smplr, uv); - let original = (original_raw - 0.5) * 2.0; // Normalize to [-1,1] - let gray = (dot(original_raw.rgb, vec3<f32>(0.2126, 0.7152, 0.0722)) - 0.5) * 2.0; - var result = vec4<f32>(0.0); - - // Layer 0: 7→4 (RGBD output, normalizes [0,1] input) - if (params.layer_index == 0) { - result = cnn_conv5x5_7to4_src(txt, smplr, uv, uniforms.resolution, weights_layer0); - result = cnn_tanh(result); - } - else if (params.layer_index == 1) { - result = cnn_conv3x3_7to4(txt, smplr, uv, uniforms.resolution, gray, weights_layer1); - result = cnn_tanh(result); // Keep in [-1,1] - } - else if (params.layer_index == 2) { - let sum = cnn_conv3x3_7to1(txt, smplr, uv, uniforms.resolution, gray, weights_layer2); - let gray_out = 1.0 / (1.0 + exp(-sum)); // Sigmoid activation - result = vec4<f32>(gray_out, gray_out, gray_out, 1.0); - return mix(original_raw, result, params.blend_amount); // [0,1] - } - return result; // [-1,1] -} |
