From 0f53ed1ed8ed7c07cd7ea8e88e21b5be5d5494e5 Mon Sep 17 00:00:00 2001 From: skal Date: Sat, 14 Feb 2026 07:22:17 +0100 Subject: CNN v2: bilinear mip-level sampling and UI improvements MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit **CNN v2 Changes:** - Replace point sampling with bilinear interpolation for mip-level features - Add linear sampler (binding 6) to static features shader - Update CNNv2Effect, cnn_test, and HTML tool **HTML Tool UI:** - Move controls to floating bottom bar in central view - Consolidate video controls + Blend/Depth/Save PNG in single container - Increase left panel width: 300px → 315px (+5%) - Remove per-frame debug messages (visualization, rendering logs) **Technical:** - WGSL: textureSample() with linear_sampler vs textureLoad() - C++: Create WGPUSampler with Linear filtering - HTML: Change sampler from 'nearest' to 'linear' handoff(Claude): CNN v2 now uses bilinear mip-level sampling across all tools --- workspaces/main/shaders/cnn_v2/cnn_v2_static.wgsl | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'workspaces') diff --git a/workspaces/main/shaders/cnn_v2/cnn_v2_static.wgsl b/workspaces/main/shaders/cnn_v2/cnn_v2_static.wgsl index 7b08132..63fafa8 100644 --- a/workspaces/main/shaders/cnn_v2/cnn_v2_static.wgsl +++ b/workspaces/main/shaders/cnn_v2/cnn_v2_static.wgsl @@ -20,6 +20,7 @@ struct StaticFeatureParams { @group(0) @binding(3) var depth_tex: texture_2d; @group(0) @binding(4) var output_tex: texture_storage_2d; @group(0) @binding(5) var params: StaticFeatureParams; +@group(0) @binding(6) var linear_sampler: sampler; @compute @workgroup_size(8, 8) fn main(@builtin(global_invocation_id) id: vec3) { @@ -30,17 +31,19 @@ fn main(@builtin(global_invocation_id) id: vec3) { return; } - // Parametric features (p0-p3) - sample from specified mip level + // Parametric features (p0-p3) - bilinear sample from specified mip level + // Use UV coordinates for bilinear interpolation + let uv = (vec2(coord) + 0.5) / vec2(dims); var rgba: vec4; if (params.mip_level == 0u) { - rgba = textureLoad(input_tex, coord, 0); + rgba = textureSample(input_tex, linear_sampler, uv); } else if (params.mip_level == 1u) { - rgba = textureLoad(input_tex_mip1, coord, 0); + rgba = textureSample(input_tex_mip1, linear_sampler, uv); } else if (params.mip_level == 2u) { - rgba = textureLoad(input_tex_mip2, coord, 0); + rgba = textureSample(input_tex_mip2, linear_sampler, uv); } else { // Mip 3 or higher: use mip 2 as fallback - rgba = textureLoad(input_tex_mip2, coord, 0); + rgba = textureSample(input_tex_mip2, linear_sampler, uv); } let p0 = rgba.r; -- cgit v1.2.3