diff options
Diffstat (limited to 'workspaces/main')
| -rw-r--r-- | workspaces/main/shaders/cnn_v2/cnn_v2_static.wgsl | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/workspaces/main/shaders/cnn_v2/cnn_v2_static.wgsl b/workspaces/main/shaders/cnn_v2/cnn_v2_static.wgsl index 7a9e6de..f71fad2 100644 --- a/workspaces/main/shaders/cnn_v2/cnn_v2_static.wgsl +++ b/workspaces/main/shaders/cnn_v2/cnn_v2_static.wgsl @@ -1,13 +1,19 @@ // CNN v2 Static Features Compute Shader // Generates 8D parametric features: [p0, p1, p2, p3, uv.x, uv.y, sin10_x, bias] -// p0-p3: Parametric features (currently RGBD from mip0, could be mip1/2, gradients, etc.) +// p0-p3: Parametric features from specified mip level (0=mip0, 1=mip1, 2=mip2, 3=mip3) // Note: Input image RGBD (mip0) fed separately to Layer 0 +struct StaticFeatureParams { + mip_level: u32, + padding: vec3<u32>, +} + @group(0) @binding(0) var input_tex: texture_2d<f32>; @group(0) @binding(1) var input_tex_mip1: texture_2d<f32>; @group(0) @binding(2) var input_tex_mip2: texture_2d<f32>; @group(0) @binding(3) var depth_tex: texture_2d<f32>; @group(0) @binding(4) var output_tex: texture_storage_2d<rgba32uint, write>; +@group(0) @binding(5) var<uniform> params: StaticFeatureParams; @compute @workgroup_size(8, 8) fn main(@builtin(global_invocation_id) id: vec3<u32>) { @@ -18,10 +24,19 @@ fn main(@builtin(global_invocation_id) id: vec3<u32>) { return; } - // Parametric features (p0-p3) - // TODO: Experiment with mip1 grayscale, Sobel gradients, etc. - // For now, use RGBD from mip 0 (same as input, but could differ) - let rgba = textureLoad(input_tex, coord, 0); + // Parametric features (p0-p3) - sample from specified mip level + var rgba: vec4<f32>; + if (params.mip_level == 0u) { + rgba = textureLoad(input_tex, coord, 0); + } else if (params.mip_level == 1u) { + rgba = textureLoad(input_tex_mip1, coord, 0); + } else if (params.mip_level == 2u) { + rgba = textureLoad(input_tex_mip2, coord, 0); + } else { + // Mip 3 or higher: use mip 2 as fallback + rgba = textureLoad(input_tex_mip2, coord, 0); + } + let p0 = rgba.r; let p1 = rgba.g; let p2 = rgba.b; |
