@luma.gl/effects
Version:
Post-processing effects for luma.gl
55 lines (50 loc) • 1.47 kB
JavaScript
// luma.gl
// SPDX-License-Identifier: MIT
// Copyright (c) vis.gl contributors
const source = /* wgsl */ `\
struct vibranceUniforms {
amount: f32
};
@group(0) @binding(1) var<uniform> vibrance: vibranceUniforms;
fn vibrance_filterColor(vec4f color) -> vec4f {
let average: f32 = (color.r + color.g + color.b) / 3.0;
let mx: f32 = max(color.r, max(color.g, color.b));
let amt: f32 = (mx - average) * (-vibrance.amount * 3.0);
color.rgb = mix(color.rgb, vec3(mx), amt);
return color;
}
vec4 vibrance_filterColor_ext(vec4 color, vec2 texSize, vec2 texCoord) {
return vibrance_filterColor(color);
}
`;
const fs = /* glsl */ `\
uniform vibranceUniforms {
float amount;
} vibrance;
vec4 vibrance_filterColor(vec4 color) {
float average = (color.r + color.g + color.b) / 3.0;
float mx = max(color.r, max(color.g, color.b));
float amt = (mx - average) * (-vibrance.amount * 3.0);
color.rgb = mix(color.rgb, vec3(mx), amt);
return color;
}
vec4 vibrance_filterColor_ext(vec4 color, vec2 texSize, vec2 texCoord) {
return vibrance_filterColor(color);
}
`;
/** Vibrance - Modifies the saturation of desaturated colors, leaving saturated colors unmodified. */
export const vibrance = {
props: {},
uniforms: {},
name: 'vibrance',
uniformTypes: {
amount: 'f32'
},
propTypes: {
amount: { value: 0, min: -1, max: 1 }
},
source,
fs,
passes: [{ filter: true }]
};
//# sourceMappingURL=vibrance.js.map