1 line
14 KiB
Plaintext
1 line
14 KiB
Plaintext
|
|
{"version":3,"file":"BokehShader2.cjs","sources":["../../src/shaders/BokehShader2.ts"],"sourcesContent":["import { IUniform, Texture, Vector2 } from 'three'\n\nexport interface BokehShader2Uniforms {\n textureWidth: IUniform<number>\n textureHeight: IUniform<number>\n\n focalDepth: IUniform<number>\n focalLength: IUniform<number>\n fstop: IUniform<number>\n\n tColor: IUniform<Texture | null>\n tDepth: IUniform<Texture | null>\n\n maxblur: IUniform<number>\n\n showFocus: IUniform<number>\n manualdof: IUniform<number>\n vignetting: IUniform<number>\n depthblur: IUniform<number>\n\n threshold: IUniform<number>\n gain: IUniform<number>\n bias: IUniform<number>\n fringe: IUniform<number>\n\n znear: IUniform<number>\n zfar: IUniform<number>\n\n noise: IUniform<number>\n dithering: IUniform<number>\n pentagon: IUniform<number>\n\n shaderFocus: IUniform<number>\n focusCoords: IUniform<Vector2>\n}\n\n/**\n * Depth-of-field shader with bokeh\n * ported from GLSL shader by Martins Upitis\n * http://blenderartists.org/forum/showthread.php?237488-GLSL-depth-of-field-with-bokeh-v2-4-(update)\n *\n * Requires #define RINGS and SAMPLES integers\n */\n\nexport const BokehShader2: {\n uniforms: BokehShader2Uniforms\n vertexShader: string\n fragmentShader: string\n} = {\n uniforms: {\n textureWidth: { value: 1.0 },\n textureHeight: { value: 1.0 },\n\n focalDepth: { value: 1.0 },\n focalLength: { value: 24.0 },\n fstop: { value: 0.9 },\n\n tColor: { value: null },\n tDepth: { value: null },\n\n maxblur: { value: 1.0 },\n\n showFocus: { value: 0 },\n manualdof: { value: 0 },\n vignetting: { value: 0 },\n depthblur: { value: 0 },\n\n threshold: { value: 0.5 },\n gain: { value: 2.0 },\n bias: { value: 0.5 },\n fringe: { value: 0.7 },\n\n znear: { value: 0.1 },\n zfar: { value: 100 },\n\n noise: { value: 1 },\n dithering: { value: 0.0001 },\n pentagon: { value: 0 },\n\n shaderFocus: { value: 1 },\n focusCoords: { value: /* @__PURE__ */ new Vector2() },\n },\n\n vertexShader: /* glsl */ `\n varying vec2 vUv;\n\n void main() {\n\n \tvUv = uv;\n \tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\n }\n `,\n\n fragmentShader: /* glsl */ `\n #include <common>\n\n varying vec2 vUv;\n\n uniform sampler2D tColor;\n uniform sampler2D tDepth;\n uniform float textureWidth;\n uniform float textureHeight;\n\n uniform float focalDepth; //focal distance value in meters, but you may use autofocus option below\n uniform float focalLength; //focal length in mm\n uniform float fstop; //f-stop value\n uniform bool showFocus; //show debug focus point and focal range (red = focal point, green = focal range)\n\n /*\n make sure that these two values are the same for your camera, otherwise distances will be wrong.\n */\n\n uniform float znear; // camera clipping start\n uniform float zfar; // camera clipping end\n\n //------------------------------------------\n //user variables\n\n const int samples = SAMPLES; //samples on the first ring\n const int rings = RINGS; //ring count\n\n const int maxringsamples = rings * samples;\n\n uniform bool manualdof; // manual dof calculation\n float ndofstart = 1.0; // near dof blur start\n float ndofdist = 2.0; // near dof blur falloff distance\n float fdofstart = 1.0; // far dof blur start\n float fdofdist = 3.0; // far dof blur falloff distance\n\n float CoC = 0.03; //circle of confusion size in mm (35mm film = 0.03mm)\n\n uniform bool vignetting; // use optical lens vignetting\n\n float vignout = 1.3; // vignetting outer border\n float vignin = 0.0; // vignetting inner border\n float vignfade = 22.0; // f-stops till vignete fades\n\n uniform bool shaderFocus;\n // disable if you use external focalDepth value\n\n uniform vec2 focusCoords;\n // autofocus point on screen (0.0,0.0 - left lower corner, 1.0,1.0 - upper right)\n // if center of screen use vec2(0.5, 0.5);\n\n uniform float
|