@luma.gl/effects
Version:
Post-processing effects for luma.gl
41 lines • 3.32 kB
TypeScript
/**
* Ink -
* Simulates outlining the image in ink by darkening edges stronger than a
* certain threshold. The edge detection value is the difference of two
* copies of the image, each blurred using a blur of a different radius.
*/
export type InkProps = {
/** The multiplicative scale of the ink edges.
* Values in the range 0 to 1 are usually sufficient, where 0 doesn't change the image and 1 adds lots of black edges.
* Negative strength values will create white ink edges instead of black ones.
*/
strength?: number;
};
export type InkUniforms = InkProps;
/**
* Ink -
* Simulates outlining the image in ink by darkening edges stronger than a
* certain threshold. The edge detection value is the difference of two
* copies of the image, each blurred using a blur of a different radius.
*/
export declare const ink: {
readonly name: "ink";
readonly source: "uniform inkUniforms {\n strength: f32,\n};\n\n@group(0) @binding(1) var<uniform> ink: inkUniforms;\n\nfn ink_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord) -> vec4f {\n vec2 dx = vec2(1.0 / texSize.x, 0.0);\n vec2 dy = vec2(0.0, 1.0 / texSize.y);\n vec4 color = texture(source, texCoord);\n float bigTotal = 0.0;\n float smallTotal = 0.0;\n vec3 bigAverage = vec3(0.0);\n vec3 smallAverage = vec3(0.0);\n for (float x = -2.0; x <= 2.0; x += 1.0) {\n for (float y = -2.0; y <= 2.0; y += 1.0) {\n vec3 offsetColor = texture(source, texCoord + dx * x + dy * y).rgb;\n bigAverage += offsetColor;\n bigTotal += 1.0;\n if (abs(x) + abs(y) < 2.0) {\n smallAverage += offsetColor;\n smallTotal += 1.0;\n }\n }\n }\n vec3 edge = max(vec3(0.0), bigAverage / bigTotal - smallAverage / smallTotal);\n float power = ink.strength * ink.strength * ink.strength * ink.strength * ink.strength;\n return vec4(color.rgb - dot(edge, edge) * power * 100000.0, color.a);\n}\n";
readonly fs: "uniform inkUniforms {\n float strength;\n} ink;\n\nvec4 ink_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord) {\n vec2 dx = vec2(1.0 / texSize.x, 0.0);\n vec2 dy = vec2(0.0, 1.0 / texSize.y);\n vec4 color = texture(source, texCoord);\n float bigTotal = 0.0;\n float smallTotal = 0.0;\n vec3 bigAverage = vec3(0.0);\n vec3 smallAverage = vec3(0.0);\n for (float x = -2.0; x <= 2.0; x += 1.0) {\n for (float y = -2.0; y <= 2.0; y += 1.0) {\n vec3 offsetColor = texture(source, texCoord + dx * x + dy * y).rgb;\n bigAverage += offsetColor;\n bigTotal += 1.0;\n if (abs(x) + abs(y) < 2.0) {\n smallAverage += offsetColor;\n smallTotal += 1.0;\n }\n }\n }\n vec3 edge = max(vec3(0.0), bigAverage / bigTotal - smallAverage / smallTotal);\n float power = ink.strength * ink.strength * ink.strength * ink.strength * ink.strength;\n return vec4(color.rgb - dot(edge, edge) * power * 100000.0, color.a);\n}\n";
readonly props: InkProps;
readonly uniforms: InkUniforms;
readonly uniformTypes: {
readonly strength: "f32";
};
readonly propTypes: {
readonly strength: {
readonly value: 0.25;
readonly min: 0;
readonly softMax: 1;
};
};
readonly passes: [{
readonly sampler: true;
}];
};
//# sourceMappingURL=ink.d.ts.map