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); }