make colormap respect color

This commit is contained in:
numzero 2025-11-25 14:51:49 +03:00
parent 059e98c3e3
commit ca460bc0d9

View File

@ -14,9 +14,10 @@ struct Varying {
@group(0) @binding(0) var<uniform> look: LookParams; @group(0) @binding(0) var<uniform> look: LookParams;
fn colormap(light: f32) -> vec3f { fn colormap(light: vec3f) -> vec3f {
let brightness = 3. * (1. - 1. / (1. + light)); let avg = dot(light, vec3f(1. / 3.));
return vec3(brightness, brightness - 1., brightness - 2.); let scale = 1. / (1. + avg);
return scale * light;
} }
@vertex @vertex
@ -28,5 +29,5 @@ fn on_vertex(in: Vertex) -> Varying {
@fragment @fragment
fn on_fragment(in: Varying) -> @location(0) vec4f { 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);
} }