@luma.gl/effects
Version:
Post-processing effects for luma.gl
1,834 lines (1,659 loc) • 69.7 kB
JavaScript
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
// dist/index.js
var dist_exports = {};
__export(dist_exports, {
_warp: () => warp,
brightnessContrast: () => brightnessContrast,
bulgePinch: () => bulgePinch,
colorHalftone: () => colorHalftone,
denoise: () => denoise,
dotScreen: () => dotScreen,
edgeWork: () => edgeWork,
fxaa: () => fxaa,
hexagonalPixelate: () => hexagonalPixelate,
hueSaturation: () => hueSaturation,
ink: () => ink,
magnify: () => magnify,
noise: () => noise,
sepia: () => sepia,
swirl: () => swirl,
tiltShift: () => tiltShift,
triangleBlur: () => triangleBlur,
vibrance: () => vibrance,
vignette: () => vignette,
zoomBlur: () => zoomBlur
});
module.exports = __toCommonJS(dist_exports);
// dist/passes/postprocessing/image-adjust-filters/brightnesscontrast.js
var source = (
/* wgsl */
`struct brightnessContrastUniforms {
brightness: f32,
contrast: f32
};
// Binding 0:1 is reserved for shader passes
@group(0) @binding(1) var<uniform> brightnessContrast : brightnessContrastUniforms;
fn brightnessContrast_filterColor_ext(color: vec4f, texSize: vec2<f32>, texCoords: vec2<f32>) -> vec4f {
color.rgb += brightnessContrast.brightness;
if (brightnessContrast.contrast > 0.0) {
color.rgb = (color.rgb - 0.5) / (1.0 - brightnessContrast.contrast) + 0.5;
} else {
color.rgb = (color.rgb - 0.5) * (1.0 + brightnessContrast.contrast) + 0.5;
}
return vec4f(1.0, 0.0, 0.0, 1.0);
}
`
);
var fs = (
/* glsl */
`uniform brightnessContrastUniforms {
float brightness;
float contrast;
} brightnessContrast;
vec4 brightnessContrast_filterColor(vec4 color) {
color.rgb += brightnessContrast.brightness;
if (brightnessContrast.contrast > 0.0) {
color.rgb = (color.rgb - 0.5) / (1.0 - brightnessContrast.contrast) + 0.5;
} else {
color.rgb = (color.rgb - 0.5) * (1.0 + brightnessContrast.contrast) + 0.5;
}
return color;
}
vec4 brightnessContrast_filterColor_ext(vec4 color, vec2 texSize, vec2 texCoord) {
return brightnessContrast_filterColor(color);
}
`
);
var brightnessContrast = {
name: "brightnessContrast",
source,
fs,
props: {},
uniformTypes: {
brightness: "f32",
contrast: "f32"
},
defaultUniforms: {
brightness: 0,
contrast: 0
},
propTypes: {
brightness: { format: "f32", value: 0, min: -1, max: 1 },
contrast: { format: "f32", value: 0, min: -1, max: 1 }
},
passes: [{ filter: true }]
};
// dist/passes/postprocessing/image-adjust-filters/denoise.js
var source2 = (
/* wgsl */
`
struct denoiseUniforms {
strength: f32
};
@group(0), @binding(1) var<uniform> denoise: denoiseUniforms;
fn denoise_sampleColor(source: sampler2D, texSize: vec2<f32>, texCoord: vec2<f32>) -> vec4<f32> {
let adjustedExponent: f32 = 3. + 200. * pow(1. - denoise.strength, 4.);
let center: vec4<f32> = sample_texture(BUFFER_source, texCoord);
var color: vec4<f32> = vec4<f32>(0.);
var total: f32 = 0.;
for (var x: f32 = -4.; x <= 4.; x = x + (1.)) {
for (var y: f32 = -4.; y <= 4.; y = y + (1.)) {
let offsetColor: vec4<f32> = sample_texture(BUFFER_source, texCoord + vec2<f32>(x, y) / texSize);
var weight: f32 = 1. - abs(dot(offsetColor.rgb - center.rgb, vec3<f32>(0.25)));
weight = pow(weight, adjustedExponent);
color = color + (offsetColor * weight);
total = total + (weight);
}
}
return color / total;
}
`
);
var fs2 = (
/* glsl */
`uniform dedenoiseUniforms {
float strength;
} denoise;
vec4 dedenoise_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord) {
float adjustedExponent = 3. + 200. * pow(1. - noise.strength, 4.);
vec4 center = texture(source, texCoord);
vec4 color = vec4(0.0);
float total = 0.0;
for (float x = -4.0; x <= 4.0; x += 1.0) {
for (float y = -4.0; y <= 4.0; y += 1.0) {
vec4 offsetColor = texture(source, texCoord + vec2(x, y) / texSize);
float weight = 1.0 - abs(dot(offsetColor.rgb - center.rgb, vec3(0.25)));
weight = pow(weight, adjustedExponent);
color += offsetColor * weight;
total += weight;
}
}
return color / total;
}
`
);
var denoise = {
props: {},
uniforms: {},
name: "denoise",
uniformTypes: {
strength: "f32"
},
propTypes: {
strength: { format: "f32", value: 0.5, min: 0, max: 1 }
// strength: {..., adjust: (strength: number): number => 0.53 + 200 * Math.pow(1 - strength, 4) // TODO - JS preprocessing
},
source: source2,
fs: fs2,
passes: [{ sampler: true }, { sampler: true }]
};
// dist/passes/postprocessing/image-adjust-filters/huesaturation.js
var source3 = (
/* wgsl */
`
struct hueSaturationUniforms {
hue: f32,
saturation: f32,
};
@group(0), @binding(1) var<uniform> hueSaturation: hueSaturationUniforms;
fn hueSaturation_filterColor(color: vec4<f32>) -> vec4<f32> {
let angle: f32 = hueSaturation.hue * 3.1415927;
let s: f32 = sin(angle);
let c: f32 = cos(angle);
let weights: vec3<f32> = (vec3<f32>(2. * c, -sqrt(3.) * s - c, sqrt(3.) * s - c) + 1.) / 3.;
let len: f32 = length(color.rgb);
var colorrgb = color.rgb;
colorrgb = vec3<f32>(dot(color.rgb, weights.xyz), dot(color.rgb, weights.zxy), dot(color.rgb, weights.yzx));
color.r = colorrgb.x;
color.g = colorrgb.y;
color.b = colorrgb.z;
let average: f32 = (color.r + color.g + color.b) / 3.;
if (hueSaturation.saturation > 0.) {
var colorrgb = color.rgb;
colorrgb = color.rgb + ((average - color.rgb) * (1. - 1. / (1.001 - hueSaturation.saturation)));
color.r = colorrgb.x;
color.g = colorrgb.y;
color.b = colorrgb.z;
} else {
var colorrgb = color.rgb;
colorrgb = color.rgb + ((average - color.rgb) * -hueSaturation.saturation);
color.r = colorrgb.x;
color.g = colorrgb.y;
color.b = colorrgb.z;
}
return color;
}
fn hueSaturation_filterColor_ext(color: vec4<f32>, texSize: vec2<f32>, texCoord: vec2<f32>) -> vec4<f32> {
return hueSaturation_filterColor(color);
}
`
);
var fs3 = (
/* glsl */
`uniform hueSaturationUniforms {
float hue;
float saturation;
} hueSaturation;
vec4 hueSaturation_filterColor(vec4 color) {
// hue adjustment, wolfram alpha: RotationTransform[angle, {1, 1, 1}][{x, y, z}]
float angle = hueSaturation.hue * 3.14159265;
float s = sin(angle), c = cos(angle);
vec3 weights = (vec3(2.0 * c, -sqrt(3.0) * s - c, sqrt(3.0) * s - c) + 1.0) / 3.0;
float len = length(color.rgb);
color.rgb = vec3(
dot(color.rgb, weights.xyz),
dot(color.rgb, weights.zxy),
dot(color.rgb, weights.yzx)
);
// saturation adjustment
float average = (color.r + color.g + color.b) / 3.0;
if (hueSaturation.saturation > 0.0) {
color.rgb += (average - color.rgb) * (1.0 - 1.0 / (1.001 - hueSaturation.saturation));
} else {
color.rgb += (average - color.rgb) * (-hueSaturation.saturation);
}
return color;
}
vec4 hueSaturation_filterColor_ext(vec4 color, vec2 texSize, vec2 texCoord) {
return hueSaturation_filterColor(color);
}
`
);
var hueSaturation = {
props: {},
name: "hueSaturation",
source: source3,
fs: fs3,
uniformTypes: {
hue: "f32",
saturation: "f32"
},
propTypes: {
hue: { value: 0, min: -1, max: 1 },
saturation: { value: 0, min: -1, max: 1 }
},
passes: [{ filter: true }]
};
// dist/passes/postprocessing/image-adjust-filters/noise.js
var source4 = (
/* wgsl */
`struct noiseUniforms {
amount: f32
};
@group(0) @binding(1) var<uniform> noise: noiseUniforms;
fn rand(co: vec2f) -> f32 {
return fract(sin(dot(co.xy, vec2f(12.9898, 78.233))) * 43758.547);
}
fn noise_filterColor_ext(color: vec4f, texSize: vec2f, texCoord: vec2f) -> vec4f {
let diff: f32 = (rand(texCoord) - 0.5) * noise.amount;
color.r = color.r + (diff);
color.g = color.g + (diff);
color.b = color.b + (diff);
return color;
}
`
);
var fs4 = (
/* glsl */
`uniform noiseUniforms {
float amount;
} noise;
float rand(vec2 co) {
return fract(sin(dot(co.xy ,vec2(12.9898,78.233))) * 43758.5453);
}
vec4 noise_filterColor_ext(vec4 color, vec2 texSize, vec2 texCoord) {
float diff = (rand(texCoord) - 0.5) * noise.amount;
color.r += diff;
color.g += diff;
color.b += diff;
return color;
}
`
);
var noise = {
name: "noise",
fs: fs4,
source: source4,
props: {},
uniforms: {},
uniformTypes: {
amount: "f32"
},
propTypes: {
amount: { value: 0.5, min: 0, max: 1 }
},
passes: [{ filter: true }]
};
// dist/passes/postprocessing/image-adjust-filters/sepia.js
var source5 = (
/* wgsl */
`struct sepiaUniforms {
amount: f32
};
@group(0) @binding(1) var<uniform> sepia: sepiaUniforms;
fn sepia_filterColor(color: vec4f) -> vec4f {
let r: f32 = color.r;
let g: f32 = color.g;
let b: f32 = color.b;
color.r =
min(1.0, (r * (1.0 - (0.607 * sepia.amount))) + (g * (0.769 * sepia.amount)) + (b * (0.189 * sepia.amount)));
color.g = min(1.0, (r * 0.349 * sepia.amount) + (g * (1.0 - (0.314 * sepia.amount))) + (b * 0.168 * sepia.amount));
color.b = min(1.0, (r * 0.272 * sepia.amount) + (g * 0.534 * sepia.amount) + (b * (1.0 - (0.869 * sepia.amount))));
return color;
}
vec4 sepia_filterColor_ext(vec4 color, vec2 texSize, vec2 texCoord) {
return sepia_filterColor(color);
}
`
);
var fs5 = (
/* glsl */
`uniform sepiaUniforms {
float amount;
} sepia;
vec4 sepia_filterColor(vec4 color) {
float r = color.r;
float g = color.g;
float b = color.b;
color.r =
min(1.0, (r * (1.0 - (0.607 * sepia.amount))) + (g * (0.769 * sepia.amount)) + (b * (0.189 * sepia.amount)));
color.g = min(1.0, (r * 0.349 * sepia.amount) + (g * (1.0 - (0.314 * sepia.amount))) + (b * 0.168 * sepia.amount));
color.b = min(1.0, (r * 0.272 * sepia.amount) + (g * 0.534 * sepia.amount) + (b * (1.0 - (0.869 * sepia.amount))));
return color;
}
vec4 sepia_filterColor_ext(vec4 color, vec2 texSize, vec2 texCoord) {
return sepia_filterColor(color);
}
`
);
var sepia = {
props: {},
uniforms: {},
name: "sepia",
uniformTypes: {
amount: "f32"
},
propTypes: {
amount: { value: 0.5, min: 0, max: 1 }
},
fs: fs5,
source: source5,
passes: [{ filter: true }]
};
// dist/passes/postprocessing/image-adjust-filters/vibrance.js
var source6 = (
/* 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);
}
`
);
var fs6 = (
/* 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);
}
`
);
var vibrance = {
props: {},
uniforms: {},
name: "vibrance",
uniformTypes: {
amount: "f32"
},
propTypes: {
amount: { value: 0, min: -1, max: 1 }
},
source: source6,
fs: fs6,
passes: [{ filter: true }]
};
// dist/passes/postprocessing/image-adjust-filters/vignette.js
var source7 = (
/* wgsl */
`struct vignetteUniforms {
radius: f32,
amount: f32
};
@group(0) @binding(1) var<uniform> vignette: vignetteUniforms;
fn vibrance_filterColor(color: vec4f) -> 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, vec3f(mx), amt);
return color;
}
fn vignette_filterColor_ext(color: vec4f, texSize: vec2f, texCoord: vec2f) ->vec4f {
let dist: f32 = distance(texCoord, vec2f(0.5, 0.5));
let ratio: f32 = smoothstep(0.8, vignette.radius * 0.799, dist * (vignette.amount + vignette.radius));
return color.rgba * ratio + (1.0 - ratio)*vec4f(0.0, 0.0, 0.0, 1.0);
}
`
);
var fs7 = (
/* glsl */
`uniform vignetteUniforms {
float radius;
float amount;
} vignette;
vec4 vignette_filterColor_ext(vec4 color, vec2 texSize, vec2 texCoord) {
float dist = distance(texCoord, vec2(0.5, 0.5));
float ratio = smoothstep(0.8, vignette.radius * 0.799, dist * (vignette.amount + vignette.radius));
return color.rgba * ratio + (1.0 - ratio)*vec4(0.0, 0.0, 0.0, 1.0);
}
`
);
var vignette = {
props: {},
uniforms: {},
name: "vignette",
source: source7,
fs: fs7,
uniformTypes: {
radius: "f32",
amount: "f32"
},
defaultUniforms: {
radius: 0.5,
amount: 0.5
},
propTypes: {
radius: { value: 0.5, min: 0, max: 1 },
amount: { value: 0.5, min: 0, max: 1 }
},
passes: [{ filter: true }]
};
// dist/passes/postprocessing/image-blur-filters/tiltshift.js
var import_shadertools = require("@luma.gl/shadertools");
var source8 = (
/* wgsl */
`uniform tiltShiftUniforms {
blurRadius: f32,
gradientRadius: f32,
start: vec2f,
end: vec2f,
invert: u32,
};
@group(0) @binding(1) var<uniform> tiltShift: tiltShiftUniforms;
fn tiltShift_getDelta(vec2 texSize) -> vec2f {
vec2 vector = normalize((tiltShift.end - tiltShift.start) * texSize);
return tiltShift.invert ? vec2(-vector.y, vector.x) : vector;
}
fn tiltShift_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord) -> vec4f {
vec4 color = vec4(0.0);
float total = 0.0;
/* randomize the lookup values to hide the fixed number of samples */
float offset = random(vec3(12.9898, 78.233, 151.7182), 0.0);
vec2 normal = normalize(vec2((tiltShift.start.y - tiltShift.end.y) * texSize.y, (tiltShift.end.x - tiltShift.start.x) * texSize.x));
float radius = smoothstep(0.0, 1.0,
abs(dot(texCoord * texSize - tiltShift.start * texSize, normal)) / tiltShift.gradientRadius) * tiltShift.blurRadius;
for (float t = -30.0; t <= 30.0; t++) {
float percent = (t + offset - 0.5) / 30.0;
float weight = 1.0 - abs(percent);
vec4 offsetColor = texture(source, texCoord + tiltShift_getDelta(texSize) / texSize * percent * radius);
color += offsetColor * weight;
total += weight;
}
color = color / total;
return color;
}
`
);
var fs8 = (
/* glsl */
`uniform tiltShiftUniforms {
float blurRadius;
float gradientRadius;
vec2 start;
vec2 end;
bool invert;
} tiltShift;
vec2 tiltShift_getDelta(vec2 texSize) {
vec2 vector = normalize((tiltShift.end - tiltShift.start) * texSize);
return tiltShift.invert ? vec2(-vector.y, vector.x) : vector;
}
vec4 tiltShift_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord) {
vec4 color = vec4(0.0);
float total = 0.0;
/* randomize the lookup values to hide the fixed number of samples */
float offset = random(vec3(12.9898, 78.233, 151.7182), 0.0);
vec2 normal = normalize(vec2((tiltShift.start.y - tiltShift.end.y) * texSize.y, (tiltShift.end.x - tiltShift.start.x) * texSize.x));
float radius = smoothstep(0.0, 1.0,
abs(dot(texCoord * texSize - tiltShift.start * texSize, normal)) / tiltShift.gradientRadius) * tiltShift.blurRadius;
for (float t = -30.0; t <= 30.0; t++) {
float percent = (t + offset - 0.5) / 30.0;
float weight = 1.0 - abs(percent);
vec4 offsetColor = texture(source, texCoord + tiltShift_getDelta(texSize) / texSize * percent * radius);
color += offsetColor * weight;
total += weight;
}
color = color / total;
return color;
}
`
);
var tiltShift = {
name: "tiltShift",
dependencies: [import_shadertools.random],
source: source8,
fs: fs8,
props: {},
uniforms: {},
uniformTypes: {
blurRadius: "f32",
gradientRadius: "f32",
start: "vec2<f32>",
end: "vec2<f32>",
invert: "i32"
},
propTypes: {
blurRadius: { value: 15, min: 0, max: 50 },
gradientRadius: { value: 200, min: 0, max: 400 },
start: { value: [0, 0] },
end: { value: [1, 1] },
invert: { value: 0, private: true }
},
passes: [
{ sampler: true, uniforms: { invert: 0 } },
{ sampler: true, uniforms: { invert: 1 } }
]
};
// dist/passes/postprocessing/image-blur-filters/triangleblur.js
var import_shadertools2 = require("@luma.gl/shadertools");
var source9 = (
/* wgsl */
`uniform triangleBlurUniforms {
radius: f32,
delta: vec2f,
}
@group(0) @binding(1) var<uniform> triangleBlur: triangleBlurUniforms;
vec4 triangleBlur_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord) {
vec2 adjustedDelta = triangleBlur.delta * triangleBlur.radius / texSize;
vec4 color = vec4(0.0);
float total = 0.0;
/* randomize the lookup values to hide the fixed number of samples */
float offset = random(vec3(12.9898, 78.233, 151.7182), 0.0);
for (float t = -30.0; t <= 30.0; t++) {
float percent = (t + offset - 0.5) / 30.0;
float weight = 1.0 - abs(percent);
vec4 offsetColor = texture(source, texCoord + adjustedDelta * percent);
/* switch to pre-multiplied alpha to correctly blur transparent images */
offsetColor.rgb *= offsetColor.a;
color += offsetColor * weight;
total += weight;
}
color = color / total;
/* switch back from pre-multiplied alpha */
color.rgb /= color.a + 0.00001;
return color;
}
`
);
var fs9 = (
/* glsl */
`uniform triangleBlurUniforms {
float radius;
vec2 delta;
} triangleBlur;
vec4 triangleBlur_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord) {
vec2 adjustedDelta = triangleBlur.delta * triangleBlur.radius / texSize;
vec4 color = vec4(0.0);
float total = 0.0;
/* randomize the lookup values to hide the fixed number of samples */
float offset = random(vec3(12.9898, 78.233, 151.7182), 0.0);
for (float t = -30.0; t <= 30.0; t++) {
float percent = (t + offset - 0.5) / 30.0;
float weight = 1.0 - abs(percent);
vec4 offsetColor = texture(source, texCoord + adjustedDelta * percent);
/* switch to pre-multiplied alpha to correctly blur transparent images */
offsetColor.rgb *= offsetColor.a;
color += offsetColor * weight;
total += weight;
}
color = color / total;
/* switch back from pre-multiplied alpha */
color.rgb /= color.a + 0.00001;
return color;
}
`
);
var triangleBlur = {
name: "triangleBlur",
dependencies: [import_shadertools2.random],
source: source9,
fs: fs9,
props: {},
uniforms: {},
uniformTypes: {
radius: "f32",
delta: "vec2<f32>"
},
propTypes: {
radius: { value: 20, min: 0, softMax: 100 },
delta: { value: [1, 0], private: true }
},
passes: [
{ sampler: true, uniforms: { delta: [1, 0] } },
{ sampler: true, uniforms: { delta: [0, 1] } }
]
};
// dist/passes/postprocessing/image-blur-filters/zoomblur.js
var import_shadertools3 = require("@luma.gl/shadertools");
var source10 = (
/* wgsl */
`
uniform zoomBlurUniforms {
center: vec2f,
strength: f32,
};
@group(0) @binding(1) var<uniform> zoomBlur : zoomBlurUniforms;
fn zoomBlur_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord) -> vec4f {
vec4 color = vec4(0.0);
float total = 0.0;
vec2 toCenter = zoomBlur.center * texSize - texCoord * texSize;
/* randomize the lookup values to hide the fixed number of samples */
float offset = random(vec3(12.9898, 78.233, 151.7182), 0.0);
for (float t = 0.0; t <= 40.0; t++) {
float percent = (t + offset) / 40.0;
float weight = 4.0 * (percent - percent * percent);
vec4 offsetColor = texture(source, texCoord + toCenter * percent * zoomBlur.strength / texSize);
color += offsetColor * weight;
total += weight;
}
color = color / total;
return color;
}
`
);
var fs10 = (
/* glsl */
`
uniform zoomBlurUniforms {
vec2 center;
float strength;
} zoomBlur;
vec4 zoomBlur_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord) {
vec4 color = vec4(0.0);
float total = 0.0;
vec2 toCenter = zoomBlur.center * texSize - texCoord * texSize;
/* randomize the lookup values to hide the fixed number of samples */
float offset = random(vec3(12.9898, 78.233, 151.7182), 0.0);
for (float t = 0.0; t <= 40.0; t++) {
float percent = (t + offset) / 40.0;
float weight = 4.0 * (percent - percent * percent);
vec4 offsetColor = texture(source, texCoord + toCenter * percent * zoomBlur.strength / texSize);
color += offsetColor * weight;
total += weight;
}
color = color / total;
return color;
}
`
);
var zoomBlur = {
name: "zoomBlur",
dependencies: [import_shadertools3.random],
source: source10,
fs: fs10,
props: {},
uniforms: {},
uniformTypes: {
center: "vec2<f32>",
strength: "f32"
},
propTypes: {
center: { value: [0.5, 0.5] },
strength: { value: 0.3, min: 0, softMax: 1 }
},
passes: [{ sampler: true }]
};
// dist/passes/postprocessing/image-fun-filters/colorhalftone.js
var source11 = (
/* wgsl */
`struct colorHalftoneUniforms {
center: vec2f,
angle: f32,
size: f32.
};
@group(0) @binding(1) var<uniform> colorHalftone: colorHalftoneUniforms;
fn pattern(angle: f32, scale: f32, texSize: vec2f, texCoord: vec2f) -> f32 {
let s: f32 = sin(angle), c = cos(angle);
let tex: vec2f = texCoord * texSize - colorHalftone.center * texSize;
let point: vec2f = vec2(
c * tex.x - s * tex.y,
s * tex.x + c * tex.y
) * scale;
return (sin(point.x) * sin(point.y)) * 4.0;
}
fn colorHalftone_filterColor_ext(vec4f color, vec2f texSize, vec2f texCoord) -> vec4f {
let scale: f32 = 3.1514 / colorHalftone.size;
let cmy: vec3f = 1.0 - color.rgb;
let k: f32 = min(cmy.x, min(cmy.y, cmy.z));
cmy = (cmy - k) / (1.0 - k);
cmy = clamp(
cmy * 10.0 - 3.0 + vec3(
pattern(colorHalftone.angle + 0.26179, scale, texSize, texCoord),
pattern(colorHalftone.angle + 1.30899, scale, texSize, texCoord),
pattern(colorHalftone.angle, scale, texSize, texCoord)
),
0.0,
1.0
);
k = clamp(k * 10.0 - 5.0 + pattern(colorHalftone.angle + 0.78539, scale, texSize, texCoord), 0.0, 1.0);
return vec4(1.0 - cmy - k, color.a);
}
`
);
var fs11 = (
/* glsl */
`uniform colorHalftoneUniforms {
vec2 center;
float angle;
float size;
} colorHalftone;
float pattern(float angle, float scale, vec2 texSize, vec2 texCoord) {
float s = sin(angle), c = cos(angle);
vec2 tex = texCoord * texSize - colorHalftone.center * texSize;
vec2 point = vec2(
c * tex.x - s * tex.y,
s * tex.x + c * tex.y
) * scale;
return (sin(point.x) * sin(point.y)) * 4.0;
}
vec4 colorHalftone_filterColor_ext(vec4 color, vec2 texSize, vec2 texCoord) {
float scale = 3.1514 / colorHalftone.size;
vec3 cmy = 1.0 - color.rgb;
float k = min(cmy.x, min(cmy.y, cmy.z));
cmy = (cmy - k) / (1.0 - k);
cmy = clamp(
cmy * 10.0 - 3.0 + vec3(
pattern(colorHalftone.angle + 0.26179, scale, texSize, texCoord),
pattern(colorHalftone.angle + 1.30899, scale, texSize, texCoord),
pattern(colorHalftone.angle, scale, texSize, texCoord)
),
0.0,
1.0
);
k = clamp(k * 10.0 - 5.0 + pattern(colorHalftone.angle + 0.78539, scale, texSize, texCoord), 0.0, 1.0);
return vec4(1.0 - cmy - k, color.a);
}
`
);
var colorHalftone = {
name: "colorHalftone",
source: source11,
fs: fs11,
props: {},
uniforms: {},
uniformTypes: {
center: "vec2<f32>",
angle: "f32",
size: "f32"
},
propTypes: {
center: { value: [0.5, 0.5] },
angle: { value: 1.1, softMin: 0, softMax: Math.PI / 2 },
size: { value: 4, min: 1, softMin: 3, softMax: 20 }
},
passes: [{ filter: true }]
};
// dist/passes/postprocessing/image-fun-filters/dotscreen.js
var source12 = (
/* wgsl */
`uniform dotScreenUniforms {
center: vec2f,
angle: f32,
size: f32,
};
@group(0) @binding(1) dotScreen: dotScreenUniforms;
fn pattern(texSize: vec2f, texCoord: vec2f) -> f32 {
let scale: f32 = 3.1415 / dotScreen.size;
let s: f32 = sin(dotScreen.angle), c = cos(dotScreen.angle);
tex: vec2f = texCoord * texSize - dotScreen.center * texSize;
point = vec2f(
c: * tex.x - s * tex.y,
s * tex.x + c * tex.y
) * scale;
return (sin(point.x) * sin(point.y)) * 4.0;
}
fn dotScreen_filterColor_ext(vec4 color, texSize: vec2f, texCoord: vec2f) -> vec4f {
let average: f32 = (color.r + color.g + color.b) / 3.0;
return vec4(vec3(average * 10.0 - 5.0 + pattern(texSize, texCoord)), color.a);
}
`
);
var fs12 = (
/* glsl */
`uniform dotScreenUniforms {
vec2 center;
float angle;
float size;
} dotScreen;
float pattern(vec2 texSize, vec2 texCoord) {
float scale = 3.1415 / dotScreen.size;
float s = sin(dotScreen.angle), c = cos(dotScreen.angle);
vec2 tex = texCoord * texSize - dotScreen.center * texSize;
vec2 point = vec2(
c * tex.x - s * tex.y,
s * tex.x + c * tex.y
) * scale;
return (sin(point.x) * sin(point.y)) * 4.0;
}
vec4 dotScreen_filterColor_ext(vec4 color, vec2 texSize, vec2 texCoord) {
float average = (color.r + color.g + color.b) / 3.0;
return vec4(vec3(average * 10.0 - 5.0 + pattern(texSize, texCoord)), color.a);
}
`
);
var dotScreen = {
name: "dotScreen",
source: source12,
fs: fs12,
props: {},
uniforms: {},
uniformTypes: {
center: "vec2<f32>",
angle: "f32",
size: "f32"
},
propTypes: {
center: { value: [0.5, 0.5] },
angle: { value: 1.1, softMin: 0, softMax: Math.PI / 2 },
size: { value: 3, min: 1, softMin: 3, softMax: 20 }
},
passes: [{ filter: true }]
};
// dist/passes/postprocessing/image-fun-filters/edgework.js
var import_shadertools4 = require("@luma.gl/shadertools");
var source13 = (
/* wgsl */
`struct edgeWorkUniforms {
radius: f32,
int mode: uint32,
};
@group(0) @binding(1) var<uniform> edgeWork: edgeWorkUniforms;
fn edgeWork_sampleColorRGB(sampler2D source, vec2 texSize, vec2 texCoord, vec2 delta) -> vec4f {
vec2 relativeDelta = edgeWork.radius * delta / texSize;
vec2 color = vec2(0.0);
vec2 total = vec2(0.0);
/* randomize the lookup values to hide the fixed number of samples */
float offset = random(vec3(12.9898, 78.233, 151.7182), 0.0);
for (float t = -30.0; t <= 30.0; t++) {
float percent = (t + offset - 0.5) / 30.0;
float weight = 1.0 - abs(percent);
vec3 sampleColor = texture(source, texCoord + relativeDelta * percent).rgb;
float average = (sampleColor.r + sampleColor.g + sampleColor.b) / 3.0;
color.x += average * weight;
total.x += weight;
if (abs(t) < 15.0) {
weight = weight * 2.0 - 1.0;
color.y += average * weight;
total.y += weight;
}
}
return vec4(color / total, 0.0, 1.0);
}
`
);
var fs13 = (
/* glsl */
`uniform edgeWorkUniforms {
float radius;
int mode;
} edgeWork;
vec4 edgeWork_sampleColorRGB(sampler2D source, vec2 texSize, vec2 texCoord, vec2 delta) {
vec2 relativeDelta = edgeWork.radius * delta / texSize;
vec2 color = vec2(0.0);
vec2 total = vec2(0.0);
/* randomize the lookup values to hide the fixed number of samples */
float offset = random(vec3(12.9898, 78.233, 151.7182), 0.0);
for (float t = -30.0; t <= 30.0; t++) {
float percent = (t + offset - 0.5) / 30.0;
float weight = 1.0 - abs(percent);
vec3 sampleColor = texture(source, texCoord + relativeDelta * percent).rgb;
float average = (sampleColor.r + sampleColor.g + sampleColor.b) / 3.0;
color.x += average * weight;
total.x += weight;
if (abs(t) < 15.0) {
weight = weight * 2.0 - 1.0;
color.y += average * weight;
total.y += weight;
}
}
return vec4(color / total, 0.0, 1.0);
}
vec4 edgeWork_sampleColorXY(sampler2D source, vec2 texSize, vec2 texCoord, vec2 delta) {
vec2 relativeDelta = edgeWork.radius * delta / texSize;
vec2 color = vec2(0.0);
vec2 total = vec2(0.0);
/* randomize the lookup values to hide the fixed number of samples */
float offset = random(vec3(12.9898, 78.233, 151.7182), 0.0);
for (float t = -30.0; t <= 30.0; t++) {
float percent = (t + offset - 0.5) / 30.0;
float weight = 1.0 - abs(percent);
vec2 sampleColor = texture(source, texCoord + relativeDelta * percent).xy;
color.x += sampleColor.x * weight;
total.x += weight;
if (abs(t) < 15.0) {
weight = weight * 2.0 - 1.0;
color.y += sampleColor.y * weight;
total.y += weight;
}
}
float c = clamp(10000.0 * (color.y / total.y - color.x / total.x) + 0.5, 0.0, 1.0);
return vec4(c, c, c, 1.0);
}
vec4 edgeWork_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord) {
switch (edgeWork.mode) {
case 0:
return edgeWork_sampleColorRGB(source, texSize, texCoord, vec2(1., 0.));
case 1:
default:
return edgeWork_sampleColorXY(source, texSize, texCoord, vec2(0., 1.));
}
}
`
);
var edgeWork = {
name: "edgeWork",
dependencies: [import_shadertools4.random],
source: source13,
fs: fs13,
props: {},
uniforms: {},
uniformTypes: {
radius: "f32",
mode: "i32"
},
propTypes: {
radius: { value: 2, min: 1, softMax: 50 },
mode: { value: 0, private: true }
},
passes: [
{
sampler: true,
uniforms: { mode: 0 }
},
{
sampler: true,
uniforms: { mode: 1 }
}
]
};
// dist/passes/postprocessing/image-fun-filters/hexagonalpixelate.js
var source14 = (
/* wgsl */
`struct hexagonalPixelateUniforms {
center: vec2f,
scale: f32,
};
@group(0) @binding(1) var<uniform> hexagonalPixelate: hexagonalPixelateUniforms;
fn hexagonalPixelate_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord) -> vec4f {
vec2 tex = (texCoord * texSize - hexagonalPixelate.center * texSize) / hexagonalPixelate.scale;
tex.y /= 0.866025404;
tex.x -= tex.y * 0.5;
vec2 a;
if (tex.x + tex.y - floor(tex.x) - floor(tex.y) < 1.0) {
a = vec2(floor(tex.x), floor(tex.y));
}
else a = vec2(ceil(tex.x), ceil(tex.y));
vec2 b = vec2(ceil(tex.x), floor(tex.y));
vec2 c = vec2(floor(tex.x), ceil(tex.y));
vec3 TEX = vec3(tex.x, tex.y, 1.0 - tex.x - tex.y);
vec3 A = vec3(a.x, a.y, 1.0 - a.x - a.y);
vec3 B = vec3(b.x, b.y, 1.0 - b.x - b.y);
vec3 C = vec3(c.x, c.y, 1.0 - c.x - c.y);
float alen = length(TEX - A);
float blen = length(TEX - B);
float clen = length(TEX - C);
vec2 choice;
if (alen < blen) {
if (alen < clen) choice = a;
else choice = c;
} else {
if (blen < clen) choice = b;
else choice = c;
}
choice.x += choice.y * 0.5;
choice.y *= 0.866025404;
choice *= hexagonalPixelate.scale / texSize;
return texture(source, choice + hexagonalPixelate.center);
}
`
);
var fs14 = (
/* glsl */
`uniform hexagonalPixelateUniforms {
vec2 center;
float scale;
} hexagonalPixelate;
vec4 hexagonalPixelate_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord) {
vec2 tex = (texCoord * texSize - hexagonalPixelate.center * texSize) / hexagonalPixelate.scale;
tex.y /= 0.866025404;
tex.x -= tex.y * 0.5;
vec2 a;
if (tex.x + tex.y - floor(tex.x) - floor(tex.y) < 1.0) {
a = vec2(floor(tex.x), floor(tex.y));
}
else a = vec2(ceil(tex.x), ceil(tex.y));
vec2 b = vec2(ceil(tex.x), floor(tex.y));
vec2 c = vec2(floor(tex.x), ceil(tex.y));
vec3 TEX = vec3(tex.x, tex.y, 1.0 - tex.x - tex.y);
vec3 A = vec3(a.x, a.y, 1.0 - a.x - a.y);
vec3 B = vec3(b.x, b.y, 1.0 - b.x - b.y);
vec3 C = vec3(c.x, c.y, 1.0 - c.x - c.y);
float alen = length(TEX - A);
float blen = length(TEX - B);
float clen = length(TEX - C);
vec2 choice;
if (alen < blen) {
if (alen < clen) choice = a;
else choice = c;
} else {
if (blen < clen) choice = b;
else choice = c;
}
choice.x += choice.y * 0.5;
choice.y *= 0.866025404;
choice *= hexagonalPixelate.scale / texSize;
return texture(source, choice + hexagonalPixelate.center);
}
`
);
var hexagonalPixelate = {
name: "hexagonalPixelate",
source: source14,
fs: fs14,
props: {},
uniforms: {},
uniformTypes: {
center: "vec2<f32>",
scale: "f32"
},
propTypes: {
center: { value: [0.5, 0.5], hint: "screenspace" },
scale: { value: 10, min: 1, softMin: 5, softMax: 50 }
},
passes: [{ sampler: true }]
};
// dist/passes/postprocessing/image-fun-filters/ink.js
var source15 = (
/* wgsl */
`uniform inkUniforms {
strength: f32,
};
@group(0) @binding(1) var<uniform> ink: inkUniforms;
fn ink_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord) -> vec4f {
vec2 dx = vec2(1.0 / texSize.x, 0.0);
vec2 dy = vec2(0.0, 1.0 / texSize.y);
vec4 color = texture(source, texCoord);
float bigTotal = 0.0;
float smallTotal = 0.0;
vec3 bigAverage = vec3(0.0);
vec3 smallAverage = vec3(0.0);
for (float x = -2.0; x <= 2.0; x += 1.0) {
for (float y = -2.0; y <= 2.0; y += 1.0) {
vec3 offsetColor = texture(source, texCoord + dx * x + dy * y).rgb;
bigAverage += offsetColor;
bigTotal += 1.0;
if (abs(x) + abs(y) < 2.0) {
smallAverage += offsetColor;
smallTotal += 1.0;
}
}
}
vec3 edge = max(vec3(0.0), bigAverage / bigTotal - smallAverage / smallTotal);
float power = ink.strength * ink.strength * ink.strength * ink.strength * ink.strength;
return vec4(color.rgb - dot(edge, edge) * power * 100000.0, color.a);
}
`
);
var fs15 = (
/* glsl */
`uniform inkUniforms {
float strength;
} ink;
vec4 ink_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord) {
vec2 dx = vec2(1.0 / texSize.x, 0.0);
vec2 dy = vec2(0.0, 1.0 / texSize.y);
vec4 color = texture(source, texCoord);
float bigTotal = 0.0;
float smallTotal = 0.0;
vec3 bigAverage = vec3(0.0);
vec3 smallAverage = vec3(0.0);
for (float x = -2.0; x <= 2.0; x += 1.0) {
for (float y = -2.0; y <= 2.0; y += 1.0) {
vec3 offsetColor = texture(source, texCoord + dx * x + dy * y).rgb;
bigAverage += offsetColor;
bigTotal += 1.0;
if (abs(x) + abs(y) < 2.0) {
smallAverage += offsetColor;
smallTotal += 1.0;
}
}
}
vec3 edge = max(vec3(0.0), bigAverage / bigTotal - smallAverage / smallTotal);
float power = ink.strength * ink.strength * ink.strength * ink.strength * ink.strength;
return vec4(color.rgb - dot(edge, edge) * power * 100000.0, color.a);
}
`
);
var ink = {
name: "ink",
source: source15,
fs: fs15,
props: {},
uniforms: {},
uniformTypes: {
strength: "f32"
},
propTypes: {
strength: { value: 0.25, min: 0, softMax: 1 }
},
passes: [{ sampler: true }]
};
// dist/passes/postprocessing/image-fun-filters/magnify.js
var source16 = (
/* wgsl */
`uniform magnifyUniforms {
screenXY: vec2f;
radiusPixels: f32;
zoom: f32;
borderWidthPixels: f32;
borderColor: vec4f;
};
@group(0) @binding(1) var<uniform> magnify: magnifyUniforms;
fn magnify_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord) -> vec4f {
vec2 pos = vec2(magnify.screenXY.x, 1.0 - magnify.screenXY.y);
float dist = distance(texCoord * texSize, pos * texSize);
if (dist < magnify.radiusPixels) {
return texture(source, (texCoord - pos) / magnify.zoom + pos);
}
if (dist <= magnify.radiusPixels + magnify.borderWidthPixels) {
return magnify.borderColor;
}
return texture(source, texCoord);
}
`
);
var fs16 = (
/* glsl */
`uniform magnifyUniforms {
vec2 screenXY;
float radiusPixels;
float zoom;
float borderWidthPixels;
vec4 borderColor;
} magnify;
vec4 magnify_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord) {
vec2 pos = vec2(magnify.screenXY.x, 1.0 - magnify.screenXY.y);
float dist = distance(texCoord * texSize, pos * texSize);
if (dist < magnify.radiusPixels) {
return texture(source, (texCoord - pos) / magnify.zoom + pos);
}
if (dist <= magnify.radiusPixels + magnify.borderWidthPixels) {
return magnify.borderColor;
}
return texture(source, texCoord);
}
`
);
var magnify = {
name: "magnify",
source: source16,
fs: fs16,
uniformTypes: {
screenXY: "vec2<f32>",
radiusPixels: "f32",
zoom: "f32",
borderWidthPixels: "f32",
borderColor: "vec4<f32>"
},
propTypes: {
// range 0 to 1
screenXY: { value: [0, 0] },
radiusPixels: 200,
zoom: 2,
borderWidthPixels: 0,
borderColor: { value: [255, 255, 255, 255] }
},
passes: [{ sampler: true }]
};
// dist/passes/postprocessing/image-warp-filters/warp.js
var source17 = (
/* wgsl */
`vec4 warp_sampleColor(sampler2D source, vec2 texSize, vec2 coord) {
vec4 color = texture(source, coord / texSize);
vec2 clampedCoord = clamp(coord, vec2(0.0), texSize);
if (coord != clampedCoord) {
/* fade to transparent if we are outside the image */
color.a *= max(0.0, 1.0 - length(coord - clampedCoord));
}
return color;
}
`
);
var fs17 = (
/* glsl */
`vec4 warp_sampleColor(sampler2D source, vec2 texSize, vec2 coord) {
vec4 color = texture(source, coord / texSize);
vec2 clampedCoord = clamp(coord, vec2(0.0), texSize);
if (coord != clampedCoord) {
/* fade to transparent if we are outside the image */
color.a *= max(0.0, 1.0 - length(coord - clampedCoord));
}
return color;
}
`
);
var warp = {
name: "warp",
source: source17,
fs: fs17,
passes: []
};
// dist/passes/postprocessing/image-warp-filters/bulgepinch.js
var source18 = (
/* wgsl */
`uniform bulgePinchUniforms {
radius: f32,
strength: f32,
center: vec2f,
};
@group(0) @binding(1) var<uniform> bulgePinch: bulgePinchUniforms;
fn bulgePinch_warp(vec2 coord, vec2 texCenter) -> vec2f {
coord -= texCenter;
float distance = length(coord);
if (distance < bulgePinch.radius) {
float percent = distance / bulgePinch.radius;
if (bulgePinch.strength > 0.0) {
coord *= mix(1.0, smoothstep(0.0, bulgePinch.radius / distance, percent), bulgePinch.strength * 0.75);
} else {
coord *= mix(1.0, pow(percent, 1.0 + bulgePinch.strength * 0.75) * bulgePinch.radius / distance, 1.0 - percent);
}
}
coord += texCenter;
return coord;
}
fn bulgePinch_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord) -> vec4f {
vec2 coord = texCoord * texSize;
coord = bulgePinch_warp(coord, bulgePinch.center * texSize);
return warp_sampleColor(source, texSize, coord);
}
`
);
var fs18 = (
/* glsl */
`uniform bulgePinchUniforms {
float radius;
float strength;
vec2 center;
} bulgePinch;
vec2 bulgePinch_warp(vec2 coord, vec2 texCenter) {
coord -= texCenter;
float distance = length(coord);
if (distance < bulgePinch.radius) {
float percent = distance / bulgePinch.radius;
if (bulgePinch.strength > 0.0) {
coord *= mix(1.0, smoothstep(0.0, bulgePinch.radius / distance, percent), bulgePinch.strength * 0.75);
} else {
coord *= mix(1.0, pow(percent, 1.0 + bulgePinch.strength * 0.75) * bulgePinch.radius / distance, 1.0 - percent);
}
}
coord += texCenter;
return coord;
}
vec4 bulgePinch_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord) {
vec2 coord = texCoord * texSize;
coord = bulgePinch_warp(coord, bulgePinch.center * texSize);
return warp_sampleColor(source, texSize, coord);
}
`
);
var bulgePinch = {
name: "bulgePinch",
dependencies: [warp],
source: source18,
fs: fs18,
props: {},
uniforms: {},
uniformTypes: {
center: "vec2<f32>",
radius: "f32",
strength: "f32"
},
propTypes: {
center: { value: [0.5, 0.5] },
radius: { value: 200, min: 1, softMax: 600 },
strength: { value: 0.5, min: -1, max: 1 }
},
passes: [{ sampler: true }]
};
// dist/passes/postprocessing/image-warp-filters/swirl.js
var source19 = (
/* wgsl */
`uniform swirlUniforms {
radius: f32,
angle: f32,
center: vec2f,
};
@group(0) @binding(1) swirl: swirlUniforms;
fn swirl_warp(vec2 coord, vec2 texCenter) -> vec2f {
coord -= texCenter;
float distance = length(coord);
if (distance < swirl.radius) {
float percent = (swirl.radius - distance) / swirl.radius;
float theta = percent * percent * swirl.angle;
float s = sin(theta);
float c = cos(theta);
coord = vec2(
coord.x * c - coord.y * s,
coord.x * s + coord.y * c
);
}
coord += texCenter;
return coord;
}
fn swirl_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord) -> vec4f {
vec2 coord = texCoord * texSize;
coord = swirl_warp(coord, swirl.center * texSize);
return warp_sampleColor(source, texSize, coord);
}
`
);
var fs19 = (
/* glsl */
`uniform swirlUniforms {
float radius;
float angle;
vec2 center;
} swirl;
vec2 swirl_warp(vec2 coord, vec2 texCenter) {
coord -= texCenter;
float distance = length(coord);
if (distance < swirl.radius) {
float percent = (swirl.radius - distance) / swirl.radius;
float theta = percent * percent * swirl.angle;
float s = sin(theta);
float c = cos(theta);
coord = vec2(
coord.x * c - coord.y * s,
coord.x * s + coord.y * c
);
}
coord += texCenter;
return coord;
}
vec4 swirl_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord) {
vec2 coord = texCoord * texSize;
coord = swirl_warp(coord, swirl.center * texSize);
return warp_sampleColor(source, texSize, coord);
}
`
);
var swirl = {
name: "swirl",
dependencies: [warp],
source: source19,
fs: fs19,
props: {},
uniforms: {},
uniformTypes: {
center: "vec2<f32>",
radius: "f32",
angle: "f32"
},
propTypes: {
center: { value: [0.5, 0.5] },
radius: { value: 200, min: 1, softMax: 600 },
angle: { value: 3, softMin: -25, softMax: 25 }
},
passes: [{ sampler: true }]
};
// dist/passes/postprocessing/fxaa/fxaa.js
var fs20 = (
/* glsl */
`
#define FXAA_QUALITY_PRESET 29
#if (FXAA_QUALITY_PRESET == 10)
#define FXAA_QUALITY_PS 3
#define FXAA_QUALITY_P0 1.5
#define FXAA_QUALITY_P1 3.0
#define FXAA_QUALITY_P2 12.0
#endif
#if (FXAA_QUALITY_PRESET == 11)
#define FXAA_QUALITY_PS 4
#define FXAA_QUALITY_P0 1.0
#define FXAA_QUALITY_P1 1.5
#define FXAA_QUALITY_P2 3.0
#define FXAA_QUALITY_P3 12.0
#endif
#if (FXAA_QUALITY_PRESET == 12)
#define FXAA_QUALITY_PS 5
#define FXAA_QUALITY_P0 1.0
#define FXAA_QUALITY_P1 1.5
#define FXAA_QUALITY_P2 2.0
#define FXAA_QUALITY_P3 4.0
#define FXAA_QUALITY_P4 12.0
#endif
#if (FXAA_QUALITY_PRESET == 13)
#define FXAA_QUALITY_PS 6
#define FXAA_QUALITY_P0 1.0
#define FXAA_QUALITY_P1 1.5
#define FXAA_QUALITY_P2 2.0
#define FXAA_QUALITY_P3 2.0
#define FXAA_QUALITY_P4 4.0
#define FXAA_QUALITY_P5 12.0
#endif
#if (FXAA_QUALITY_PRESET == 14)
#define FXAA_QUALITY_PS 7
#define FXAA_QUALITY_P0 1.0
#define FXAA_QUALITY_P1 1.5
#define FXAA_QUALITY_P2 2.0
#define FXAA_QUALITY_P3 2.0
#define FXAA_QUALITY_P4 2.0
#define FXAA_QUALITY_P5 4.0
#define FXAA_QUALITY_P6 12.0
#endif
#if (FXAA_QUALITY_PRESET == 15)
#define FXAA_QUALITY_PS 8
#define FXAA_QUALITY_P0 1.0
#define FXAA_QUALITY_P1 1.5
#define FXAA_QUALITY_P2 2.0
#define FXAA_QUALITY_P3 2.0
#define FXAA_QUALITY_P4 2.0
#define FXAA_QUALITY_P5 2.0
#define FXAA_QUALITY_P6 4.0
#define FXAA_QUALITY_P7 12.0
#endif
#if (FXAA_QUALITY_PRESET == 20)
#define FXAA_QUALITY_PS 3
#define FXAA_QUALITY_P0 1.5
#define FXAA_QUALITY_P1 2.0
#define FXAA_QUALITY_P2 8.0
#endif
#if (FXAA_QUALITY_PRESET == 21)
#define FXAA_QUALITY_PS 4
#define FXAA_QUALITY_P0 1.0
#define FXAA_QUALITY_P1 1.5
#define FXAA_QUALITY_P2 2.0
#define FXAA_QUALITY_P3 8.0
#endif
#if (FXAA_QUALITY_PRESET == 22)
#define FXAA_QUALITY_PS 5
#define FXAA_QUALITY_P0 1.0
#define FXAA_QUALITY_P1 1.5
#define FXAA_QUALITY_P2 2.0
#define FXAA_QUALITY_P3 2.0
#define FXAA_QUALITY_P4 8.0
#endif
#if (FXAA_QUALITY_PRESET == 23)
#define FXAA_QUALITY_PS 6
#define FXAA_QUALITY_P0 1.0
#define FXAA_QUALITY_P1 1.5
#define FXAA_QUALITY_P2 2.0
#define FXAA_QUALITY_P3 2.0
#define FXAA_QUALITY_P4 2.0
#define FXAA_QUALITY_P5 8.0
#endif
#if (FXAA_QUALITY_PRESET == 24)
#define FXAA_QUALITY_PS 7
#define FXAA_QUALITY_P0 1.0
#define FXAA_QUALITY_P1 1.5
#define FXAA_QUALITY_P2 2.0
#define FXAA_QUALITY_P3 2.0
#define FXAA_QUALITY_P4 2.0
#define FXAA_QUALITY_P5 3.0
#define FXAA_QUALITY_P6 8.0
#endif
#if (FXAA_QUALITY_PRESET == 25)
#define FXAA_QUALITY_PS 8
#define FXAA_QUALITY_P0 1.0
#define FXAA_QUALITY_P1 1.5
#define FXAA_QUALITY_P2 2.0
#define FXAA_QUALITY_P3 2.0
#define FXAA_QUALITY_P4 2.0
#define FXAA_QUALITY_P5 2.0
#define FXAA_QUALITY_P6 4.0
#define FXAA_QUALITY_P7 8.0
#endif
#if (FXAA_QUALITY_PRESET == 26)
#define FXAA_QUALITY_PS 9
#define FXAA_QUALITY_P0 1.0
#define FXAA_QUALITY_P1 1.5
#define FXAA_QUALITY_P2 2.0
#define FXAA_QUALITY_P3 2.0
#define FXAA_QUALITY_P4 2.0
#define FXAA_QUALITY_P5 2.0
#define FXAA_QUALITY_P6 2.0
#define FXAA_QUALITY_P7 4.0
#define FXAA_QUALITY_P8 8.0
#endif
#if (FXAA_QUALITY_PRESET == 27)
#define FXAA_QUALITY_PS 10
#define FXAA_QUALITY_P0 1.0
#define FXAA_QUALITY_P1 1.5
#define FXAA_QUALITY_P2 2.0
#define FXAA_QUALITY_P3 2.0
#define FXAA_QUALITY_P4 2.0
#define FXAA_QUALITY_P5 2.0
#define FXAA_QUALITY_P6 2.0
#define FXAA_QUALITY_P7 2.0
#define FXAA_QUALITY_P8 4.0
#define FXAA_QUALITY_P9 8.0
#endif
#if (FXAA_QUALITY_PRESET == 28)
#define FXAA_QUALITY_PS 11
#define FXAA_QUALITY_P0 1.0
#define FXAA_QUALITY_P1 1.5
#define FXAA_QUALITY_P2 2.0
#define FXAA_QUALITY_P3 2.0
#define FXAA_QUALITY_P4 2.0
#define FXAA_QUALITY_P5 2.0
#define FXAA_QUALITY_P6 2.0
#define FXAA_QUALITY_P7 2.0
#define FXAA_QUALITY_P8 2.0
#define FXAA_QUALITY_P9 4.0
#define FXAA_QUALITY_P10 8.0
#endif
#if (FXAA_QUALITY_PRESET == 29)
#define FXAA_QUALITY_PS 12
#define FXAA_QUALITY_P0 1.0
#define FXAA_QUALITY_P1 1.5
#define FXAA_QUALITY_P2 2.0
#define FXAA_QUALITY_P3 2.0
#define FXAA_QUALITY_P4 2.0
#define FXAA_QUALITY_P5 2.0
#define FXAA_QUALITY_P6 2.0
#define FXAA_QUALITY_P7 2.0
#define FXAA_QUALITY_P8 2.0
#define FXAA_QUALITY_P9 2.0
#define FXAA_QUALITY_P10 4.0
#define FXAA_QUALITY_P11 8.0
#endif
#if (FXAA_QUALITY_PRESET == 39)
#define FXAA_QUALITY_PS 12
#define FXAA_QUALITY_P0 1.0
#define FXAA_QUALITY_P1 1.0
#define FXAA_QUALITY_P2 1.0
#define FXAA_QUALITY_P3 1.0
#define FXAA_QUALITY_P4 1.0
#define FXAA_QUALITY_P5 1.5
#define FXAA_QUALITY_P6 2.0
#define FXAA_QUALITY_P7 2.0
#define FXAA_QUALITY_P8 2.0
#define FXAA_QUALITY_P9 2.0
#define FXAA_QUALITY_P10 4.0
#define FXAA_QUALITY_P11 8.0
#endif
#define FxaaBool bool
#define FxaaFloat float
#define FxaaFloat2 vec2
#define FxaaFloat3 vec3
#define FxaaFloat4 vec4
#define FxaaHalf float
#define FxaaHalf2 vec2
#define FxaaHalf3 vec3
#define FxaaHalf4 vec4
#define FxaaInt2 vec2
#define FxaaTex sampler2D
#define FxaaSat(x) clamp(x, 0.0, 1.0)
#define FxaaTexTop(t, p) texture(t, p)
#define FxaaTexOff(t, p, o, r) texture(t, p + (o * r))
FxaaFloat FxaaLuma_(FxaaFloat4 rgba) { return dot(rgba.rgb, vec3(0.2126, 0.7152, 0.0722)); }
FxaaFloat4 FxaaPixelShader_(
//
// Use noperspective interpolation here (turn off perspective interpolation).
// {xy} = center of pixel
FxaaFloat2 pos,
//
// Input color texture.
// {rgb_} = color in linear or perceptual color space
// if (FXAA_GREEN_AS_LUMA == 0)
// {___a} = luma in perceptual color space (not linear)
FxaaTex tex,
//
// Only used on FXAA Quality.
// This must be from a constant/uniform.
// {x_} = 1.0/screenWidthInPixels
// {_y} = 1.0/screenHeightInPixels
FxaaFloat2 fxaaQualityRcpFrame,
//
// Only used on FXAA Quality.
// This used to be the FXAA_QUALITY_SUBPIX define.
// It is here now to allow easier tuning.
// Choose the amount of sub-pixel aliasing removal.
// This can effect sharpness.
// 1.00 - upper limit (softer)
// 0.75 - default amount of filtering
// 0.50 - lower limit (sharper, less sub-pixel aliasing removal)
// 0.25 - almost off
// 0.00 - completely off
FxaaFloat fxaaQualitySubpix,
//
// Only used on FXAA Quality.
// This used to be the FXAA_QUALITY_EDGE_THRESHOLD define.
// It is here now to allow easier tuning.
// The minimum amount of local contrast required to apply algorithm.
// 0.333 - too little (faster)
// 0.250 - low quality
// 0.166 - default
// 0.125 - high quality
// 0.063 - overkill (slower)
FxaaFloat fxaaQualityEdgeThreshold,
//
// Only used on FXAA Quality.
// This used to be the FXAA_QUALITY_EDGE_THRESHOLD_MIN define.
// It is here now to allow easier tuning.
// Trims the algorithm from processing darks.
// 0.0833 - upper limit (default, the start of visible unfiltered edges)
// 0.0625 - high quality (faster)
// 0.0312 - visible limit (slower)
// Special notes when using FXAA_GREEN_AS_LUMA,
// Likely want to set this to zero.
// As colors that are mostly not-green
// will appear very dark in the green channel!
// Tune by looking at mostly non-green content,
// then start at zero and increase until aliasing is a problem.
FxaaFloat fxaaQualityEdgeThresholdMin
) {
/*--------------