@luma.gl/effects
Version:
Post-processing effects for luma.gl
46 lines • 3.9 kB
TypeScript
/**
* Hue / Saturation
*/
export type HueSaturationProps = {
/** -1 to 1 (-1 is 180 degree rotation in the negative direction, 0 is no change,
* and 1 is 180 degree rotation in the positive direction) */
hue?: number;
/** -1 to 1 (-1 is solid gray, 0 is no change, and 1 is maximum contrast) */
saturation?: number;
};
export type HueSaturationUniforms = HueSaturationProps;
/**
* Hue / Saturation
* Provides rotational hue and multiplicative saturation control. RGB color space
* can be imagined as a cube where the axes are the red, green, and blue color
* values. Hue changing works by rotating the color vector around the grayscale
* line, which is the straight line from black (0, 0, 0) to white (1, 1, 1).
* Saturation is implemented by scaling all color channel values either toward
* or away from the average color channel value.
*/
export declare const hueSaturation: {
readonly props: HueSaturationProps;
readonly name: "hueSaturation";
readonly source: "\nstruct hueSaturationUniforms {\n hue: f32,\n saturation: f32,\n};\n\n@group(0), @binding(1) var<uniform> hueSaturation: hueSaturationUniforms;\n\nfn hueSaturation_filterColor(color: vec4<f32>) -> vec4<f32> {\n\tlet angle: f32 = hueSaturation.hue * 3.1415927;\n\tlet s: f32 = sin(angle);\n\tlet c: f32 = cos(angle);\n\tlet weights: vec3<f32> = (vec3<f32>(2. * c, -sqrt(3.) * s - c, sqrt(3.) * s - c) + 1.) / 3.;\n\tlet len: f32 = length(color.rgb);\n\tvar colorrgb = color.rgb;\n\tcolorrgb = vec3<f32>(dot(color.rgb, weights.xyz), dot(color.rgb, weights.zxy), dot(color.rgb, weights.yzx));\n\tcolor.r = colorrgb.x;\n\tcolor.g = colorrgb.y;\n\tcolor.b = colorrgb.z;\n\tlet average: f32 = (color.r + color.g + color.b) / 3.;\n\tif (hueSaturation.saturation > 0.) {\n\t\tvar colorrgb = color.rgb;\n\tcolorrgb = color.rgb + ((average - color.rgb) * (1. - 1. / (1.001 - hueSaturation.saturation)));\n\tcolor.r = colorrgb.x;\n\tcolor.g = colorrgb.y;\n\tcolor.b = colorrgb.z;\n\t} else { \n\t\tvar colorrgb = color.rgb;\n\tcolorrgb = color.rgb + ((average - color.rgb) * -hueSaturation.saturation);\n\tcolor.r = colorrgb.x;\n\tcolor.g = colorrgb.y;\n\tcolor.b = colorrgb.z;\n\t}\n\treturn color;\n} \n\nfn hueSaturation_filterColor_ext(color: vec4<f32>, texSize: vec2<f32>, texCoord: vec2<f32>) -> vec4<f32> {\n\treturn hueSaturation_filterColor(color);\n} \n";
readonly fs: "uniform hueSaturationUniforms {\n float hue;\n float saturation;\n} hueSaturation;\n\nvec4 hueSaturation_filterColor(vec4 color) {\n // hue adjustment, wolfram alpha: RotationTransform[angle, {1, 1, 1}][{x, y, z}]\n float angle = hueSaturation.hue * 3.14159265;\n float s = sin(angle), c = cos(angle);\n vec3 weights = (vec3(2.0 * c, -sqrt(3.0) * s - c, sqrt(3.0) * s - c) + 1.0) / 3.0;\n float len = length(color.rgb);\n color.rgb = vec3(\n dot(color.rgb, weights.xyz),\n dot(color.rgb, weights.zxy),\n dot(color.rgb, weights.yzx)\n );\n\n // saturation adjustment\n float average = (color.r + color.g + color.b) / 3.0;\n if (hueSaturation.saturation > 0.0) {\n color.rgb += (average - color.rgb) * (1.0 - 1.0 / (1.001 - hueSaturation.saturation));\n } else {\n color.rgb += (average - color.rgb) * (-hueSaturation.saturation);\n }\n\n return color;\n}\n\nvec4 hueSaturation_filterColor_ext(vec4 color, vec2 texSize, vec2 texCoord) {\n return hueSaturation_filterColor(color);\n}\n";
readonly uniformTypes: {
readonly hue: "f32";
readonly saturation: "f32";
};
readonly propTypes: {
readonly hue: {
readonly value: 0;
readonly min: -1;
readonly max: 1;
};
readonly saturation: {
readonly value: 0;
readonly min: -1;
readonly max: 1;
};
};
readonly passes: [{
readonly filter: true;
}];
};
//# sourceMappingURL=huesaturation.d.ts.map