/** * Tilt Shift * Simulates the shallow depth of field normally encountered in close-up photography */ export type TiltShiftProps = { /** The x,y coordinate of the start of the line segment. */ start?: [number, number]; /** The xm y coordinate of the end of the line segment. */ end?: [number, number]; /** The maximum radius of the pyramid blur. */ blurRadius?: number; /** The distance from the line at which the maximum blur radius is reached. */ gradientRadius?: number; /** @deprecated internal shaderpass use */ invert?: number; }; export type TiltShiftUniforms = TiltShiftProps; /** * Tilt Shift * Simulates the shallow depth of field normally encountered in close-up * photography, which makes the scene seem much smaller than it actually * is. This filter assumes the scene is relatively planar, in which case * the part of the scene that is completely in focus can be described by * a line (the intersection of the focal plane and the scene). An example * of a planar scene might be looking at a road from above at a downward * angle. The image is then blurred with a blur radius that starts at zero * on the line and increases further from the line. */ export declare const tiltShift: { readonly name: "tiltShift"; readonly dependencies: [{ readonly name: "random"; readonly source: "fn random(scale: vec3f, seed: float) -> f32 {\n /* use the fragment position for a different seed per-pixel */\n return fract(sin(dot(gl_FragCoord.xyz + seed, scale)) * 43758.5453 + seed);\n}\n"; readonly fs: "float random(vec3 scale, float seed) {\n /* use the fragment position for a different seed per-pixel */\n return fract(sin(dot(gl_FragCoord.xyz + seed, scale)) * 43758.5453 + seed);\n}\n"; }]; readonly source: "uniform tiltShiftUniforms {\n blurRadius: f32,\n gradientRadius: f32,\n start: vec2f,\n end: vec2f,\n invert: u32,\n};\n\n@group(0) @binding(1) var tiltShift: tiltShiftUniforms;\n\nfn tiltShift_getDelta(vec2 texSize) -> vec2f {\n vec2 vector = normalize((tiltShift.end - tiltShift.start) * texSize);\n return tiltShift.invert ? vec2(-vector.y, vector.x) : vector;\n}\n\nfn tiltShift_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord) -> vec4f {\n vec4 color = vec4(0.0);\n float total = 0.0;\n\n /* randomize the lookup values to hide the fixed number of samples */\n float offset = random(vec3(12.9898, 78.233, 151.7182), 0.0);\n\n vec2 normal = normalize(vec2((tiltShift.start.y - tiltShift.end.y) * texSize.y, (tiltShift.end.x - tiltShift.start.x) * texSize.x));\n float radius = smoothstep(0.0, 1.0,\n abs(dot(texCoord * texSize - tiltShift.start * texSize, normal)) / tiltShift.gradientRadius) * tiltShift.blurRadius;\n\n for (float t = -30.0; t <= 30.0; t++) {\n float percent = (t + offset - 0.5) / 30.0;\n float weight = 1.0 - abs(percent);\n vec4 offsetColor = texture(source, texCoord + tiltShift_getDelta(texSize) / texSize * percent * radius);\n\n color += offsetColor * weight;\n total += weight;\n }\n\n color = color / total;\n return color;\n}\n"; readonly fs: "uniform tiltShiftUniforms {\n float blurRadius;\n float gradientRadius;\n vec2 start;\n vec2 end;\n bool invert;\n} tiltShift;\n\nvec2 tiltShift_getDelta(vec2 texSize) {\n vec2 vector = normalize((tiltShift.end - tiltShift.start) * texSize);\n return tiltShift.invert ? vec2(-vector.y, vector.x) : vector;\n}\n\nvec4 tiltShift_sampleColor(sampler2D source, vec2 texSize, vec2 texCoord) {\n vec4 color = vec4(0.0);\n float total = 0.0;\n\n /* randomize the lookup values to hide the fixed number of samples */\n float offset = random(vec3(12.9898, 78.233, 151.7182), 0.0);\n\n vec2 normal = normalize(vec2((tiltShift.start.y - tiltShift.end.y) * texSize.y, (tiltShift.end.x - tiltShift.start.x) * texSize.x));\n float radius = smoothstep(0.0, 1.0,\n abs(dot(texCoord * texSize - tiltShift.start * texSize, normal)) / tiltShift.gradientRadius) * tiltShift.blurRadius;\n\n for (float t = -30.0; t <= 30.0; t++) {\n float percent = (t + offset - 0.5) / 30.0;\n float weight = 1.0 - abs(percent);\n vec4 offsetColor = texture(source, texCoord + tiltShift_getDelta(texSize) / texSize * percent * radius);\n color += offsetColor * weight;\n total += weight;\n }\n\n color = color / total;\n return color;\n}\n"; readonly props: TiltShiftProps; readonly uniforms: TiltShiftUniforms; readonly uniformTypes: { readonly blurRadius: "f32"; readonly gradientRadius: "f32"; readonly start: "vec2"; readonly end: "vec2"; readonly invert: "i32"; }; readonly propTypes: { readonly blurRadius: { readonly value: 15; readonly min: 0; readonly max: 50; }; readonly gradientRadius: { readonly value: 200; readonly min: 0; readonly max: 400; }; readonly start: { readonly value: readonly [0, 0]; }; readonly end: { readonly value: readonly [1, 1]; }; readonly invert: { readonly value: 0; readonly private: true; }; }; readonly passes: [{ readonly sampler: true; readonly uniforms: { readonly invert: 0; }; }, { readonly sampler: true; readonly uniforms: { readonly invert: 1; }; }]; }; //# sourceMappingURL=tiltshift.d.ts.map