From ca460bc0d91b45fd2cd4111cce845d6b6583a846 Mon Sep 17 00:00:00 2001 From: numzero Date: Tue, 25 Nov 2025 14:51:49 +0300 Subject: [PATCH] make colormap respect color --- src/render/colormap.wgsl | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/render/colormap.wgsl b/src/render/colormap.wgsl index e2af29d..0e7db5b 100644 --- a/src/render/colormap.wgsl +++ b/src/render/colormap.wgsl @@ -14,9 +14,10 @@ struct Varying { @group(0) @binding(0) var look: LookParams; -fn colormap(light: f32) -> vec3f { - let brightness = 3. * (1. - 1. / (1. + light)); - return vec3(brightness, brightness - 1., brightness - 2.); +fn colormap(light: vec3f) -> vec3f { + let avg = dot(light, vec3f(1. / 3.)); + let scale = 1. / (1. + avg); + return scale * light; } @vertex @@ -28,5 +29,5 @@ fn on_vertex(in: Vertex) -> Varying { @fragment fn on_fragment(in: Varying) -> @location(0) vec4f { - return vec4f(colormap(in.color.x), 1.0); + return vec4f(colormap(in.color.rgb), in.color.a); }