three-stdlib 2.8.11 → 2.8.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.cjs.js +1 -1
- package/index.d.ts +1 -52
- package/index.js +52 -52
- package/lines/LineMaterial.d.ts +7 -6
- package/modifiers/CurveModifier.cjs.js +1 -1
- package/modifiers/CurveModifier.d.ts +13 -9
- package/modifiers/CurveModifier.js +27 -30
- package/objects/Lensflare.cjs.js +1 -1
- package/objects/Lensflare.js +11 -3
- package/package.json +2 -2
- package/postprocessing/AfterimagePass.d.ts +2 -30
- package/shaders/ACESFilmicToneMappingShader.cjs.js +1 -1
- package/shaders/ACESFilmicToneMappingShader.d.ts +9 -0
- package/shaders/ACESFilmicToneMappingShader.js +1 -1
- package/shaders/AfterimageShader.d.ts +9 -15
- package/shaders/BasicShader.cjs.js +1 -1
- package/shaders/BasicShader.d.ts +5 -5
- package/shaders/BasicShader.js +1 -1
- package/shaders/BleachBypassShader.cjs.js +1 -1
- package/shaders/BleachBypassShader.d.ts +8 -9
- package/shaders/BleachBypassShader.js +1 -1
- package/shaders/BlendShader.cjs.js +1 -1
- package/shaders/BlendShader.d.ts +13 -7
- package/shaders/BlendShader.js +1 -1
- package/shaders/BokehShader.cjs.js +1 -1
- package/shaders/BokehShader.d.ts +18 -19
- package/shaders/BokehShader.js +1 -1
- package/shaders/BokehShader2.cjs.js +1 -1
- package/shaders/BokehShader2.d.ts +80 -34
- package/shaders/BokehShader2.js +2 -2
- package/shaders/BrightnessContrastShader.cjs.js +1 -1
- package/shaders/BrightnessContrastShader.d.ts +10 -6
- package/shaders/BrightnessContrastShader.js +1 -1
- package/shaders/ColorCorrectionShader.cjs.js +1 -1
- package/shaders/ColorCorrectionShader.d.ts +14 -7
- package/shaders/ColorCorrectionShader.js +1 -1
- package/shaders/ColorifyShader.cjs.js +1 -1
- package/shaders/ColorifyShader.d.ts +8 -5
- package/shaders/ColorifyShader.js +1 -1
- package/shaders/ConvolutionShader.cjs.js +1 -1
- package/shaders/ConvolutionShader.d.ts +15 -16
- package/shaders/ConvolutionShader.js +9 -14
- package/shaders/CopyShader.d.ts +8 -12
- package/shaders/DOFMipMapShader.cjs.js +1 -1
- package/shaders/DOFMipMapShader.d.ts +13 -7
- package/shaders/DOFMipMapShader.js +1 -1
- package/shaders/DepthLimitedBlurShader.cjs.js +1 -1
- package/shaders/DepthLimitedBlurShader.d.ts +26 -25
- package/shaders/DepthLimitedBlurShader.js +12 -16
- package/shaders/DigitalGlitch.cjs.js +1 -1
- package/shaders/DigitalGlitch.d.ts +34 -14
- package/shaders/DigitalGlitch.js +1 -10
- package/shaders/DotScreenShader.cjs.js +1 -1
- package/shaders/DotScreenShader.d.ts +17 -8
- package/shaders/DotScreenShader.js +1 -1
- package/shaders/FXAAShader.cjs.js +1 -1
- package/shaders/FXAAShader.d.ts +8 -5
- package/shaders/FXAAShader.js +1 -1
- package/shaders/FilmShader.cjs.js +1 -1
- package/shaders/FilmShader.d.ts +19 -9
- package/shaders/FilmShader.js +1 -1
- package/shaders/FocusShader.cjs.js +1 -1
- package/shaders/FocusShader.d.ts +16 -8
- package/shaders/FocusShader.js +1 -1
- package/shaders/FreiChenShader.cjs.js +1 -1
- package/shaders/FreiChenShader.d.ts +8 -5
- package/shaders/FreiChenShader.js +1 -1
- package/shaders/FresnelShader.cjs.js +1 -1
- package/shaders/FresnelShader.d.ts +21 -0
- package/shaders/FresnelShader.js +1 -1
- package/shaders/GammaCorrectionShader.d.ts +7 -7
- package/shaders/GodRaysShader.cjs.js +1 -1
- package/shaders/GodRaysShader.d.ts +38 -20
- package/shaders/GodRaysShader.js +4 -4
- package/shaders/HalftoneShader.cjs.js +1 -1
- package/shaders/HalftoneShader.d.ts +40 -16
- package/shaders/HalftoneShader.js +1 -1
- package/shaders/HorizontalBlurShader.d.ts +8 -8
- package/shaders/HorizontalTiltShiftShader.cjs.js +1 -1
- package/shaders/HorizontalTiltShiftShader.d.ts +10 -6
- package/shaders/HorizontalTiltShiftShader.js +1 -1
- package/shaders/HueSaturationShader.cjs.js +1 -1
- package/shaders/HueSaturationShader.d.ts +10 -6
- package/shaders/HueSaturationShader.js +1 -1
- package/shaders/KaleidoShader.cjs.js +1 -1
- package/shaders/KaleidoShader.d.ts +10 -6
- package/shaders/KaleidoShader.js +1 -1
- package/shaders/LuminosityHighPassShader.cjs.js +1 -1
- package/shaders/LuminosityHighPassShader.d.ts +17 -8
- package/shaders/LuminosityHighPassShader.js +1 -1
- package/shaders/LuminosityShader.cjs.js +1 -1
- package/shaders/LuminosityShader.d.ts +4 -4
- package/shaders/LuminosityShader.js +1 -1
- package/shaders/MirrorShader.cjs.js +1 -1
- package/shaders/MirrorShader.d.ts +7 -5
- package/shaders/MirrorShader.js +1 -1
- package/shaders/NormalMapShader.cjs.js +1 -1
- package/shaders/NormalMapShader.d.ts +14 -7
- package/shaders/NormalMapShader.js +1 -1
- package/shaders/ParallaxShader.cjs.js +1 -1
- package/shaders/ParallaxShader.d.ts +28 -0
- package/shaders/ParallaxShader.js +1 -1
- package/shaders/PixelShader.cjs.js +1 -1
- package/shaders/PixelShader.d.ts +10 -6
- package/shaders/PixelShader.js +1 -1
- package/shaders/RGBShiftShader.cjs.js +1 -1
- package/shaders/RGBShiftShader.d.ts +10 -6
- package/shaders/RGBShiftShader.js +1 -1
- package/shaders/SAOShader.cjs.js +1 -1
- package/shaders/SAOShader.d.ts +24 -29
- package/shaders/SAOShader.js +1 -5
- package/shaders/SMAAShader.cjs.js +1 -1
- package/shaders/SMAAShader.d.ts +31 -16
- package/shaders/SMAAShader.js +3 -3
- package/shaders/SSAOShader.cjs.js +1 -1
- package/shaders/SSAOShader.d.ts +58 -25
- package/shaders/SSAOShader.js +3 -3
- package/shaders/SSRShader.cjs.js +1 -1
- package/shaders/SSRShader.d.ts +67 -36
- package/shaders/SSRShader.js +3 -3
- package/shaders/SepiaShader.cjs.js +1 -1
- package/shaders/SepiaShader.d.ts +7 -5
- package/shaders/SepiaShader.js +1 -1
- package/shaders/SobelOperatorShader.cjs.js +1 -1
- package/shaders/SobelOperatorShader.d.ts +8 -5
- package/shaders/SobelOperatorShader.js +1 -1
- package/shaders/SubsurfaceScatteringShader.cjs.js +1 -1
- package/shaders/SubsurfaceScatteringShader.d.ts +2 -34
- package/shaders/SubsurfaceScatteringShader.js +3 -3
- package/shaders/TechnicolorShader.cjs.js +1 -1
- package/shaders/TechnicolorShader.d.ts +4 -4
- package/shaders/TechnicolorShader.js +1 -1
- package/shaders/ToneMapShader.cjs.js +1 -1
- package/shaders/ToneMapShader.d.ts +19 -9
- package/shaders/ToneMapShader.js +1 -1
- package/shaders/ToonShader.cjs.js +1 -1
- package/shaders/ToonShader.d.ts +80 -34
- package/shaders/ToonShader.js +4 -4
- package/shaders/TriangleBlurShader.cjs.js +1 -1
- package/shaders/TriangleBlurShader.d.ts +8 -5
- package/shaders/TriangleBlurShader.js +1 -1
- package/shaders/UnpackDepthRGBAShader.cjs.js +1 -1
- package/shaders/UnpackDepthRGBAShader.d.ts +7 -5
- package/shaders/UnpackDepthRGBAShader.js +1 -1
- package/shaders/VerticalBlurShader.cjs.js +1 -1
- package/shaders/VerticalBlurShader.d.ts +8 -8
- package/shaders/VerticalBlurShader.js +1 -1
- package/shaders/VerticalTiltShiftShader.cjs.js +1 -1
- package/shaders/VerticalTiltShiftShader.d.ts +10 -6
- package/shaders/VerticalTiltShiftShader.js +1 -1
- package/shaders/VignetteShader.cjs.js +1 -1
- package/shaders/VignetteShader.d.ts +10 -6
- package/shaders/VignetteShader.js +1 -1
- package/shaders/VolumeShader.cjs.js +1 -1
- package/shaders/VolumeShader.d.ts +20 -9
- package/shaders/VolumeShader.js +1 -1
- package/shaders/WaterRefractionShader.cjs.js +1 -1
- package/shaders/WaterRefractionShader.d.ts +16 -8
- package/shaders/WaterRefractionShader.js +1 -1
- package/shaders/index.cjs.js +1 -0
- package/shaders/index.d.ts +53 -0
- package/shaders/index.js +53 -0
- package/shaders/types.cjs.js +1 -0
- package/shaders/types.d.ts +14 -0
- package/shaders/types.js +1 -0
- package/types/shared.d.ts +0 -20
@@ -1 +1 @@
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});const t={defines:{DEPTH_PACKING:1,PERSPECTIVE_CAMERA:1},uniforms:{tColor:{value:null},tDepth:{value:null},focus:{value:1},aspect:{value:1},aperture:{value:.025},maxblur:{value:.01},nearClip:{value:1},farClip:{value:1e3}},vertexShader:["varying vec2 vUv;","void main() {","\tvUv = uv;","\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","}"].join("\n"),fragmentShader:["#include <common>","varying vec2 vUv;","uniform sampler2D tColor;","uniform sampler2D tDepth;","uniform float maxblur;","uniform float aperture;","uniform float nearClip;","uniform float farClip;","uniform float focus;","uniform float aspect;","#include <packing>","float getDepth( const in vec2 screenPosition ) {","\t#if DEPTH_PACKING == 1","\treturn unpackRGBAToDepth( texture2D( tDepth, screenPosition ) );","\t#else","\treturn texture2D( tDepth, screenPosition ).x;","\t#endif","}","float getViewZ( const in float depth ) {","\t#if PERSPECTIVE_CAMERA == 1","\treturn perspectiveDepthToViewZ( depth, nearClip, farClip );","\t#else","\treturn orthographicDepthToViewZ( depth, nearClip, farClip );","\t#endif","}","void main() {","\tvec2 aspectcorrect = vec2( 1.0, aspect );","\tfloat viewZ = getViewZ( getDepth( vUv ) );","\tfloat factor = ( focus + viewZ );","\tvec2 dofblur = vec2 ( clamp( factor * aperture, -maxblur, maxblur ) );","\tvec2 dofblur9 = dofblur * 0.9;","\tvec2 dofblur7 = dofblur * 0.7;","\tvec2 dofblur4 = dofblur * 0.4;","\tvec4 col = vec4( 0.0 );","\tcol += texture2D( tColor, vUv.xy );","\tcol += texture2D( tColor, vUv.xy + ( vec2( 0.0, 0.4 ) * aspectcorrect ) * dofblur );","\tcol += texture2D( tColor, vUv.xy + ( vec2( 0.15, 0.37 ) * aspectcorrect ) * dofblur );","\tcol += texture2D( tColor, vUv.xy + ( vec2( 0.29, 0.29 ) * aspectcorrect ) * dofblur );","\tcol += texture2D( tColor, vUv.xy + ( vec2( -0.37, 0.15 ) * aspectcorrect ) * dofblur );","\tcol += texture2D( tColor, vUv.xy + ( vec2( 0.40, 0.0 ) * aspectcorrect ) * dofblur );","\tcol += texture2D( tColor, vUv.xy + ( vec2( 0.37, -0.15 ) * aspectcorrect ) * dofblur );","\tcol += texture2D( tColor, vUv.xy + ( vec2( 0.29, -0.29 ) * aspectcorrect ) * dofblur );","\tcol += texture2D( tColor, vUv.xy + ( vec2( -0.15, -0.37 ) * aspectcorrect ) * dofblur );","\tcol += texture2D( tColor, vUv.xy + ( vec2( 0.0, -0.4 ) * aspectcorrect ) * dofblur );","\tcol += texture2D( tColor, vUv.xy + ( vec2( -0.15, 0.37 ) * aspectcorrect ) * dofblur );","\tcol += texture2D( tColor, vUv.xy + ( vec2( -0.29, 0.29 ) * aspectcorrect ) * dofblur );","\tcol += texture2D( tColor, vUv.xy + ( vec2( 0.37, 0.15 ) * aspectcorrect ) * dofblur );","\tcol += texture2D( tColor, vUv.xy + ( vec2( -0.4, 0.0 ) * aspectcorrect ) * dofblur );","\tcol += texture2D( tColor, vUv.xy + ( vec2( -0.37, -0.15 ) * aspectcorrect ) * dofblur );","\tcol += texture2D( tColor, vUv.xy + ( vec2( -0.29, -0.29 ) * aspectcorrect ) * dofblur );","\tcol += texture2D( tColor, vUv.xy + ( vec2( 0.15, -0.37 ) * aspectcorrect ) * dofblur );","\tcol += texture2D( tColor, vUv.xy + ( vec2( 0.15, 0.37 ) * aspectcorrect ) * dofblur9 );","\tcol += texture2D( tColor, vUv.xy + ( vec2( -0.37, 0.15 ) * aspectcorrect ) * dofblur9 );","\tcol += texture2D( tColor, vUv.xy + ( vec2( 0.37, -0.15 ) * aspectcorrect ) * dofblur9 );","\tcol += texture2D( tColor, vUv.xy + ( vec2( -0.15, -0.37 ) * aspectcorrect ) * dofblur9 );","\tcol += texture2D( tColor, vUv.xy + ( vec2( -0.15, 0.37 ) * aspectcorrect ) * dofblur9 );","\tcol += texture2D( tColor, vUv.xy + ( vec2( 0.37, 0.15 ) * aspectcorrect ) * dofblur9 );","\tcol += texture2D( tColor, vUv.xy + ( vec2( -0.37, -0.15 ) * aspectcorrect ) * dofblur9 );","\tcol += texture2D( tColor, vUv.xy + ( vec2( 0.15, -0.37 ) * aspectcorrect ) * dofblur9 );","\tcol += texture2D( tColor, vUv.xy + ( vec2( 0.29, 0.29 ) * aspectcorrect ) * dofblur7 );","\tcol += texture2D( tColor, vUv.xy + ( vec2( 0.40, 0.0 ) * aspectcorrect ) * dofblur7 );","\tcol += texture2D( tColor, vUv.xy + ( vec2( 0.29, -0.29 ) * aspectcorrect ) * dofblur7 );","\tcol += texture2D( tColor, vUv.xy + ( vec2( 0.0, -0.4 ) * aspectcorrect ) * dofblur7 );","\tcol += texture2D( tColor, vUv.xy + ( vec2( -0.29, 0.29 ) * aspectcorrect ) * dofblur7 );","\tcol += texture2D( tColor, vUv.xy + ( vec2( -0.4, 0.0 ) * aspectcorrect ) * dofblur7 );","\tcol += texture2D( tColor, vUv.xy + ( vec2( -0.29, -0.29 ) * aspectcorrect ) * dofblur7 );","\tcol += texture2D( tColor, vUv.xy + ( vec2( 0.0, 0.4 ) * aspectcorrect ) * dofblur7 );","\tcol += texture2D( tColor, vUv.xy + ( vec2( 0.29, 0.29 ) * aspectcorrect ) * dofblur4 );","\tcol += texture2D( tColor, vUv.xy + ( vec2( 0.4, 0.0 ) * aspectcorrect ) * dofblur4 );","\tcol += texture2D( tColor, vUv.xy + ( vec2( 0.29, -0.29 ) * aspectcorrect ) * dofblur4 );","\tcol += texture2D( tColor, vUv.xy + ( vec2( 0.0, -0.4 ) * aspectcorrect ) * dofblur4 );","\tcol += texture2D( tColor, vUv.xy + ( vec2( -0.29, 0.29 ) * aspectcorrect ) * dofblur4 );","\tcol += texture2D( tColor, vUv.xy + ( vec2( -0.4, 0.0 ) * aspectcorrect ) * dofblur4 );","\tcol += texture2D( tColor, vUv.xy + ( vec2( -0.29, -0.29 ) * aspectcorrect ) * dofblur4 );","\tcol += texture2D( tColor, vUv.xy + ( vec2( 0.0, 0.4 ) * aspectcorrect ) * dofblur4 );","\tgl_FragColor = col / 41.0;","\tgl_FragColor.a = 1.0;","}"].join("\n")};exports.BokehShader=t;
|
package/shaders/BokehShader.d.ts
CHANGED
@@ -1,20 +1,19 @@
|
|
1
|
-
import {
|
2
|
-
|
3
|
-
export
|
4
|
-
|
5
|
-
|
6
|
-
PERSPECTIVE_CAMERA: number;
|
7
|
-
};
|
8
|
-
uniforms: {
|
9
|
-
tColor: Uniform;
|
10
|
-
tDepth: Uniform;
|
11
|
-
focus: Uniform;
|
12
|
-
aspect: Uniform;
|
13
|
-
aperture: Uniform;
|
14
|
-
maxblur: Uniform;
|
15
|
-
nearClip: Uniform;
|
16
|
-
farClip: Uniform;
|
17
|
-
};
|
18
|
-
vertexShader: string;
|
19
|
-
fragmentShader: string;
|
1
|
+
import type { IUniform, Texture } from 'three';
|
2
|
+
import type { IShader } from './types';
|
3
|
+
export declare type BokehShaderDefines = {
|
4
|
+
DEPTH_PACKING: number;
|
5
|
+
PERSPECTIVE_CAMERA: number;
|
20
6
|
};
|
7
|
+
export declare type BokehShaderUniforms = {
|
8
|
+
aperture: IUniform<number>;
|
9
|
+
aspect: IUniform<number>;
|
10
|
+
farClip: IUniform<number>;
|
11
|
+
focus: IUniform<number>;
|
12
|
+
maxblur: IUniform<number>;
|
13
|
+
nearClip: IUniform<number>;
|
14
|
+
tColor: IUniform<Texture | null>;
|
15
|
+
tDepth: IUniform<Texture | null>;
|
16
|
+
};
|
17
|
+
export interface IBokehShader extends IShader<BokehShaderUniforms, BokehShaderDefines> {
|
18
|
+
}
|
19
|
+
export declare const BokehShader: IBokehShader;
|
package/shaders/BokehShader.js
CHANGED
@@ -1 +1 @@
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});const t={uniforms:{textureWidth:{value:1},textureHeight:{value:1},focalDepth:{value:1},focalLength:{value:24},fstop:{value:.9},tColor:{value:null},tDepth:{value:null},maxblur:{value:1},showFocus:{value:0},manualdof:{value:0},vignetting:{value:0},depthblur:{value:0},threshold:{value:.5},gain:{value:2},bias:{value:.5},fringe:{value:.7},znear:{value:.1},zfar:{value:100},noise:{value:1},dithering:{value:1e-4},pentagon:{value:0},shaderFocus:{value:1},focusCoords:{value:new(require("three").Vector2)}},vertexShader:["varying vec2 vUv;","void main() {","\tvUv = uv;","\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","}"].join("\n"),fragmentShader:["#include <common>","varying vec2 vUv;","uniform sampler2D tColor;","uniform sampler2D tDepth;","uniform float textureWidth;","uniform float textureHeight;","uniform float focalDepth; //focal distance value in meters, but you may use autofocus option below","uniform float focalLength; //focal length in mm","uniform float fstop; //f-stop value","uniform bool showFocus; //show debug focus point and focal range (red = focal point, green = focal range)","/*","make sure that these two values are the same for your camera, otherwise distances will be wrong.","*/","uniform float znear; // camera clipping start","uniform float zfar; // camera clipping end","//------------------------------------------","//user variables","const int samples = SAMPLES; //samples on the first ring","const int rings = RINGS; //ring count","const int maxringsamples = rings * samples;","uniform bool manualdof; // manual dof calculation","float ndofstart = 1.0; // near dof blur start","float ndofdist = 2.0; // near dof blur falloff distance","float fdofstart = 1.0; // far dof blur start","float fdofdist = 3.0; // far dof blur falloff distance","float CoC = 0.03; //circle of confusion size in mm (35mm film = 0.03mm)","uniform bool vignetting; // use optical lens vignetting","float vignout = 1.3; // vignetting outer border","float vignin = 0.0; // vignetting inner border","float vignfade = 22.0; // f-stops till vignete fades","uniform bool shaderFocus;","// disable if you use external focalDepth value","uniform vec2 focusCoords;","// autofocus point on screen (0.0,0.0 - left lower corner, 1.0,1.0 - upper right)","// if center of screen use vec2(0.5, 0.5);","uniform float maxblur;","//clamp value of max blur (0.0 = no blur, 1.0 default)","uniform float threshold; // highlight threshold;","uniform float gain; // highlight gain;","uniform float bias; // bokeh edge bias","uniform float fringe; // bokeh chromatic aberration / fringing","uniform bool noise; //use noise instead of pattern for sample dithering","uniform float dithering;","uniform bool depthblur; // blur the depth buffer","float dbsize = 1.25; // depth blur size","/*","next part is experimental","not looking good with small sample and ring count","looks okay starting from samples = 4, rings = 4","*/","uniform bool pentagon; //use pentagon as bokeh shape?","float feather = 0.4; //pentagon shape feather","//------------------------------------------","float penta(vec2 coords) {","\t//pentagonal shape","\tfloat scale = float(rings) - 1.3;","\tvec4 HS0 = vec4( 1.0, 0.0, 0.0, 1.0);","\tvec4 HS1 = vec4( 0.309016994, 0.951056516, 0.0, 1.0);","\tvec4 HS2 = vec4(-0.809016994, 0.587785252, 0.0, 1.0);","\tvec4 HS3 = vec4(-0.809016994,-0.587785252, 0.0, 1.0);","\tvec4 HS4 = vec4( 0.309016994,-0.951056516, 0.0, 1.0);","\tvec4 HS5 = vec4( 0.0 ,0.0 , 1.0, 1.0);","\tvec4 one = vec4( 1.0 );","\tvec4 P = vec4((coords),vec2(scale, scale));","\tvec4 dist = vec4(0.0);","\tfloat inorout = -4.0;","\tdist.x = dot( P, HS0 );","\tdist.y = dot( P, HS1 );","\tdist.z = dot( P, HS2 );","\tdist.w = dot( P, HS3 );","\tdist = smoothstep( -feather, feather, dist );","\tinorout += dot( dist, one );","\tdist.x = dot( P, HS4 );","\tdist.y = HS5.w - abs( P.z );","\tdist = smoothstep( -feather, feather, dist );","\tinorout += dist.x;","\treturn clamp( inorout, 0.0, 1.0 );","}","float bdepth(vec2 coords) {","\t// Depth buffer blur","\tfloat d = 0.0;","\tfloat kernel[9];","\tvec2 offset[9];","\tvec2 wh = vec2(1.0/textureWidth,1.0/textureHeight) * dbsize;","\toffset[0] = vec2(-wh.x,-wh.y);","\toffset[1] = vec2( 0.0, -wh.y);","\toffset[2] = vec2( wh.x -wh.y);","\toffset[3] = vec2(-wh.x, 0.0);","\toffset[4] = vec2( 0.0, 0.0);","\toffset[5] = vec2( wh.x, 0.0);","\toffset[6] = vec2(-wh.x, wh.y);","\toffset[7] = vec2( 0.0, wh.y);","\toffset[8] = vec2( wh.x, wh.y);","\tkernel[0] = 1.0/16.0; kernel[1] = 2.0/16.0; kernel[2] = 1.0/16.0;","\tkernel[3] = 2.0/16.0; kernel[4] = 4.0/16.0; kernel[5] = 2.0/16.0;","\tkernel[6] = 1.0/16.0; kernel[7] = 2.0/16.0; kernel[8] = 1.0/16.0;","\tfor( int i=0; i<9; i++ ) {","\t\tfloat tmp = texture2D(tDepth, coords + offset[i]).r;","\t\td += tmp * kernel[i];","\t}","\treturn d;","}","vec3 color(vec2 coords,float blur) {","\t//processing the sample","\tvec3 col = vec3(0.0);","\tvec2 texel = vec2(1.0/textureWidth,1.0/textureHeight);","\tcol.r = texture2D(tColor,coords + vec2(0.0,1.0)*texel*fringe*blur).r;","\tcol.g = texture2D(tColor,coords + vec2(-0.866,-0.5)*texel*fringe*blur).g;","\tcol.b = texture2D(tColor,coords + vec2(0.866,-0.5)*texel*fringe*blur).b;","\tvec3 lumcoeff = vec3(0.299,0.587,0.114);","\tfloat lum = dot(col.rgb, lumcoeff);","\tfloat thresh = max((lum-threshold)*gain, 0.0);","\treturn col+mix(vec3(0.0),col,thresh*blur);","}","vec3 debugFocus(vec3 col, float blur, float depth) {","\tfloat edge = 0.002*depth; //distance based edge smoothing","\tfloat m = clamp(smoothstep(0.0,edge,blur),0.0,1.0);","\tfloat e = clamp(smoothstep(1.0-edge,1.0,blur),0.0,1.0);","\tcol = mix(col,vec3(1.0,0.5,0.0),(1.0-m)*0.6);","\tcol = mix(col,vec3(0.0,0.5,1.0),((1.0-e)-(1.0-m))*0.2);","\treturn col;","}","float linearize(float depth) {","\treturn -zfar * znear / (depth * (zfar - znear) - zfar);","}","float vignette() {","\tfloat dist = distance(vUv.xy, vec2(0.5,0.5));","\tdist = smoothstep(vignout+(fstop/vignfade), vignin+(fstop/vignfade), dist);","\treturn clamp(dist,0.0,1.0);","}","float gather(float i, float j, int ringsamples, inout vec3 col, float w, float h, float blur) {","\tfloat rings2 = float(rings);","\tfloat step = PI*2.0 / float(ringsamples);","\tfloat pw = cos(j*step)*i;","\tfloat ph = sin(j*step)*i;","\tfloat p = 1.0;","\tif (pentagon) {","\t\tp = penta(vec2(pw,ph));","\t}","\tcol += color(vUv.xy + vec2(pw*w,ph*h), blur) * mix(1.0, i/rings2, bias) * p;","\treturn 1.0 * mix(1.0, i /rings2, bias) * p;","}","void main() {","\t//scene depth calculation","\tfloat depth = linearize(texture2D(tDepth,vUv.xy).x);","\t// Blur depth?","\tif ( depthblur ) {","\t\tdepth = linearize(bdepth(vUv.xy));","\t}","\t//focal plane calculation","\tfloat fDepth = focalDepth;","\tif (shaderFocus) {","\t\tfDepth = linearize(texture2D(tDepth,focusCoords).x);","\t}","\t// dof blur factor calculation","\tfloat blur = 0.0;","\tif (manualdof) {","\t\tfloat a = depth-fDepth; // Focal plane","\t\tfloat b = (a-fdofstart)/fdofdist; // Far DoF","\t\tfloat c = (-a-ndofstart)/ndofdist; // Near Dof","\t\tblur = (a>0.0) ? b : c;","\t} else {","\t\tfloat f = focalLength; // focal length in mm","\t\tfloat d = fDepth*1000.0; // focal plane in mm","\t\tfloat o = depth*1000.0; // depth in mm","\t\tfloat a = (o*f)/(o-f);","\t\tfloat b = (d*f)/(d-f);","\t\tfloat c = (d-f)/(d*fstop*CoC);","\t\tblur = abs(a-b)*c;","\t}","\tblur = clamp(blur,0.0,1.0);","\t// calculation of pattern for dithering","\tvec2 noise = vec2(rand(vUv.xy), rand( vUv.xy + vec2( 0.4, 0.6 ) ) )*dithering*blur;","\t// getting blur x and y step factor","\tfloat w = (1.0/textureWidth)*blur*maxblur+noise.x;","\tfloat h = (1.0/textureHeight)*blur*maxblur+noise.y;","\t// calculation of final color","\tvec3 col = vec3(0.0);","\tif(blur < 0.05) {","\t\t//some optimization thingy","\t\tcol = texture2D(tColor, vUv.xy).rgb;","\t} else {","\t\tcol = texture2D(tColor, vUv.xy).rgb;","\t\tfloat s = 1.0;","\t\tint ringsamples;","\t\tfor (int i = 1; i <= rings; i++) {","\t\t\t/*unboxstart*/","\t\t\tringsamples = i * samples;","\t\t\tfor (int j = 0 ; j < maxringsamples ; j++) {","\t\t\t\tif (j >= ringsamples) break;","\t\t\t\ts += gather(float(i), float(j), ringsamples, col, w, h, blur);","\t\t\t}","\t\t\t/*unboxend*/","\t\t}","\t\tcol /= s; //divide by sample count","\t}","\tif (showFocus) {","\t\tcol = debugFocus(col, blur, depth);","\t}","\tif (vignetting) {","\t\tcol *= vignette();","\t}","\tgl_FragColor.rgb = col;","\tgl_FragColor.a = 1.0;","} "].join("\n")},e={uniforms:{mNear:{value:1},mFar:{value:1e3}},vertexShader:["varying float vViewZDepth;","void main() {","\t#include <begin_vertex>","\t#include <project_vertex>","\tvViewZDepth = - mvPosition.z;","}"].join("\n"),fragmentShader:["uniform float mNear;","uniform float mFar;","varying float vViewZDepth;","void main() {","\tfloat color = 1.0 - smoothstep( mNear, mFar, vViewZDepth );","\tgl_FragColor = vec4( vec3( color ), 1.0 );","} "].join("\n")};exports.BokehDepthShader=e,exports.BokehShader2=t;
|
@@ -1,41 +1,87 @@
|
|
1
|
-
import {
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
}
|
28
|
-
|
29
|
-
|
30
|
-
|
1
|
+
import { Vector2 } from 'three';
|
2
|
+
export declare const BokehShader2: {
|
3
|
+
uniforms: {
|
4
|
+
textureWidth: {
|
5
|
+
value: number;
|
6
|
+
};
|
7
|
+
textureHeight: {
|
8
|
+
value: number;
|
9
|
+
};
|
10
|
+
focalDepth: {
|
11
|
+
value: number;
|
12
|
+
};
|
13
|
+
focalLength: {
|
14
|
+
value: number;
|
15
|
+
};
|
16
|
+
fstop: {
|
17
|
+
value: number;
|
18
|
+
};
|
19
|
+
tColor: {
|
20
|
+
value: null;
|
21
|
+
};
|
22
|
+
tDepth: {
|
23
|
+
value: null;
|
24
|
+
};
|
25
|
+
maxblur: {
|
26
|
+
value: number;
|
27
|
+
};
|
28
|
+
showFocus: {
|
29
|
+
value: number;
|
30
|
+
};
|
31
|
+
manualdof: {
|
32
|
+
value: number;
|
33
|
+
};
|
34
|
+
vignetting: {
|
35
|
+
value: number;
|
36
|
+
};
|
37
|
+
depthblur: {
|
38
|
+
value: number;
|
39
|
+
};
|
40
|
+
threshold: {
|
41
|
+
value: number;
|
42
|
+
};
|
43
|
+
gain: {
|
44
|
+
value: number;
|
45
|
+
};
|
46
|
+
bias: {
|
47
|
+
value: number;
|
48
|
+
};
|
49
|
+
fringe: {
|
50
|
+
value: number;
|
51
|
+
};
|
52
|
+
znear: {
|
53
|
+
value: number;
|
54
|
+
};
|
55
|
+
zfar: {
|
56
|
+
value: number;
|
57
|
+
};
|
58
|
+
noise: {
|
59
|
+
value: number;
|
60
|
+
};
|
61
|
+
dithering: {
|
62
|
+
value: number;
|
63
|
+
};
|
64
|
+
pentagon: {
|
65
|
+
value: number;
|
66
|
+
};
|
67
|
+
shaderFocus: {
|
68
|
+
value: number;
|
69
|
+
};
|
70
|
+
focusCoords: {
|
71
|
+
value: Vector2;
|
72
|
+
};
|
73
|
+
};
|
31
74
|
vertexShader: string;
|
32
75
|
fragmentShader: string;
|
33
76
|
};
|
34
|
-
|
35
|
-
export const BokehDepthShader: {
|
77
|
+
export declare const BokehDepthShader: {
|
36
78
|
uniforms: {
|
37
|
-
mNear:
|
38
|
-
|
79
|
+
mNear: {
|
80
|
+
value: number;
|
81
|
+
};
|
82
|
+
mFar: {
|
83
|
+
value: number;
|
84
|
+
};
|
39
85
|
};
|
40
86
|
vertexShader: string;
|
41
87
|
fragmentShader: string;
|
package/shaders/BokehShader2.js
CHANGED
@@ -8,7 +8,7 @@ import { Vector2 } from 'three';
|
|
8
8
|
* Requires #define RINGS and SAMPLES integers
|
9
9
|
*/
|
10
10
|
|
11
|
-
|
11
|
+
const BokehShader2 = {
|
12
12
|
uniforms: {
|
13
13
|
textureWidth: {
|
14
14
|
value: 1.0
|
@@ -83,7 +83,7 @@ var BokehShader2 = {
|
|
83
83
|
vertexShader: ['varying vec2 vUv;', 'void main() {', ' vUv = uv;', ' gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );', '}'].join('\n'),
|
84
84
|
fragmentShader: ['#include <common>', 'varying vec2 vUv;', 'uniform sampler2D tColor;', 'uniform sampler2D tDepth;', 'uniform float textureWidth;', 'uniform float textureHeight;', 'uniform float focalDepth; //focal distance value in meters, but you may use autofocus option below', 'uniform float focalLength; //focal length in mm', 'uniform float fstop; //f-stop value', 'uniform bool showFocus; //show debug focus point and focal range (red = focal point, green = focal range)', '/*', 'make sure that these two values are the same for your camera, otherwise distances will be wrong.', '*/', 'uniform float znear; // camera clipping start', 'uniform float zfar; // camera clipping end', '//------------------------------------------', '//user variables', 'const int samples = SAMPLES; //samples on the first ring', 'const int rings = RINGS; //ring count', 'const int maxringsamples = rings * samples;', 'uniform bool manualdof; // manual dof calculation', 'float ndofstart = 1.0; // near dof blur start', 'float ndofdist = 2.0; // near dof blur falloff distance', 'float fdofstart = 1.0; // far dof blur start', 'float fdofdist = 3.0; // far dof blur falloff distance', 'float CoC = 0.03; //circle of confusion size in mm (35mm film = 0.03mm)', 'uniform bool vignetting; // use optical lens vignetting', 'float vignout = 1.3; // vignetting outer border', 'float vignin = 0.0; // vignetting inner border', 'float vignfade = 22.0; // f-stops till vignete fades', 'uniform bool shaderFocus;', '// disable if you use external focalDepth value', 'uniform vec2 focusCoords;', '// autofocus point on screen (0.0,0.0 - left lower corner, 1.0,1.0 - upper right)', '// if center of screen use vec2(0.5, 0.5);', 'uniform float maxblur;', '//clamp value of max blur (0.0 = no blur, 1.0 default)', 'uniform float threshold; // highlight threshold;', 'uniform float gain; // highlight gain;', 'uniform float bias; // bokeh edge bias', 'uniform float fringe; // bokeh chromatic aberration / fringing', 'uniform bool noise; //use noise instead of pattern for sample dithering', 'uniform float dithering;', 'uniform bool depthblur; // blur the depth buffer', 'float dbsize = 1.25; // depth blur size', '/*', 'next part is experimental', 'not looking good with small sample and ring count', 'looks okay starting from samples = 4, rings = 4', '*/', 'uniform bool pentagon; //use pentagon as bokeh shape?', 'float feather = 0.4; //pentagon shape feather', '//------------------------------------------', 'float penta(vec2 coords) {', ' //pentagonal shape', ' float scale = float(rings) - 1.3;', ' vec4 HS0 = vec4( 1.0, 0.0, 0.0, 1.0);', ' vec4 HS1 = vec4( 0.309016994, 0.951056516, 0.0, 1.0);', ' vec4 HS2 = vec4(-0.809016994, 0.587785252, 0.0, 1.0);', ' vec4 HS3 = vec4(-0.809016994,-0.587785252, 0.0, 1.0);', ' vec4 HS4 = vec4( 0.309016994,-0.951056516, 0.0, 1.0);', ' vec4 HS5 = vec4( 0.0 ,0.0 , 1.0, 1.0);', ' vec4 one = vec4( 1.0 );', ' vec4 P = vec4((coords),vec2(scale, scale));', ' vec4 dist = vec4(0.0);', ' float inorout = -4.0;', ' dist.x = dot( P, HS0 );', ' dist.y = dot( P, HS1 );', ' dist.z = dot( P, HS2 );', ' dist.w = dot( P, HS3 );', ' dist = smoothstep( -feather, feather, dist );', ' inorout += dot( dist, one );', ' dist.x = dot( P, HS4 );', ' dist.y = HS5.w - abs( P.z );', ' dist = smoothstep( -feather, feather, dist );', ' inorout += dist.x;', ' return clamp( inorout, 0.0, 1.0 );', '}', 'float bdepth(vec2 coords) {', ' // Depth buffer blur', ' float d = 0.0;', ' float kernel[9];', ' vec2 offset[9];', ' vec2 wh = vec2(1.0/textureWidth,1.0/textureHeight) * dbsize;', ' offset[0] = vec2(-wh.x,-wh.y);', ' offset[1] = vec2( 0.0, -wh.y);', ' offset[2] = vec2( wh.x -wh.y);', ' offset[3] = vec2(-wh.x, 0.0);', ' offset[4] = vec2( 0.0, 0.0);', ' offset[5] = vec2( wh.x, 0.0);', ' offset[6] = vec2(-wh.x, wh.y);', ' offset[7] = vec2( 0.0, wh.y);', ' offset[8] = vec2( wh.x, wh.y);', ' kernel[0] = 1.0/16.0; kernel[1] = 2.0/16.0; kernel[2] = 1.0/16.0;', ' kernel[3] = 2.0/16.0; kernel[4] = 4.0/16.0; kernel[5] = 2.0/16.0;', ' kernel[6] = 1.0/16.0; kernel[7] = 2.0/16.0; kernel[8] = 1.0/16.0;', ' for( int i=0; i<9; i++ ) {', ' float tmp = texture2D(tDepth, coords + offset[i]).r;', ' d += tmp * kernel[i];', ' }', ' return d;', '}', 'vec3 color(vec2 coords,float blur) {', ' //processing the sample', ' vec3 col = vec3(0.0);', ' vec2 texel = vec2(1.0/textureWidth,1.0/textureHeight);', ' col.r = texture2D(tColor,coords + vec2(0.0,1.0)*texel*fringe*blur).r;', ' col.g = texture2D(tColor,coords + vec2(-0.866,-0.5)*texel*fringe*blur).g;', ' col.b = texture2D(tColor,coords + vec2(0.866,-0.5)*texel*fringe*blur).b;', ' vec3 lumcoeff = vec3(0.299,0.587,0.114);', ' float lum = dot(col.rgb, lumcoeff);', ' float thresh = max((lum-threshold)*gain, 0.0);', ' return col+mix(vec3(0.0),col,thresh*blur);', '}', 'vec3 debugFocus(vec3 col, float blur, float depth) {', ' float edge = 0.002*depth; //distance based edge smoothing', ' float m = clamp(smoothstep(0.0,edge,blur),0.0,1.0);', ' float e = clamp(smoothstep(1.0-edge,1.0,blur),0.0,1.0);', ' col = mix(col,vec3(1.0,0.5,0.0),(1.0-m)*0.6);', ' col = mix(col,vec3(0.0,0.5,1.0),((1.0-e)-(1.0-m))*0.2);', ' return col;', '}', 'float linearize(float depth) {', ' return -zfar * znear / (depth * (zfar - znear) - zfar);', '}', 'float vignette() {', ' float dist = distance(vUv.xy, vec2(0.5,0.5));', ' dist = smoothstep(vignout+(fstop/vignfade), vignin+(fstop/vignfade), dist);', ' return clamp(dist,0.0,1.0);', '}', 'float gather(float i, float j, int ringsamples, inout vec3 col, float w, float h, float blur) {', ' float rings2 = float(rings);', ' float step = PI*2.0 / float(ringsamples);', ' float pw = cos(j*step)*i;', ' float ph = sin(j*step)*i;', ' float p = 1.0;', ' if (pentagon) {', ' p = penta(vec2(pw,ph));', ' }', ' col += color(vUv.xy + vec2(pw*w,ph*h), blur) * mix(1.0, i/rings2, bias) * p;', ' return 1.0 * mix(1.0, i /rings2, bias) * p;', '}', 'void main() {', ' //scene depth calculation', ' float depth = linearize(texture2D(tDepth,vUv.xy).x);', ' // Blur depth?', ' if ( depthblur ) {', ' depth = linearize(bdepth(vUv.xy));', ' }', ' //focal plane calculation', ' float fDepth = focalDepth;', ' if (shaderFocus) {', ' fDepth = linearize(texture2D(tDepth,focusCoords).x);', ' }', ' // dof blur factor calculation', ' float blur = 0.0;', ' if (manualdof) {', ' float a = depth-fDepth; // Focal plane', ' float b = (a-fdofstart)/fdofdist; // Far DoF', ' float c = (-a-ndofstart)/ndofdist; // Near Dof', ' blur = (a>0.0) ? b : c;', ' } else {', ' float f = focalLength; // focal length in mm', ' float d = fDepth*1000.0; // focal plane in mm', ' float o = depth*1000.0; // depth in mm', ' float a = (o*f)/(o-f);', ' float b = (d*f)/(d-f);', ' float c = (d-f)/(d*fstop*CoC);', ' blur = abs(a-b)*c;', ' }', ' blur = clamp(blur,0.0,1.0);', ' // calculation of pattern for dithering', ' vec2 noise = vec2(rand(vUv.xy), rand( vUv.xy + vec2( 0.4, 0.6 ) ) )*dithering*blur;', ' // getting blur x and y step factor', ' float w = (1.0/textureWidth)*blur*maxblur+noise.x;', ' float h = (1.0/textureHeight)*blur*maxblur+noise.y;', ' // calculation of final color', ' vec3 col = vec3(0.0);', ' if(blur < 0.05) {', ' //some optimization thingy', ' col = texture2D(tColor, vUv.xy).rgb;', ' } else {', ' col = texture2D(tColor, vUv.xy).rgb;', ' float s = 1.0;', ' int ringsamples;', ' for (int i = 1; i <= rings; i++) {', ' /*unboxstart*/', ' ringsamples = i * samples;', ' for (int j = 0 ; j < maxringsamples ; j++) {', ' if (j >= ringsamples) break;', ' s += gather(float(i), float(j), ringsamples, col, w, h, blur);', ' }', ' /*unboxend*/', ' }', ' col /= s; //divide by sample count', ' }', ' if (showFocus) {', ' col = debugFocus(col, blur, depth);', ' }', ' if (vignetting) {', ' col *= vignette();', ' }', ' gl_FragColor.rgb = col;', ' gl_FragColor.a = 1.0;', '} '].join('\n')
|
85
85
|
};
|
86
|
-
|
86
|
+
const BokehDepthShader = {
|
87
87
|
uniforms: {
|
88
88
|
mNear: {
|
89
89
|
value: 1.0
|
@@ -1 +1 @@
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});const r={uniforms:{tDiffuse:{value:null},brightness:{value:0},contrast:{value:0}},vertexShader:["varying vec2 vUv;","void main() {","\tvUv = uv;","\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","}"].join("\n"),fragmentShader:["uniform sampler2D tDiffuse;","uniform float brightness;","uniform float contrast;","varying vec2 vUv;","void main() {","\tgl_FragColor = texture2D( tDiffuse, vUv );","\tgl_FragColor.rgb += brightness;","\tif (contrast > 0.0) {","\t\tgl_FragColor.rgb = (gl_FragColor.rgb - 0.5) / (1.0 - contrast) + 0.5;","\t} else {","\t\tgl_FragColor.rgb = (gl_FragColor.rgb - 0.5) * (1.0 + contrast) + 0.5;","\t}","}"].join("\n")};exports.BrightnessContrastShader=r;
|
@@ -1,10 +1,14 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
export const BrightnessContrastShader: {
|
1
|
+
export declare const BrightnessContrastShader: {
|
4
2
|
uniforms: {
|
5
|
-
tDiffuse:
|
6
|
-
|
7
|
-
|
3
|
+
tDiffuse: {
|
4
|
+
value: null;
|
5
|
+
};
|
6
|
+
brightness: {
|
7
|
+
value: number;
|
8
|
+
};
|
9
|
+
contrast: {
|
10
|
+
value: number;
|
11
|
+
};
|
8
12
|
};
|
9
13
|
vertexShader: string;
|
10
14
|
fragmentShader: string;
|
@@ -4,7 +4,7 @@
|
|
4
4
|
* brightness: -1 to 1 (-1 is solid black, 0 is no change, and 1 is solid white)
|
5
5
|
* contrast: -1 to 1 (-1 is solid gray, 0 is no change, and 1 is maximum contrast)
|
6
6
|
*/
|
7
|
-
|
7
|
+
const BrightnessContrastShader = {
|
8
8
|
uniforms: {
|
9
9
|
tDiffuse: {
|
10
10
|
value: null
|
@@ -1 +1 @@
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("three")
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("three");const r={uniforms:{tDiffuse:{value:null},powRGB:{value:new e.Vector3(2,2,2)},mulRGB:{value:new e.Vector3(1,1,1)},addRGB:{value:new e.Vector3(0,0,0)}},vertexShader:["varying vec2 vUv;","void main() {","\tvUv = uv;","\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","}"].join("\n"),fragmentShader:["uniform sampler2D tDiffuse;","uniform vec3 powRGB;","uniform vec3 mulRGB;","uniform vec3 addRGB;","varying vec2 vUv;","void main() {","\tgl_FragColor = texture2D( tDiffuse, vUv );","\tgl_FragColor.rgb = mulRGB * pow( ( gl_FragColor.rgb + addRGB ), powRGB );","}"].join("\n")};exports.ColorCorrectionShader=r;
|
@@ -1,11 +1,18 @@
|
|
1
|
-
import {
|
2
|
-
|
3
|
-
export const ColorCorrectionShader: {
|
1
|
+
import { Vector3 } from 'three';
|
2
|
+
export declare const ColorCorrectionShader: {
|
4
3
|
uniforms: {
|
5
|
-
tDiffuse:
|
6
|
-
|
7
|
-
|
8
|
-
|
4
|
+
tDiffuse: {
|
5
|
+
value: null;
|
6
|
+
};
|
7
|
+
powRGB: {
|
8
|
+
value: Vector3;
|
9
|
+
};
|
10
|
+
mulRGB: {
|
11
|
+
value: Vector3;
|
12
|
+
};
|
13
|
+
addRGB: {
|
14
|
+
value: Vector3;
|
15
|
+
};
|
9
16
|
};
|
10
17
|
vertexShader: string;
|
11
18
|
fragmentShader: string;
|
@@ -1 +1 @@
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});const e={uniforms:{tDiffuse:{value:null},color:{value:new(require("three").Color)(16777215)}},vertexShader:["varying vec2 vUv;","void main() {","\tvUv = uv;","\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","}"].join("\n"),fragmentShader:["uniform vec3 color;","uniform sampler2D tDiffuse;","varying vec2 vUv;","void main() {","\tvec4 texel = texture2D( tDiffuse, vUv );","\tvec3 luma = vec3( 0.299, 0.587, 0.114 );","\tfloat v = dot( texel.xyz, luma );","\tgl_FragColor = vec4( v * color, texel.w );","}"].join("\n")};exports.ColorifyShader=e;
|
@@ -1,9 +1,12 @@
|
|
1
|
-
import {
|
2
|
-
|
3
|
-
export const ColorifyShader: {
|
1
|
+
import { Color } from 'three';
|
2
|
+
export declare const ColorifyShader: {
|
4
3
|
uniforms: {
|
5
|
-
tDiffuse:
|
6
|
-
|
4
|
+
tDiffuse: {
|
5
|
+
value: null;
|
6
|
+
};
|
7
|
+
color: {
|
8
|
+
value: Color;
|
9
|
+
};
|
7
10
|
};
|
8
11
|
vertexShader: string;
|
9
12
|
fragmentShader: string;
|
@@ -1 +1 @@
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});const e={defines:{KERNEL_SIZE_FLOAT:"25.0",KERNEL_SIZE_INT:"25"},uniforms:{tDiffuse:{value:null},uImageIncrement:{value:new(require("three").Vector2)(.001953125,0)},cKernel:{value:[]}},vertexShader:["uniform vec2 uImageIncrement;","varying vec2 vUv;","void main() {","\tvUv = uv - ( ( KERNEL_SIZE_FLOAT - 1.0 ) / 2.0 ) * uImageIncrement;","\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","}"].join("\n"),fragmentShader:["uniform float cKernel[ KERNEL_SIZE_INT ];","uniform sampler2D tDiffuse;","uniform vec2 uImageIncrement;","varying vec2 vUv;","void main() {","\tvec2 imageCoord = vUv;","\tvec4 sum = vec4( 0.0, 0.0, 0.0, 0.0 );","\tfor( int i = 0; i < KERNEL_SIZE_INT; i ++ ) {","\t\tsum += texture2D( tDiffuse, imageCoord ) * cKernel[ i ];","\t\timageCoord += uImageIncrement;","\t}","\tgl_FragColor = sum;","}"].join("\n"),buildKernel:function(e){function t(e,t){return Math.exp(-e*e/(2*t*t))}const r=Math.min(2*Math.ceil(3*e)+1,25),n=.5*(r-1),i=new Array(r);let o=0;for(let u=0;u<r;++u)i[u]=t(u-n,e),o+=i[u];for(let e=0;e<r;++e)i[e]/=o;return i}};exports.ConvolutionShader=e;
|
@@ -1,17 +1,16 @@
|
|
1
|
-
import {
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
};
|
8
|
-
uniforms: {
|
9
|
-
tDiffuse: Uniform;
|
10
|
-
uImageIncrement: Uniform;
|
11
|
-
cKernel: Uniform;
|
12
|
-
};
|
13
|
-
vertexShader: string;
|
14
|
-
fragmentShader: string;
|
15
|
-
|
16
|
-
buildKernel(sigma: number): number[];
|
1
|
+
import { Vector2 } from 'three';
|
2
|
+
import type { IUniform, Texture } from 'three';
|
3
|
+
import type { IShader } from './types';
|
4
|
+
export declare type ConvolutionShaderDefines = {
|
5
|
+
KERNEL_SIZE_FLOAT: string;
|
6
|
+
KERNEL_SIZE_INT: string;
|
17
7
|
};
|
8
|
+
export declare type ConvolutionShaderUniforms = {
|
9
|
+
cKernel: IUniform<number[]>;
|
10
|
+
tDiffuse: IUniform<Texture | null>;
|
11
|
+
uImageIncrement: IUniform<Vector2>;
|
12
|
+
};
|
13
|
+
export interface IConvolutionShader extends IShader<ConvolutionShaderUniforms, ConvolutionShaderDefines> {
|
14
|
+
buildKernel: (sigma: number) => number[];
|
15
|
+
}
|
16
|
+
export declare const ConvolutionShader: IConvolutionShader;
|
@@ -6,7 +6,7 @@ import { Vector2 } from 'three';
|
|
6
6
|
* http://o3d.googlecode.com/svn/trunk/samples/convolution.html
|
7
7
|
*/
|
8
8
|
|
9
|
-
|
9
|
+
const ConvolutionShader = {
|
10
10
|
defines: {
|
11
11
|
KERNEL_SIZE_FLOAT: '25.0',
|
12
12
|
KERNEL_SIZE_INT: '25'
|
@@ -30,24 +30,19 @@ var ConvolutionShader = {
|
|
30
30
|
return Math.exp(-(x * x) / (2.0 * sigma * sigma));
|
31
31
|
}
|
32
32
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
halfWidth = (kernelSize - 1) * 0.5;
|
41
|
-
values = new Array(kernelSize);
|
42
|
-
sum = 0.0;
|
43
|
-
|
44
|
-
for (i = 0; i < kernelSize; ++i) {
|
33
|
+
const kMaxKernelSize = 25;
|
34
|
+
const kernelSize = Math.min(2 * Math.ceil(sigma * 3.0) + 1, kMaxKernelSize);
|
35
|
+
const halfWidth = (kernelSize - 1) * 0.5;
|
36
|
+
const values = new Array(kernelSize);
|
37
|
+
let sum = 0.0;
|
38
|
+
|
39
|
+
for (let i = 0; i < kernelSize; ++i) {
|
45
40
|
values[i] = gauss(i - halfWidth, sigma);
|
46
41
|
sum += values[i];
|
47
42
|
} // normalize the kernel
|
48
43
|
|
49
44
|
|
50
|
-
for (i = 0; i < kernelSize; ++i) values[i] /= sum;
|
45
|
+
for (let i = 0; i < kernelSize; ++i) values[i] /= sum;
|
51
46
|
|
52
47
|
return values;
|
53
48
|
}
|
package/shaders/CopyShader.d.ts
CHANGED
@@ -1,13 +1,9 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
opacity: {
|
7
|
-
value: number;
|
8
|
-
};
|
9
|
-
};
|
10
|
-
vertexShader: string;
|
11
|
-
fragmentShader: string;
|
1
|
+
import type { IUniform, Texture } from 'three';
|
2
|
+
import type { IShader } from './types';
|
3
|
+
export declare type CopyShaderUniforms = {
|
4
|
+
opacity: IUniform<number>;
|
5
|
+
tDiffuse: IUniform<Texture | null>;
|
12
6
|
};
|
13
|
-
export
|
7
|
+
export interface ICopyShader extends IShader<CopyShaderUniforms> {
|
8
|
+
}
|
9
|
+
export declare const CopyShader: ICopyShader;
|
@@ -1 +1 @@
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});const o={uniforms:{tColor:{value:null},tDepth:{value:null},focus:{value:1},maxblur:{value:1}},vertexShader:["varying vec2 vUv;","void main() {","\tvUv = uv;","\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","}"].join("\n"),fragmentShader:["uniform float focus;","uniform float maxblur;","uniform sampler2D tColor;","uniform sampler2D tDepth;","varying vec2 vUv;","void main() {","\tvec4 depth = texture2D( tDepth, vUv );","\tfloat factor = depth.x - focus;","\tvec4 col = texture2D( tColor, vUv, 2.0 * maxblur * abs( focus - depth.x ) );","\tgl_FragColor = col;","\tgl_FragColor.a = 1.0;","}"].join("\n")};exports.DOFMipMapShader=o;
|
@@ -1,11 +1,17 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
export const DOFMipMapShader: {
|
1
|
+
export declare const DOFMipMapShader: {
|
4
2
|
uniforms: {
|
5
|
-
tColor:
|
6
|
-
|
7
|
-
|
8
|
-
|
3
|
+
tColor: {
|
4
|
+
value: null;
|
5
|
+
};
|
6
|
+
tDepth: {
|
7
|
+
value: null;
|
8
|
+
};
|
9
|
+
focus: {
|
10
|
+
value: number;
|
11
|
+
};
|
12
|
+
maxblur: {
|
13
|
+
value: number;
|
14
|
+
};
|
9
15
|
};
|
10
16
|
vertexShader: string;
|
11
17
|
fragmentShader: string;
|
@@ -1 +1 @@
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("three")
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("three");const t={defines:{KERNEL_RADIUS:4,DEPTH_PACKING:1,PERSPECTIVE_CAMERA:1},uniforms:{tDiffuse:{value:null},size:{value:new e.Vector2(512,512)},sampleUvOffsets:{value:[new e.Vector2(0,0)]},sampleWeights:{value:[1]},tDepth:{value:null},cameraNear:{value:10},cameraFar:{value:1e3},depthCutoff:{value:10}},vertexShader:["#include <common>","uniform vec2 size;","varying vec2 vUv;","varying vec2 vInvSize;","void main() {","\tvUv = uv;","\tvInvSize = 1.0 / size;","\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","}"].join("\n"),fragmentShader:["#include <common>","#include <packing>","uniform sampler2D tDiffuse;","uniform sampler2D tDepth;","uniform float cameraNear;","uniform float cameraFar;","uniform float depthCutoff;","uniform vec2 sampleUvOffsets[ KERNEL_RADIUS + 1 ];","uniform float sampleWeights[ KERNEL_RADIUS + 1 ];","varying vec2 vUv;","varying vec2 vInvSize;","float getDepth( const in vec2 screenPosition ) {","\t#if DEPTH_PACKING == 1","\treturn unpackRGBAToDepth( texture2D( tDepth, screenPosition ) );","\t#else","\treturn texture2D( tDepth, screenPosition ).x;","\t#endif","}","float getViewZ( const in float depth ) {","\t#if PERSPECTIVE_CAMERA == 1","\treturn perspectiveDepthToViewZ( depth, cameraNear, cameraFar );","\t#else","\treturn orthographicDepthToViewZ( depth, cameraNear, cameraFar );","\t#endif","}","void main() {","\tfloat depth = getDepth( vUv );","\tif( depth >= ( 1.0 - EPSILON ) ) {","\t\tdiscard;","\t}","\tfloat centerViewZ = -getViewZ( depth );","\tbool rBreak = false, lBreak = false;","\tfloat weightSum = sampleWeights[0];","\tvec4 diffuseSum = texture2D( tDiffuse, vUv ) * weightSum;","\tfor( int i = 1; i <= KERNEL_RADIUS; i ++ ) {","\t\tfloat sampleWeight = sampleWeights[i];","\t\tvec2 sampleUvOffset = sampleUvOffsets[i] * vInvSize;","\t\tvec2 sampleUv = vUv + sampleUvOffset;","\t\tfloat viewZ = -getViewZ( getDepth( sampleUv ) );","\t\tif( abs( viewZ - centerViewZ ) > depthCutoff ) rBreak = true;","\t\tif( ! rBreak ) {","\t\t\tdiffuseSum += texture2D( tDiffuse, sampleUv ) * sampleWeight;","\t\t\tweightSum += sampleWeight;","\t\t}","\t\tsampleUv = vUv - sampleUvOffset;","\t\tviewZ = -getViewZ( getDepth( sampleUv ) );","\t\tif( abs( viewZ - centerViewZ ) > depthCutoff ) lBreak = true;","\t\tif( ! lBreak ) {","\t\t\tdiffuseSum += texture2D( tDiffuse, sampleUv ) * sampleWeight;","\t\t\tweightSum += sampleWeight;","\t\t}","\t}","\tgl_FragColor = diffuseSum / weightSum;","}"].join("\n")},a={createSampleWeights:(e,t)=>{const a=(e,t)=>Math.exp(-e*e/(t*t*2))/(Math.sqrt(2*Math.PI)*t),i=[];for(let r=0;r<=e;r++)i.push(a(r,t));return i},createSampleOffsets:(e,t)=>{const a=[];for(let i=0;i<=e;i++)a.push(t.clone().multiplyScalar(i));return a},configure:(e,t,i,r)=>{e.defines.KERNEL_RADIUS=t,e.uniforms.sampleUvOffsets.value=a.createSampleOffsets(t,r),e.uniforms.sampleWeights.value=a.createSampleWeights(t,i),e.needsUpdate=!0}};exports.BlurShaderUtils=a,exports.DepthLimitedBlurShader=t;
|