diff --git a/docs/manual/en/introduction/Import-via-modules.html b/docs/manual/en/introduction/Import-via-modules.html
index 8bc59bd0a522202d3b7bfd2432e909b15c25b551..86e49d31a15fb0985ce1dcb222012e980111a4ea 100644
--- a/docs/manual/en/introduction/Import-via-modules.html
+++ b/docs/manual/en/introduction/Import-via-modules.html
@@ -176,11 +176,48 @@
shaders
+ - AfterimageShader
+ - BasicShader
+ - BleachBypassShader
+ - BlendShader
+ - BokehShader
- BokehShader2
+ - BrightnessContrastShader
+ - ColorCorrectionShader
+ - ColorifyShader
+ - ConvolutionShader
- CopyShader
+ - DepthLimitedBlurShader
+ - DigitalGlitch
+ - DOFMipMapShader
- DotScreenShader
+ - FilmShader
+ - FocusShader
+ - FreiChenShader
+ - FresnelShader
+ - FXAAShader
+ - GammaCorrectionShader
+ - HalftoneShader
+ - HorizontalBlurShader
+ - HorizontalTiltShiftShader
+ - HueSaturationShader
+ - KaleidoShader
+ - LuminosityHighPassShader
+ - LuminosityShader
+ - MirrorShader
+ - NormalMapShader
+ - ParallaxShader
+ - PixelShader
- RGBShiftShader
+ - SAOShader
+ - SepiaShader
+ - SobelOperatorShader
+ - SSAOShader
+ - TechnicolorShader
- UnpackDepthRGBAShader
+ - VerticalBlurShader
+ - VerticalTiltShiftShader
+ - VignetteShader
- WaterRefractionShader
diff --git a/examples/js/shaders/BleachBypassShader.js b/examples/js/shaders/BleachBypassShader.js
index 0c7d8b05402b6f5e1587681bb21996fccf26c994..bed3c704565958be06e55e0760874677ee0821d4 100644
--- a/examples/js/shaders/BleachBypassShader.js
+++ b/examples/js/shaders/BleachBypassShader.js
@@ -11,7 +11,7 @@ THREE.BleachBypassShader = {
uniforms: {
"tDiffuse": { value: null },
- "opacity": { value: 1.0 }
+ "opacity": { value: 1.0 }
},
diff --git a/examples/js/shaders/BlendShader.js b/examples/js/shaders/BlendShader.js
index 8a7a59cd85a0a50ce26a2cf84d9550cbf5b67de6..1dbd5236ac78e7e056c6f71d2bcbec9e67980117 100644
--- a/examples/js/shaders/BlendShader.js
+++ b/examples/js/shaders/BlendShader.js
@@ -10,8 +10,8 @@ THREE.BlendShader = {
"tDiffuse1": { value: null },
"tDiffuse2": { value: null },
- "mixRatio": { value: 0.5 },
- "opacity": { value: 1.0 }
+ "mixRatio": { value: 0.5 },
+ "opacity": { value: 1.0 }
},
diff --git a/examples/js/shaders/BokehShader.js b/examples/js/shaders/BokehShader.js
index a2336d0409faee65d730507b82a0b9294de26e10..20c0a93e9495a334032ace09073cf61be83fcd29 100644
--- a/examples/js/shaders/BokehShader.js
+++ b/examples/js/shaders/BokehShader.js
@@ -15,14 +15,14 @@ THREE.BokehShader = {
uniforms: {
- "tColor": { value: null },
- "tDepth": { value: null },
- "focus": { value: 1.0 },
- "aspect": { value: 1.0 },
+ "tColor": { value: null },
+ "tDepth": { value: null },
+ "focus": { value: 1.0 },
+ "aspect": { value: 1.0 },
"aperture": { value: 0.025 },
- "maxblur": { value: 1.0 },
- "nearClip": { value: 1.0 },
- "farClip": { value: 1000.0 },
+ "maxblur": { value: 1.0 },
+ "nearClip": { value: 1.0 },
+ "farClip": { value: 1000.0 },
},
@@ -47,7 +47,7 @@ THREE.BokehShader = {
"uniform sampler2D tColor;",
"uniform sampler2D tDepth;",
- "uniform float maxblur;", // max blur amount
+ "uniform float maxblur;", // max blur amount
"uniform float aperture;", // aperture - bigger values for shallower depth of field
"uniform float nearClip;",
@@ -73,15 +73,15 @@ THREE.BokehShader = {
" return orthographicDepthToViewZ( depth, nearClip, farClip );",
" #endif",
"}",
-
+
"void main() {",
"vec2 aspectcorrect = vec2( 1.0, aspect );",
-
+
"float viewZ = getViewZ( getDepth( vUv ) );",
- "float factor = ( focus + viewZ );", // viewZ is <= 0, so this is a difference equation
+ "float factor = ( focus + viewZ );", // viewZ is <= 0, so this is a difference equation
"vec2 dofblur = vec2 ( clamp( factor * aperture, -maxblur, maxblur ) );",
diff --git a/examples/js/shaders/BrightnessContrastShader.js b/examples/js/shaders/BrightnessContrastShader.js
index ae90b649c2ecdb7496b8708d06e6d6fb10875db1..7f0c1fe7d6bc40dc2e3b0b9e920b268f59ab3ecf 100644
--- a/examples/js/shaders/BrightnessContrastShader.js
+++ b/examples/js/shaders/BrightnessContrastShader.js
@@ -11,9 +11,9 @@ THREE.BrightnessContrastShader = {
uniforms: {
- "tDiffuse": { value: null },
+ "tDiffuse": { value: null },
"brightness": { value: 0 },
- "contrast": { value: 0 }
+ "contrast": { value: 0 }
},
diff --git a/examples/js/shaders/ColorCorrectionShader.js b/examples/js/shaders/ColorCorrectionShader.js
index 93060751cb04105c1753658daccd0d79c984a66a..adbb75229931083db171fcc7f428a35f8141151e 100644
--- a/examples/js/shaders/ColorCorrectionShader.js
+++ b/examples/js/shaders/ColorCorrectionShader.js
@@ -9,9 +9,9 @@ THREE.ColorCorrectionShader = {
uniforms: {
"tDiffuse": { value: null },
- "powRGB": { value: new THREE.Vector3( 2, 2, 2 ) },
- "mulRGB": { value: new THREE.Vector3( 1, 1, 1 ) },
- "addRGB": { value: new THREE.Vector3( 0, 0, 0 ) }
+ "powRGB": { value: new THREE.Vector3( 2, 2, 2 ) },
+ "mulRGB": { value: new THREE.Vector3( 1, 1, 1 ) },
+ "addRGB": { value: new THREE.Vector3( 0, 0, 0 ) }
},
diff --git a/examples/js/shaders/ColorifyShader.js b/examples/js/shaders/ColorifyShader.js
index 8b65a861fc6e2e69fe146cc7e72d51589cd5bbc6..037f69ae00f46ef71f358b31b777fc6f546878d0 100644
--- a/examples/js/shaders/ColorifyShader.js
+++ b/examples/js/shaders/ColorifyShader.js
@@ -9,7 +9,7 @@ THREE.ColorifyShader = {
uniforms: {
"tDiffuse": { value: null },
- "color": { value: new THREE.Color( 0xffffff ) }
+ "color": { value: new THREE.Color( 0xffffff ) }
},
diff --git a/examples/js/shaders/ConvolutionShader.js b/examples/js/shaders/ConvolutionShader.js
index 677f4d9a005ee610b7371bc65be4c9ff2501de48..0e5206530789474557b07f7feda0bc40b493f2b2 100644
--- a/examples/js/shaders/ConvolutionShader.js
+++ b/examples/js/shaders/ConvolutionShader.js
@@ -17,9 +17,9 @@ THREE.ConvolutionShader = {
uniforms: {
- "tDiffuse": { value: null },
+ "tDiffuse": { value: null },
"uImageIncrement": { value: new THREE.Vector2( 0.001953125, 0.0 ) },
- "cKernel": { value: [] }
+ "cKernel": { value: [] }
},
diff --git a/examples/js/shaders/DOFMipMapShader.js b/examples/js/shaders/DOFMipMapShader.js
index 8f11e9d65184397f5b3574ccd13a32a8380f2825..dad52f851e99ca87f3999a3902120312cad6b6f5 100644
--- a/examples/js/shaders/DOFMipMapShader.js
+++ b/examples/js/shaders/DOFMipMapShader.js
@@ -10,10 +10,10 @@ THREE.DOFMipMapShader = {
uniforms: {
- "tColor": { value: null },
- "tDepth": { value: null },
- "focus": { value: 1.0 },
- "maxblur": { value: 1.0 }
+ "tColor": { value: null },
+ "tDepth": { value: null },
+ "focus": { value: 1.0 },
+ "maxblur": { value: 1.0 }
},
diff --git a/examples/js/shaders/DepthLimitedBlurShader.js b/examples/js/shaders/DepthLimitedBlurShader.js
index c474085549d4206ba694df54f37ededa52f2de24..d9e71acea35743a6b7d4896bad69f6b156c36607 100644
--- a/examples/js/shaders/DepthLimitedBlurShader.js
+++ b/examples/js/shaders/DepthLimitedBlurShader.js
@@ -1,3 +1,7 @@
+/**
+ * TODO
+ */
+
THREE.DepthLimitedBlurShader = {
defines: {
'KERNEL_RADIUS': 4,
diff --git a/examples/js/shaders/DigitalGlitch.js b/examples/js/shaders/DigitalGlitch.js
index 0348e25d5dc8dc509f71d206e08feefd0a21c8a0..0dfc3b1cbf520bb8e15e41318ce00795f58a4618 100644
--- a/examples/js/shaders/DigitalGlitch.js
+++ b/examples/js/shaders/DigitalGlitch.js
@@ -14,17 +14,17 @@ THREE.DigitalGlitch = {
uniforms: {
- "tDiffuse": { value: null },//diffuse texture
- "tDisp": { value: null },//displacement texture for digital glitch squares
- "byp": { value: 0 },//apply the glitch ?
- "amount": { value: 0.08 },
- "angle": { value: 0.02 },
- "seed": { value: 0.02 },
- "seed_x": { value: 0.02 },//-1,1
- "seed_y": { value: 0.02 },//-1,1
- "distortion_x": { value: 0.5 },
- "distortion_y": { value: 0.6 },
- "col_s": { value: 0.05 }
+ "tDiffuse": { value: null }, //diffuse texture
+ "tDisp": { value: null }, //displacement texture for digital glitch squares
+ "byp": { value: 0 }, //apply the glitch ?
+ "amount": { value: 0.08 },
+ "angle": { value: 0.02 },
+ "seed": { value: 0.02 },
+ "seed_x": { value: 0.02 }, //-1,1
+ "seed_y": { value: 0.02 }, //-1,1
+ "distortion_x": { value: 0.5 },
+ "distortion_y": { value: 0.6 },
+ "col_s": { value: 0.05 }
},
vertexShader: [
@@ -38,10 +38,10 @@ THREE.DigitalGlitch = {
fragmentShader: [
"uniform int byp;",//should we apply the glitch ?
-
+
"uniform sampler2D tDiffuse;",
"uniform sampler2D tDisp;",
-
+
"uniform float amount;",
"uniform float angle;",
"uniform float seed;",
@@ -50,14 +50,14 @@ THREE.DigitalGlitch = {
"uniform float distortion_x;",
"uniform float distortion_y;",
"uniform float col_s;",
-
+
"varying vec2 vUv;",
-
-
+
+
"float rand(vec2 co){",
"return fract(sin(dot(co.xy ,vec2(12.9898,78.233))) * 43758.5453);",
"}",
-
+
"void main() {",
"if(byp<1) {",
"vec2 p = vUv;",
diff --git a/examples/js/shaders/FXAAShader.js b/examples/js/shaders/FXAAShader.js
index 57f593871dff91d738caac200ac383a44082302f..a616887f7f3fb6332818f7bca1d58a23d76fdfcd 100644
--- a/examples/js/shaders/FXAAShader.js
+++ b/examples/js/shaders/FXAAShader.js
@@ -12,7 +12,7 @@ THREE.FXAAShader = {
uniforms: {
- "tDiffuse": { value: null },
+ "tDiffuse": { value: null },
"resolution": { value: new THREE.Vector2( 1 / 1024, 1 / 512 ) }
},
diff --git a/examples/js/shaders/FilmShader.js b/examples/js/shaders/FilmShader.js
index 3028fbc330c9971ee9903afae8c4ba4e2520cdc8..5f65eaac05900d88572348dc173a0c749d7a49bf 100644
--- a/examples/js/shaders/FilmShader.js
+++ b/examples/js/shaders/FilmShader.js
@@ -24,12 +24,12 @@ THREE.FilmShader = {
uniforms: {
- "tDiffuse": { value: null },
- "time": { value: 0.0 },
+ "tDiffuse": { value: null },
+ "time": { value: 0.0 },
"nIntensity": { value: 0.5 },
"sIntensity": { value: 0.05 },
- "sCount": { value: 4096 },
- "grayscale": { value: 1 }
+ "sCount": { value: 4096 },
+ "grayscale": { value: 1 }
},
@@ -49,7 +49,7 @@ THREE.FilmShader = {
fragmentShader: [
"#include ",
-
+
// control parameter
"uniform float time;",
diff --git a/examples/js/shaders/FocusShader.js b/examples/js/shaders/FocusShader.js
index 0afbd60f0e96008d922d2691fe43fe3f408e3d0b..cfc4f7c7af9a2e4f236e42140b6adede0d7ed93d 100644
--- a/examples/js/shaders/FocusShader.js
+++ b/examples/js/shaders/FocusShader.js
@@ -8,13 +8,13 @@
THREE.FocusShader = {
- uniforms : {
+ uniforms: {
- "tDiffuse": { value: null },
- "screenWidth": { value: 1024 },
- "screenHeight": { value: 1024 },
+ "tDiffuse": { value: null },
+ "screenWidth": { value: 1024 },
+ "screenHeight": { value: 1024 },
"sampleDistance": { value: 0.94 },
- "waveFactor": { value: 0.00125 }
+ "waveFactor": { value: 0.00125 }
},
diff --git a/examples/js/shaders/FreiChenShader.js b/examples/js/shaders/FreiChenShader.js
index 0ca440d7102b8b73c9c64056f530708da57b2fc2..932615e69629e421818e4c0bc19317efe919bc30 100644
--- a/examples/js/shaders/FreiChenShader.js
+++ b/examples/js/shaders/FreiChenShader.js
@@ -12,7 +12,7 @@ THREE.FreiChenShader = {
uniforms: {
"tDiffuse": { value: null },
- "aspect": { value: new THREE.Vector2( 512, 512 ) }
+ "aspect": { value: new THREE.Vector2( 512, 512 ) }
},
vertexShader: [
diff --git a/examples/js/shaders/HorizontalBlurShader.js b/examples/js/shaders/HorizontalBlurShader.js
index a73c94bad63e4af895e03e8323df7e6765147a30..59c3a9fa02d14f0c2e14bd1ca51882c5152b1126 100644
--- a/examples/js/shaders/HorizontalBlurShader.js
+++ b/examples/js/shaders/HorizontalBlurShader.js
@@ -15,7 +15,7 @@ THREE.HorizontalBlurShader = {
uniforms: {
"tDiffuse": { value: null },
- "h": { value: 1.0 / 512.0 }
+ "h": { value: 1.0 / 512.0 }
},
diff --git a/examples/js/shaders/HorizontalTiltShiftShader.js b/examples/js/shaders/HorizontalTiltShiftShader.js
index 3114aba742fb473dc9d43fea58a3c81a2d8efb66..5d0d64acc9553174d46a9cfa6f411bfc486eb13d 100644
--- a/examples/js/shaders/HorizontalTiltShiftShader.js
+++ b/examples/js/shaders/HorizontalTiltShiftShader.js
@@ -14,8 +14,8 @@ THREE.HorizontalTiltShiftShader = {
uniforms: {
"tDiffuse": { value: null },
- "h": { value: 1.0 / 512.0 },
- "r": { value: 0.35 }
+ "h": { value: 1.0 / 512.0 },
+ "r": { value: 0.35 }
},
diff --git a/examples/js/shaders/HueSaturationShader.js b/examples/js/shaders/HueSaturationShader.js
index e22186c9438d3bc2f4639bc51f83e3003ba6d255..8141a1de04a07dc0a0f6a4387dc90fa961ad156c 100644
--- a/examples/js/shaders/HueSaturationShader.js
+++ b/examples/js/shaders/HueSaturationShader.js
@@ -11,8 +11,8 @@ THREE.HueSaturationShader = {
uniforms: {
- "tDiffuse": { value: null },
- "hue": { value: 0 },
+ "tDiffuse": { value: null },
+ "hue": { value: 0 },
"saturation": { value: 0 }
},
diff --git a/examples/js/shaders/KaleidoShader.js b/examples/js/shaders/KaleidoShader.js
index a1ac47cb28b7813ed5377591b7f4c7096ed00966..459570e2c73c7987ee0c7022d61d990755cc77b6 100644
--- a/examples/js/shaders/KaleidoShader.js
+++ b/examples/js/shaders/KaleidoShader.js
@@ -15,8 +15,8 @@ THREE.KaleidoShader = {
uniforms: {
"tDiffuse": { value: null },
- "sides": { value: 6.0 },
- "angle": { value: 0.0 }
+ "sides": { value: 6.0 },
+ "angle": { value: 0.0 }
},
@@ -38,7 +38,7 @@ THREE.KaleidoShader = {
"uniform sampler2D tDiffuse;",
"uniform float sides;",
"uniform float angle;",
-
+
"varying vec2 vUv;",
"void main() {",
diff --git a/examples/js/shaders/LuminosityHighPassShader.js b/examples/js/shaders/LuminosityHighPassShader.js
index 54e4973d7a05659551a5864ae83f61ef9bc5594b..573deb906edc4ceb063cd9db804c6734e4b6d35e 100644
--- a/examples/js/shaders/LuminosityHighPassShader.js
+++ b/examples/js/shaders/LuminosityHighPassShader.js
@@ -7,7 +7,7 @@
THREE.LuminosityHighPassShader = {
- shaderID: "luminosityHighPass",
+ shaderID: "luminosityHighPass",
uniforms: {
@@ -15,7 +15,7 @@ THREE.LuminosityHighPassShader = {
"luminosityThreshold": { value: 1.0 },
"smoothWidth": { value: 1.0 },
"defaultColor": { value: new THREE.Color( 0x000000 ) },
- "defaultOpacity": { value: 0.0 }
+ "defaultOpacity": { value: 0.0 }
},
diff --git a/examples/js/shaders/MirrorShader.js b/examples/js/shaders/MirrorShader.js
index 83f7e4fd711a72b904f6efc2076128140a14027e..129919ae71797fb2777974c042667ee5dbbaeb1f 100644
--- a/examples/js/shaders/MirrorShader.js
+++ b/examples/js/shaders/MirrorShader.js
@@ -12,7 +12,7 @@ THREE.MirrorShader = {
uniforms: {
"tDiffuse": { value: null },
- "side": { value: 1 }
+ "side": { value: 1 }
},
@@ -33,7 +33,7 @@ THREE.MirrorShader = {
"uniform sampler2D tDiffuse;",
"uniform int side;",
-
+
"varying vec2 vUv;",
"void main() {",
diff --git a/examples/js/shaders/NormalMapShader.js b/examples/js/shaders/NormalMapShader.js
index 957e818f509f4f373ed0f646236b2ccd5eb04b8f..6e3241fe546fc905efa355f06378670a60b5abd1 100644
--- a/examples/js/shaders/NormalMapShader.js
+++ b/examples/js/shaders/NormalMapShader.js
@@ -9,10 +9,10 @@ THREE.NormalMapShader = {
uniforms: {
- "heightMap": { value: null },
+ "heightMap": { value: null },
"resolution": { value: new THREE.Vector2( 512, 512 ) },
- "scale": { value: new THREE.Vector2( 1, 1 ) },
- "height": { value: 0.05 }
+ "scale": { value: new THREE.Vector2( 1, 1 ) },
+ "height": { value: 0.05 }
},
diff --git a/examples/js/shaders/RGBShiftShader.js b/examples/js/shaders/RGBShiftShader.js
index 2740b9c4a8565daaff5e0fa0cd4cb9f2c88918fd..c88b7fd84e1168e05a835bf6fca2ce8c9d7bca28 100644
--- a/examples/js/shaders/RGBShiftShader.js
+++ b/examples/js/shaders/RGBShiftShader.js
@@ -15,8 +15,8 @@ THREE.RGBShiftShader = {
uniforms: {
"tDiffuse": { value: null },
- "amount": { value: 0.005 },
- "angle": { value: 0.0 }
+ "amount": { value: 0.005 },
+ "angle": { value: 0.0 }
},
diff --git a/examples/js/shaders/SAOShader.js b/examples/js/shaders/SAOShader.js
index 5d58d59372cea0c5975e9ee411b2f8e023389c59..2221558f69b0648f739fad00dff5e958215447e6 100644
--- a/examples/js/shaders/SAOShader.js
+++ b/examples/js/shaders/SAOShader.js
@@ -1,3 +1,7 @@
+/**
+ * TODO
+ */
+
THREE.SAOShader = {
defines: {
'NUM_SAMPLES': 7,
diff --git a/examples/js/shaders/SepiaShader.js b/examples/js/shaders/SepiaShader.js
index 0a296083e5cef4895702f04c1e47612e9154561e..9792d7f70d1d3065bcd6eb947ec252cd2dc25898 100644
--- a/examples/js/shaders/SepiaShader.js
+++ b/examples/js/shaders/SepiaShader.js
@@ -11,7 +11,7 @@ THREE.SepiaShader = {
uniforms: {
"tDiffuse": { value: null },
- "amount": { value: 1.0 }
+ "amount": { value: 1.0 }
},
diff --git a/examples/js/shaders/UnpackDepthRGBAShader.js b/examples/js/shaders/UnpackDepthRGBAShader.js
index 55f34a2b0d455b0d5310e80831da35ea86b678ba..6a9c774ca70bc63ffeb6ddb07b8070511d55ee98 100644
--- a/examples/js/shaders/UnpackDepthRGBAShader.js
+++ b/examples/js/shaders/UnpackDepthRGBAShader.js
@@ -10,7 +10,7 @@ THREE.UnpackDepthRGBAShader = {
uniforms: {
"tDiffuse": { value: null },
- "opacity": { value: 1.0 }
+ "opacity": { value: 1.0 }
},
diff --git a/examples/js/shaders/VerticalBlurShader.js b/examples/js/shaders/VerticalBlurShader.js
index 80f6e901fbf29c8602e377ef01b6b0ab4bef7b58..34f49a53380462307131ecf7dbb169235f898da3 100644
--- a/examples/js/shaders/VerticalBlurShader.js
+++ b/examples/js/shaders/VerticalBlurShader.js
@@ -15,7 +15,7 @@ THREE.VerticalBlurShader = {
uniforms: {
"tDiffuse": { value: null },
- "v": { value: 1.0 / 512.0 }
+ "v": { value: 1.0 / 512.0 }
},
diff --git a/examples/js/shaders/VerticalTiltShiftShader.js b/examples/js/shaders/VerticalTiltShiftShader.js
index ad8ff70c9024ee27aa7436702143751491e49927..a6443505cab97cbbceb2b95c67a30e89163641b4 100644
--- a/examples/js/shaders/VerticalTiltShiftShader.js
+++ b/examples/js/shaders/VerticalTiltShiftShader.js
@@ -14,8 +14,8 @@ THREE.VerticalTiltShiftShader = {
uniforms: {
"tDiffuse": { value: null },
- "v": { value: 1.0 / 512.0 },
- "r": { value: 0.35 }
+ "v": { value: 1.0 / 512.0 },
+ "r": { value: 0.35 }
},
diff --git a/examples/js/shaders/VignetteShader.js b/examples/js/shaders/VignetteShader.js
index 81d9215351c97eeeebf3522b19e9e43e0b4c4a8f..8547fa52a389a8fa390748da66c9befc40916ec0 100644
--- a/examples/js/shaders/VignetteShader.js
+++ b/examples/js/shaders/VignetteShader.js
@@ -11,7 +11,7 @@ THREE.VignetteShader = {
uniforms: {
"tDiffuse": { value: null },
- "offset": { value: 1.0 },
+ "offset": { value: 1.0 },
"darkness": { value: 1.0 }
},
diff --git a/examples/jsm/shaders/AfterimageShader.d.ts b/examples/jsm/shaders/AfterimageShader.d.ts
new file mode 100644
index 0000000000000000000000000000000000000000..49b65b074f07669fc2fd3209adaf6fd057f00346
--- /dev/null
+++ b/examples/jsm/shaders/AfterimageShader.d.ts
@@ -0,0 +1,13 @@
+import {
+ Uniform
+} from '../../../src/Three';
+
+export interface AfterimageShader {
+ uniforms: {
+ damp: Uniform;
+ tOld: Uniform;
+ tNew: Uniform;
+ };
+ vertexShader: string;
+ fragmentShader: string;
+}
diff --git a/examples/jsm/shaders/AfterimageShader.js b/examples/jsm/shaders/AfterimageShader.js
new file mode 100644
index 0000000000000000000000000000000000000000..2cea85ae59ee81a21145568042a01d691e7f7c14
--- /dev/null
+++ b/examples/jsm/shaders/AfterimageShader.js
@@ -0,0 +1,64 @@
+/**
+ * @author HypnosNova / https://www.threejs.org.cn/gallery/
+ *
+ * Afterimage shader
+ * I created this effect inspired by a demo on codepen:
+ * https://codepen.io/brunoimbrizi/pen/MoRJaN?page=1&
+ */
+
+
+
+var AfterimageShader = {
+
+ uniforms: {
+
+ "damp": { value: 0.96 },
+ "tOld": { value: null },
+ "tNew": { value: null }
+
+ },
+
+ vertexShader: [
+
+ "varying vec2 vUv;",
+
+ "void main() {",
+
+ "vUv = uv;",
+ "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );",
+
+ "}"
+
+ ].join( "\n" ),
+
+ fragmentShader: [
+
+ "uniform float damp;",
+
+ "uniform sampler2D tOld;",
+ "uniform sampler2D tNew;",
+
+ "varying vec2 vUv;",
+
+ "vec4 when_gt( vec4 x, float y ) {",
+
+ "return max( sign( x - y ), 0.0 );",
+
+ "}",
+
+ "void main() {",
+
+ "vec4 texelOld = texture2D( tOld, vUv );",
+ "vec4 texelNew = texture2D( tNew, vUv );",
+
+ "texelOld *= damp * when_gt( texelOld, 0.1 );",
+
+ "gl_FragColor = max(texelNew, texelOld);",
+
+ "}"
+
+ ].join( "\n" )
+
+};
+
+export { AfterimageShader };
diff --git a/examples/jsm/shaders/BasicShader.d.ts b/examples/jsm/shaders/BasicShader.d.ts
new file mode 100644
index 0000000000000000000000000000000000000000..d66242ccc30577f87e1347d9bc2b53ed147640ec
--- /dev/null
+++ b/examples/jsm/shaders/BasicShader.d.ts
@@ -0,0 +1,9 @@
+import {
+ Uniform
+} from '../../../src/Three';
+
+export interface BasicShader {
+ uniforms: {};
+ vertexShader: string;
+ fragmentShader: string;
+}
diff --git a/examples/jsm/shaders/BasicShader.js b/examples/jsm/shaders/BasicShader.js
new file mode 100644
index 0000000000000000000000000000000000000000..58aa922ad2ef799abf345bacb5046e63b392b56b
--- /dev/null
+++ b/examples/jsm/shaders/BasicShader.js
@@ -0,0 +1,35 @@
+/**
+ * @author mrdoob / http://www.mrdoob.com
+ *
+ * Simple test shader
+ */
+
+
+
+var BasicShader = {
+
+ uniforms: {},
+
+ vertexShader: [
+
+ "void main() {",
+
+ "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );",
+
+ "}"
+
+ ].join( "\n" ),
+
+ fragmentShader: [
+
+ "void main() {",
+
+ "gl_FragColor = vec4( 1.0, 0.0, 0.0, 0.5 );",
+
+ "}"
+
+ ].join( "\n" )
+
+};
+
+export { BasicShader };
diff --git a/examples/jsm/shaders/BleachBypassShader.d.ts b/examples/jsm/shaders/BleachBypassShader.d.ts
new file mode 100644
index 0000000000000000000000000000000000000000..aec43cc26850e70bce4f861cf7d3dfa8300cf6e2
--- /dev/null
+++ b/examples/jsm/shaders/BleachBypassShader.d.ts
@@ -0,0 +1,12 @@
+import {
+ Uniform
+} from '../../../src/Three';
+
+export interface BleachBypassShader {
+ uniforms: {
+ tDiffuse: Uniform;
+ opacity: Uniform;
+ };
+ vertexShader: string;
+ fragmentShader: string;
+}
diff --git a/examples/jsm/shaders/BleachBypassShader.js b/examples/jsm/shaders/BleachBypassShader.js
new file mode 100644
index 0000000000000000000000000000000000000000..893d9c83d7dafccbabed2f2de6be16fb276109f0
--- /dev/null
+++ b/examples/jsm/shaders/BleachBypassShader.js
@@ -0,0 +1,68 @@
+/**
+ * @author alteredq / http://alteredqualia.com/
+ *
+ * Bleach bypass shader [http://en.wikipedia.org/wiki/Bleach_bypass]
+ * - based on Nvidia example
+ * http://developer.download.nvidia.com/shaderlibrary/webpages/shader_library.html#post_bleach_bypass
+ */
+
+
+
+var BleachBypassShader = {
+
+ uniforms: {
+
+ "tDiffuse": { value: null },
+ "opacity": { value: 1.0 }
+
+ },
+
+ vertexShader: [
+
+ "varying vec2 vUv;",
+
+ "void main() {",
+
+ "vUv = uv;",
+ "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );",
+
+ "}"
+
+ ].join( "\n" ),
+
+ fragmentShader: [
+
+ "uniform float opacity;",
+
+ "uniform sampler2D tDiffuse;",
+
+ "varying vec2 vUv;",
+
+ "void main() {",
+
+ "vec4 base = texture2D( tDiffuse, vUv );",
+
+ "vec3 lumCoeff = vec3( 0.25, 0.65, 0.1 );",
+ "float lum = dot( lumCoeff, base.rgb );",
+ "vec3 blend = vec3( lum );",
+
+ "float L = min( 1.0, max( 0.0, 10.0 * ( lum - 0.45 ) ) );",
+
+ "vec3 result1 = 2.0 * base.rgb * blend;",
+ "vec3 result2 = 1.0 - 2.0 * ( 1.0 - blend ) * ( 1.0 - base.rgb );",
+
+ "vec3 newColor = mix( result1, result2, L );",
+
+ "float A2 = opacity * base.a;",
+ "vec3 mixRGB = A2 * newColor.rgb;",
+ "mixRGB += ( ( 1.0 - A2 ) * base.rgb );",
+
+ "gl_FragColor = vec4( mixRGB, base.a );",
+
+ "}"
+
+ ].join( "\n" )
+
+};
+
+export { BleachBypassShader };
diff --git a/examples/jsm/shaders/BlendShader.d.ts b/examples/jsm/shaders/BlendShader.d.ts
new file mode 100644
index 0000000000000000000000000000000000000000..682e6536cbbd58b64968646d38f064cc734eb784
--- /dev/null
+++ b/examples/jsm/shaders/BlendShader.d.ts
@@ -0,0 +1,14 @@
+import {
+ Uniform
+} from '../../../src/Three';
+
+export interface BlendShader {
+ uniforms: {
+ tDiffuse1: Uniform;
+ tDiffuse2: Uniform;
+ mixRatio: Uniform;
+ opacity: Uniform;
+ };
+ vertexShader: string;
+ fragmentShader: string;
+}
diff --git a/examples/jsm/shaders/BlendShader.js b/examples/jsm/shaders/BlendShader.js
new file mode 100644
index 0000000000000000000000000000000000000000..aa6ce4c23f31b09eafe7ec28b3d6485985747595
--- /dev/null
+++ b/examples/jsm/shaders/BlendShader.js
@@ -0,0 +1,55 @@
+/**
+ * @author alteredq / http://alteredqualia.com/
+ *
+ * Blend two textures
+ */
+
+
+
+var BlendShader = {
+
+ uniforms: {
+
+ "tDiffuse1": { value: null },
+ "tDiffuse2": { value: null },
+ "mixRatio": { value: 0.5 },
+ "opacity": { value: 1.0 }
+
+ },
+
+ vertexShader: [
+
+ "varying vec2 vUv;",
+
+ "void main() {",
+
+ "vUv = uv;",
+ "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );",
+
+ "}"
+
+ ].join( "\n" ),
+
+ fragmentShader: [
+
+ "uniform float opacity;",
+ "uniform float mixRatio;",
+
+ "uniform sampler2D tDiffuse1;",
+ "uniform sampler2D tDiffuse2;",
+
+ "varying vec2 vUv;",
+
+ "void main() {",
+
+ "vec4 texel1 = texture2D( tDiffuse1, vUv );",
+ "vec4 texel2 = texture2D( tDiffuse2, vUv );",
+ "gl_FragColor = opacity * mix( texel1, texel2, mixRatio );",
+
+ "}"
+
+ ].join( "\n" )
+
+};
+
+export { BlendShader };
diff --git a/examples/jsm/shaders/BokehShader.d.ts b/examples/jsm/shaders/BokehShader.d.ts
new file mode 100644
index 0000000000000000000000000000000000000000..3cf57b8481bde20d0f0de7566969bb3579eaa273
--- /dev/null
+++ b/examples/jsm/shaders/BokehShader.d.ts
@@ -0,0 +1,22 @@
+import {
+ Uniform
+} from '../../../src/Three';
+
+export interface BokehShader {
+ defines: {
+ DEPTH_PACKING: number;
+ PERSPECTIVE_CAMERA: number;
+ }
+ uniforms: {
+ tColor: Uniform;
+ tDepth: Uniform;
+ focus: Uniform;
+ aspect: Uniform;
+ aperture: Uniform;
+ maxblur: Uniform;
+ nearClip: Uniform;
+ farClip: Uniform;
+ };
+ vertexShader: string;
+ fragmentShader: string;
+}
diff --git a/examples/jsm/shaders/BokehShader.js b/examples/jsm/shaders/BokehShader.js
new file mode 100644
index 0000000000000000000000000000000000000000..4426c87b4dcac79047d6588427e0a15a56dbf769
--- /dev/null
+++ b/examples/jsm/shaders/BokehShader.js
@@ -0,0 +1,150 @@
+/**
+ * @author alteredq / http://alteredqualia.com/
+ *
+ * Depth-of-field shader with bokeh
+ * ported from GLSL shader by Martins Upitis
+ * http://artmartinsh.blogspot.com/2010/02/glsl-lens-blur-filter-with-bokeh.html
+ */
+
+
+
+var BokehShader = {
+
+ defines: {
+ "DEPTH_PACKING": 1,
+ "PERSPECTIVE_CAMERA": 1,
+ },
+
+ uniforms: {
+
+ "tColor": { value: null },
+ "tDepth": { value: null },
+ "focus": { value: 1.0 },
+ "aspect": { value: 1.0 },
+ "aperture": { value: 0.025 },
+ "maxblur": { value: 1.0 },
+ "nearClip": { value: 1.0 },
+ "farClip": { value: 1000.0 },
+
+ },
+
+ vertexShader: [
+
+ "varying vec2 vUv;",
+
+ "void main() {",
+
+ "vUv = uv;",
+ "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );",
+
+ "}"
+
+ ].join( "\n" ),
+
+ fragmentShader: [
+ "#include ",
+
+ "varying vec2 vUv;",
+
+ "uniform sampler2D tColor;",
+ "uniform sampler2D tDepth;",
+
+ "uniform float maxblur;", // max blur amount
+ "uniform float aperture;", // aperture - bigger values for shallower depth of field
+
+ "uniform float nearClip;",
+ "uniform float farClip;",
+
+ "uniform float focus;",
+ "uniform float aspect;",
+
+ "#include ",
+
+ "float getDepth( const in vec2 screenPosition ) {",
+ " #if DEPTH_PACKING == 1",
+ " return unpackRGBAToDepth( texture2D( tDepth, screenPosition ) );",
+ " #else",
+ " return texture2D( tDepth, screenPosition ).x;",
+ " #endif",
+ "}",
+
+ "float getViewZ( const in float depth ) {",
+ " #if PERSPECTIVE_CAMERA == 1",
+ " return perspectiveDepthToViewZ( depth, nearClip, farClip );",
+ " #else",
+ " return orthographicDepthToViewZ( depth, nearClip, farClip );",
+ " #endif",
+ "}",
+
+
+ "void main() {",
+
+ "vec2 aspectcorrect = vec2( 1.0, aspect );",
+
+ "float viewZ = getViewZ( getDepth( vUv ) );",
+
+ "float factor = ( focus + viewZ );", // viewZ is <= 0, so this is a difference equation
+
+ "vec2 dofblur = vec2 ( clamp( factor * aperture, -maxblur, maxblur ) );",
+
+ "vec2 dofblur9 = dofblur * 0.9;",
+ "vec2 dofblur7 = dofblur * 0.7;",
+ "vec2 dofblur4 = dofblur * 0.4;",
+
+ "vec4 col = vec4( 0.0 );",
+
+ "col += texture2D( tColor, vUv.xy );",
+ "col += texture2D( tColor, vUv.xy + ( vec2( 0.0, 0.4 ) * aspectcorrect ) * dofblur );",
+ "col += texture2D( tColor, vUv.xy + ( vec2( 0.15, 0.37 ) * aspectcorrect ) * dofblur );",
+ "col += texture2D( tColor, vUv.xy + ( vec2( 0.29, 0.29 ) * aspectcorrect ) * dofblur );",
+ "col += texture2D( tColor, vUv.xy + ( vec2( -0.37, 0.15 ) * aspectcorrect ) * dofblur );",
+ "col += texture2D( tColor, vUv.xy + ( vec2( 0.40, 0.0 ) * aspectcorrect ) * dofblur );",
+ "col += texture2D( tColor, vUv.xy + ( vec2( 0.37, -0.15 ) * aspectcorrect ) * dofblur );",
+ "col += texture2D( tColor, vUv.xy + ( vec2( 0.29, -0.29 ) * aspectcorrect ) * dofblur );",
+ "col += texture2D( tColor, vUv.xy + ( vec2( -0.15, -0.37 ) * aspectcorrect ) * dofblur );",
+ "col += texture2D( tColor, vUv.xy + ( vec2( 0.0, -0.4 ) * aspectcorrect ) * dofblur );",
+ "col += texture2D( tColor, vUv.xy + ( vec2( -0.15, 0.37 ) * aspectcorrect ) * dofblur );",
+ "col += texture2D( tColor, vUv.xy + ( vec2( -0.29, 0.29 ) * aspectcorrect ) * dofblur );",
+ "col += texture2D( tColor, vUv.xy + ( vec2( 0.37, 0.15 ) * aspectcorrect ) * dofblur );",
+ "col += texture2D( tColor, vUv.xy + ( vec2( -0.4, 0.0 ) * aspectcorrect ) * dofblur );",
+ "col += texture2D( tColor, vUv.xy + ( vec2( -0.37, -0.15 ) * aspectcorrect ) * dofblur );",
+ "col += texture2D( tColor, vUv.xy + ( vec2( -0.29, -0.29 ) * aspectcorrect ) * dofblur );",
+ "col += texture2D( tColor, vUv.xy + ( vec2( 0.15, -0.37 ) * aspectcorrect ) * dofblur );",
+
+ "col += texture2D( tColor, vUv.xy + ( vec2( 0.15, 0.37 ) * aspectcorrect ) * dofblur9 );",
+ "col += texture2D( tColor, vUv.xy + ( vec2( -0.37, 0.15 ) * aspectcorrect ) * dofblur9 );",
+ "col += texture2D( tColor, vUv.xy + ( vec2( 0.37, -0.15 ) * aspectcorrect ) * dofblur9 );",
+ "col += texture2D( tColor, vUv.xy + ( vec2( -0.15, -0.37 ) * aspectcorrect ) * dofblur9 );",
+ "col += texture2D( tColor, vUv.xy + ( vec2( -0.15, 0.37 ) * aspectcorrect ) * dofblur9 );",
+ "col += texture2D( tColor, vUv.xy + ( vec2( 0.37, 0.15 ) * aspectcorrect ) * dofblur9 );",
+ "col += texture2D( tColor, vUv.xy + ( vec2( -0.37, -0.15 ) * aspectcorrect ) * dofblur9 );",
+ "col += texture2D( tColor, vUv.xy + ( vec2( 0.15, -0.37 ) * aspectcorrect ) * dofblur9 );",
+
+ "col += texture2D( tColor, vUv.xy + ( vec2( 0.29, 0.29 ) * aspectcorrect ) * dofblur7 );",
+ "col += texture2D( tColor, vUv.xy + ( vec2( 0.40, 0.0 ) * aspectcorrect ) * dofblur7 );",
+ "col += texture2D( tColor, vUv.xy + ( vec2( 0.29, -0.29 ) * aspectcorrect ) * dofblur7 );",
+ "col += texture2D( tColor, vUv.xy + ( vec2( 0.0, -0.4 ) * aspectcorrect ) * dofblur7 );",
+ "col += texture2D( tColor, vUv.xy + ( vec2( -0.29, 0.29 ) * aspectcorrect ) * dofblur7 );",
+ "col += texture2D( tColor, vUv.xy + ( vec2( -0.4, 0.0 ) * aspectcorrect ) * dofblur7 );",
+ "col += texture2D( tColor, vUv.xy + ( vec2( -0.29, -0.29 ) * aspectcorrect ) * dofblur7 );",
+ "col += texture2D( tColor, vUv.xy + ( vec2( 0.0, 0.4 ) * aspectcorrect ) * dofblur7 );",
+
+ "col += texture2D( tColor, vUv.xy + ( vec2( 0.29, 0.29 ) * aspectcorrect ) * dofblur4 );",
+ "col += texture2D( tColor, vUv.xy + ( vec2( 0.4, 0.0 ) * aspectcorrect ) * dofblur4 );",
+ "col += texture2D( tColor, vUv.xy + ( vec2( 0.29, -0.29 ) * aspectcorrect ) * dofblur4 );",
+ "col += texture2D( tColor, vUv.xy + ( vec2( 0.0, -0.4 ) * aspectcorrect ) * dofblur4 );",
+ "col += texture2D( tColor, vUv.xy + ( vec2( -0.29, 0.29 ) * aspectcorrect ) * dofblur4 );",
+ "col += texture2D( tColor, vUv.xy + ( vec2( -0.4, 0.0 ) * aspectcorrect ) * dofblur4 );",
+ "col += texture2D( tColor, vUv.xy + ( vec2( -0.29, -0.29 ) * aspectcorrect ) * dofblur4 );",
+ "col += texture2D( tColor, vUv.xy + ( vec2( 0.0, 0.4 ) * aspectcorrect ) * dofblur4 );",
+
+ "gl_FragColor = col / 41.0;",
+ "gl_FragColor.a = 1.0;",
+
+ "}"
+
+ ].join( "\n" )
+
+};
+
+export { BokehShader };
diff --git a/examples/jsm/shaders/BokehShader2.d.ts b/examples/jsm/shaders/BokehShader2.d.ts
index 870f60d25f11bd4b093e2ba4c867395357b8424c..e7bc883b3b61ec463c16f96bf07bff1cb7abb384 100644
--- a/examples/jsm/shaders/BokehShader2.d.ts
+++ b/examples/jsm/shaders/BokehShader2.d.ts
@@ -29,7 +29,7 @@ export interface BokehShader {
focusCoords: Uniform;
};
vertexShader: string;
- fragmentShader:string;
+ fragmentShader: string;
}
export interface BokehDepthShader {
@@ -38,5 +38,5 @@ export interface BokehDepthShader {
mFar: Uniform;
};
vertexShader: string;
- fragmentShader:string;
+ fragmentShader: string;
}
diff --git a/examples/jsm/shaders/BrightnessContrastShader.d.ts b/examples/jsm/shaders/BrightnessContrastShader.d.ts
new file mode 100644
index 0000000000000000000000000000000000000000..161ba0d473aa3f80049d709bba5a01e1f7f525a3
--- /dev/null
+++ b/examples/jsm/shaders/BrightnessContrastShader.d.ts
@@ -0,0 +1,13 @@
+import {
+ Uniform
+} from '../../../src/Three';
+
+export interface BrightnessContrastShader {
+ uniforms: {
+ tDiffuse: Uniform;
+ brightness: Uniform;
+ contrast: Uniform;
+ };
+ vertexShader: string;
+ fragmentShader: string;
+}
diff --git a/examples/jsm/shaders/BrightnessContrastShader.js b/examples/jsm/shaders/BrightnessContrastShader.js
new file mode 100644
index 0000000000000000000000000000000000000000..ef510018ca11ac34408b7309997e090c4363df18
--- /dev/null
+++ b/examples/jsm/shaders/BrightnessContrastShader.js
@@ -0,0 +1,62 @@
+/**
+ * @author tapio / http://tapio.github.com/
+ *
+ * Brightness and contrast adjustment
+ * https://github.com/evanw/glfx.js
+ * brightness: -1 to 1 (-1 is solid black, 0 is no change, and 1 is solid white)
+ * contrast: -1 to 1 (-1 is solid gray, 0 is no change, and 1 is maximum contrast)
+ */
+
+
+
+var BrightnessContrastShader = {
+
+ uniforms: {
+
+ "tDiffuse": { value: null },
+ "brightness": { value: 0 },
+ "contrast": { value: 0 }
+
+ },
+
+ vertexShader: [
+
+ "varying vec2 vUv;",
+
+ "void main() {",
+
+ "vUv = uv;",
+
+ "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );",
+
+ "}"
+
+ ].join( "\n" ),
+
+ fragmentShader: [
+
+ "uniform sampler2D tDiffuse;",
+ "uniform float brightness;",
+ "uniform float contrast;",
+
+ "varying vec2 vUv;",
+
+ "void main() {",
+
+ "gl_FragColor = texture2D( tDiffuse, vUv );",
+
+ "gl_FragColor.rgb += brightness;",
+
+ "if (contrast > 0.0) {",
+ "gl_FragColor.rgb = (gl_FragColor.rgb - 0.5) / (1.0 - contrast) + 0.5;",
+ "} else {",
+ "gl_FragColor.rgb = (gl_FragColor.rgb - 0.5) * (1.0 + contrast) + 0.5;",
+ "}",
+
+ "}"
+
+ ].join( "\n" )
+
+};
+
+export { BrightnessContrastShader };
diff --git a/examples/jsm/shaders/ColorCorrectionShader.d.ts b/examples/jsm/shaders/ColorCorrectionShader.d.ts
new file mode 100644
index 0000000000000000000000000000000000000000..31b226e69d0e0eb6f6cee17450c1d412cc310645
--- /dev/null
+++ b/examples/jsm/shaders/ColorCorrectionShader.d.ts
@@ -0,0 +1,14 @@
+import {
+ Uniform
+} from '../../../src/Three';
+
+export interface ColorCorrectionShader {
+ uniforms: {
+ tDiffuse: Uniform;
+ powRGB: Uniform;
+ mulRGB: Uniform;
+ addRGB: Uniform;
+ };
+ vertexShader: string;
+ fragmentShader: string;
+}
diff --git a/examples/jsm/shaders/ColorCorrectionShader.js b/examples/jsm/shaders/ColorCorrectionShader.js
new file mode 100644
index 0000000000000000000000000000000000000000..fd498c689ba36d01ba81a8c01447450d91a4b780
--- /dev/null
+++ b/examples/jsm/shaders/ColorCorrectionShader.js
@@ -0,0 +1,56 @@
+/**
+ * @author alteredq / http://alteredqualia.com/
+ *
+ * Color correction
+ */
+
+import {
+ Vector3
+} from "../../../build/three.module.js";
+
+var ColorCorrectionShader = {
+
+ uniforms: {
+
+ "tDiffuse": { value: null },
+ "powRGB": { value: new Vector3( 2, 2, 2 ) },
+ "mulRGB": { value: new Vector3( 1, 1, 1 ) },
+ "addRGB": { value: new Vector3( 0, 0, 0 ) }
+
+ },
+
+ vertexShader: [
+
+ "varying vec2 vUv;",
+
+ "void main() {",
+
+ "vUv = uv;",
+
+ "gl_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() {",
+
+ "gl_FragColor = texture2D( tDiffuse, vUv );",
+ "gl_FragColor.rgb = mulRGB * pow( ( gl_FragColor.rgb + addRGB ), powRGB );",
+
+ "}"
+
+ ].join( "\n" )
+
+};
+
+export { ColorCorrectionShader };
diff --git a/examples/jsm/shaders/ColorifyShader.d.ts b/examples/jsm/shaders/ColorifyShader.d.ts
new file mode 100644
index 0000000000000000000000000000000000000000..08f38136998dddc2463533290a99b64941e04f58
--- /dev/null
+++ b/examples/jsm/shaders/ColorifyShader.d.ts
@@ -0,0 +1,12 @@
+import {
+ Uniform
+} from '../../../src/Three';
+
+export interface ColorifyShader {
+ uniforms: {
+ tDiffuse: Uniform;
+ color: Uniform;
+ };
+ vertexShader: string;
+ fragmentShader: string;
+}
diff --git a/examples/jsm/shaders/ColorifyShader.js b/examples/jsm/shaders/ColorifyShader.js
new file mode 100644
index 0000000000000000000000000000000000000000..dca228ba3e8a118a49916911c65b691560b32fc1
--- /dev/null
+++ b/examples/jsm/shaders/ColorifyShader.js
@@ -0,0 +1,55 @@
+/**
+ * @author alteredq / http://alteredqualia.com/
+ *
+ * Colorify shader
+ */
+
+import {
+ Color
+} from "../../../build/three.module.js";
+
+var ColorifyShader = {
+
+ uniforms: {
+
+ "tDiffuse": { value: null },
+ "color": { value: new Color( 0xffffff ) }
+
+ },
+
+ vertexShader: [
+
+ "varying vec2 vUv;",
+
+ "void main() {",
+
+ "vUv = uv;",
+ "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );",
+
+ "}"
+
+ ].join( "\n" ),
+
+ fragmentShader: [
+
+ "uniform vec3 color;",
+ "uniform sampler2D tDiffuse;",
+
+ "varying vec2 vUv;",
+
+ "void main() {",
+
+ "vec4 texel = texture2D( tDiffuse, vUv );",
+
+ "vec3 luma = vec3( 0.299, 0.587, 0.114 );",
+ "float v = dot( texel.xyz, luma );",
+
+ "gl_FragColor = vec4( v * color, texel.w );",
+
+ "}"
+
+ ].join( "\n" )
+
+};
+
+export { ColorifyShader };
diff --git a/examples/jsm/shaders/ConvolutionShader.d.ts b/examples/jsm/shaders/ConvolutionShader.d.ts
new file mode 100644
index 0000000000000000000000000000000000000000..454cd15a847012bbb89cce40c9bd04324594073b
--- /dev/null
+++ b/examples/jsm/shaders/ConvolutionShader.d.ts
@@ -0,0 +1,19 @@
+import {
+ Uniform
+} from '../../../src/Three';
+
+export interface ConvolutionShader {
+ defines: {
+ KERNEL_SIZE_FLOAT: string;
+ KERNEL_SIZE_INT: string;
+ },
+ uniforms: {
+ tDiffuse: Uniform;
+ uImageIncrement: Uniform;
+ cKernel: Uniform;
+ };
+ vertexShader: string;
+ fragmentShader: string;
+
+ buildKernel(sigma: number): number[];
+}
diff --git a/examples/jsm/shaders/ConvolutionShader.js b/examples/jsm/shaders/ConvolutionShader.js
new file mode 100644
index 0000000000000000000000000000000000000000..2dd80b4f733e5be09bb4264b1bc7e6e65c7fcfb3
--- /dev/null
+++ b/examples/jsm/shaders/ConvolutionShader.js
@@ -0,0 +1,107 @@
+/**
+ * @author alteredq / http://alteredqualia.com/
+ *
+ * Convolution shader
+ * ported from o3d sample to WebGL / GLSL
+ * http://o3d.googlecode.com/svn/trunk/samples/convolution.html
+ */
+
+import {
+ Vector2
+} from "../../../build/three.module.js";
+
+var ConvolutionShader = {
+
+ defines: {
+
+ "KERNEL_SIZE_FLOAT": "25.0",
+ "KERNEL_SIZE_INT": "25"
+
+ },
+
+ uniforms: {
+
+ "tDiffuse": { value: null },
+ "uImageIncrement": { value: new Vector2( 0.001953125, 0.0 ) },
+ "cKernel": { value: [] }
+
+ },
+
+ vertexShader: [
+
+ "uniform vec2 uImageIncrement;",
+
+ "varying vec2 vUv;",
+
+ "void main() {",
+
+ "vUv = uv - ( ( KERNEL_SIZE_FLOAT - 1.0 ) / 2.0 ) * uImageIncrement;",
+ "gl_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() {",
+
+ "vec2 imageCoord = vUv;",
+ "vec4 sum = vec4( 0.0, 0.0, 0.0, 0.0 );",
+
+ "for( int i = 0; i < KERNEL_SIZE_INT; i ++ ) {",
+
+ "sum += texture2D( tDiffuse, imageCoord ) * cKernel[ i ];",
+ "imageCoord += uImageIncrement;",
+
+ "}",
+
+ "gl_FragColor = sum;",
+
+ "}"
+
+
+ ].join( "\n" ),
+
+ buildKernel: function ( sigma ) {
+
+ // We lop off the sqrt(2 * pi) * sigma term, since we're going to normalize anyway.
+
+ function gauss( x, sigma ) {
+
+ return Math.exp( - ( x * x ) / ( 2.0 * sigma * sigma ) );
+
+ }
+
+ var i, values, sum, halfWidth, kMaxKernelSize = 25, kernelSize = 2 * Math.ceil( sigma * 3.0 ) + 1;
+
+ if ( kernelSize > kMaxKernelSize ) kernelSize = kMaxKernelSize;
+ halfWidth = ( kernelSize - 1 ) * 0.5;
+
+ values = new Array( kernelSize );
+ sum = 0.0;
+ for ( i = 0; i < kernelSize; ++ i ) {
+
+ values[ i ] = gauss( i - halfWidth, sigma );
+ sum += values[ i ];
+
+ }
+
+ // normalize the kernel
+
+ for ( i = 0; i < kernelSize; ++ i ) values[ i ] /= sum;
+
+ return values;
+
+ }
+
+};
+
+export { ConvolutionShader };
diff --git a/examples/jsm/shaders/CopyShader.d.ts b/examples/jsm/shaders/CopyShader.d.ts
index 9d9afcef2ca689cdf74a4fe1b683fd38489ff7a1..20b54212a9993f48cb7218c535e47a9c8807b58c 100644
--- a/examples/jsm/shaders/CopyShader.d.ts
+++ b/examples/jsm/shaders/CopyShader.d.ts
@@ -8,5 +8,5 @@ export interface CopyShader {
opacity: Uniform;
};
vertexShader: string;
- fragmentShader:string;
+ fragmentShader: string;
}
diff --git a/examples/jsm/shaders/DOFMipMapShader.d.ts b/examples/jsm/shaders/DOFMipMapShader.d.ts
new file mode 100644
index 0000000000000000000000000000000000000000..0d196bf65519f0ec9ffc6e6da2d3fa53ea3a4bbd
--- /dev/null
+++ b/examples/jsm/shaders/DOFMipMapShader.d.ts
@@ -0,0 +1,14 @@
+import {
+ Uniform
+} from '../../../src/Three';
+
+export interface DOFMipMapShader {
+ uniforms: {
+ tColor: Uniform;
+ tDepth: Uniform;
+ focus: Uniform;
+ maxblur: Uniform;
+ };
+ vertexShader: string;
+ fragmentShader: string;
+}
diff --git a/examples/jsm/shaders/DOFMipMapShader.js b/examples/jsm/shaders/DOFMipMapShader.js
new file mode 100644
index 0000000000000000000000000000000000000000..dd36f847ca7d67e823e13d2bf21f63536a31a044
--- /dev/null
+++ b/examples/jsm/shaders/DOFMipMapShader.js
@@ -0,0 +1,62 @@
+/**
+ * @author alteredq / http://alteredqualia.com/
+ *
+ * Depth-of-field shader using mipmaps
+ * - from Matt Handley @applmak
+ * - requires power-of-2 sized render target with enabled mipmaps
+ */
+
+
+
+var DOFMipMapShader = {
+
+ uniforms: {
+
+ "tColor": { value: null },
+ "tDepth": { value: null },
+ "focus": { value: 1.0 },
+ "maxblur": { value: 1.0 }
+
+ },
+
+ vertexShader: [
+
+ "varying vec2 vUv;",
+
+ "void main() {",
+
+ "vUv = uv;",
+ "gl_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() {",
+
+ "vec4 depth = texture2D( tDepth, vUv );",
+
+ "float factor = depth.x - focus;",
+
+ "vec4 col = texture2D( tColor, vUv, 2.0 * maxblur * abs( focus - depth.x ) );",
+
+ "gl_FragColor = col;",
+ "gl_FragColor.a = 1.0;",
+
+ "}"
+
+ ].join( "\n" )
+
+};
+
+export { DOFMipMapShader };
diff --git a/examples/jsm/shaders/DepthLimitedBlurShader.d.ts b/examples/jsm/shaders/DepthLimitedBlurShader.d.ts
new file mode 100644
index 0000000000000000000000000000000000000000..abc761222434b08316512693a900db6ee76f2df6
--- /dev/null
+++ b/examples/jsm/shaders/DepthLimitedBlurShader.d.ts
@@ -0,0 +1,31 @@
+import {
+ Uniform,
+ Vector2,
+ Material
+} from '../../../src/Three';
+
+export interface DepthLimitedBlurShader {
+ defines: {
+ KERNEL_RADIUS: number;
+ DEPTH_PACKING: number;
+ PERSPECTIVE_CAMERA: number;
+ };
+ uniforms: {
+ tDiffuse: Uniform;
+ size: Uniform;
+ sampleUvOffsets: Uniform;
+ sampleWeights: Uniform;
+ tDepth: Uniform;
+ cameraNear: Uniform;
+ cameraFar: Uniform;
+ depthCutoff: Uniform;
+ };
+ vertexShader: string;
+ fragmentShader: string;
+}
+
+export interface BlurShaderUtils {
+ createSampleWeights(kernelRadius: number, stdDev: number): number[];
+ createSampleOffsets(kernelRadius: number, uvIncrement: Vector2): Vector2[];
+ configure(configure: Material, kernelRadius: number, stdDev: number, uvIncrement: Vector2): void;
+}
diff --git a/examples/jsm/shaders/DepthLimitedBlurShader.js b/examples/jsm/shaders/DepthLimitedBlurShader.js
new file mode 100644
index 0000000000000000000000000000000000000000..23cbff3735ef15437c9167292c41243bd78aafcb
--- /dev/null
+++ b/examples/jsm/shaders/DepthLimitedBlurShader.js
@@ -0,0 +1,165 @@
+/**
+ * TODO
+ */
+
+import {
+ Vector2
+} from "../../../build/three.module.js";
+
+var DepthLimitedBlurShader = {
+ defines: {
+ 'KERNEL_RADIUS': 4,
+ 'DEPTH_PACKING': 1,
+ 'PERSPECTIVE_CAMERA': 1
+ },
+ uniforms: {
+ 'tDiffuse': { value: null },
+ 'size': { value: new Vector2( 512, 512 ) },
+ 'sampleUvOffsets': { value: [ new Vector2( 0, 0 ) ] },
+ 'sampleWeights': { value: [ 1.0 ] },
+ 'tDepth': { value: null },
+ 'cameraNear': { value: 10 },
+ 'cameraFar': { value: 1000 },
+ 'depthCutoff': { value: 10 },
+ },
+ vertexShader: [
+ "#include ",
+
+ "uniform vec2 size;",
+
+ "varying vec2 vUv;",
+ "varying vec2 vInvSize;",
+
+ "void main() {",
+ " vUv = uv;",
+ " vInvSize = 1.0 / size;",
+
+ " gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );",
+ "}"
+
+ ].join( "\n" ),
+ fragmentShader: [
+ "#include ",
+ "#include ",
+
+ "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 ) {",
+ " #if DEPTH_PACKING == 1",
+ " return unpackRGBAToDepth( texture2D( tDepth, screenPosition ) );",
+ " #else",
+ " return texture2D( tDepth, screenPosition ).x;",
+ " #endif",
+ "}",
+
+ "float getViewZ( const in float depth ) {",
+ " #if PERSPECTIVE_CAMERA == 1",
+ " return perspectiveDepthToViewZ( depth, cameraNear, cameraFar );",
+ " #else",
+ " return orthographicDepthToViewZ( depth, cameraNear, cameraFar );",
+ " #endif",
+ "}",
+
+ "void main() {",
+ " float depth = getDepth( vUv );",
+ " if( depth >= ( 1.0 - EPSILON ) ) {",
+ " discard;",
+ " }",
+
+ " float centerViewZ = -getViewZ( depth );",
+ " bool rBreak = false, lBreak = false;",
+
+ " float weightSum = sampleWeights[0];",
+ " vec4 diffuseSum = texture2D( tDiffuse, vUv ) * weightSum;",
+
+ " for( int i = 1; i <= KERNEL_RADIUS; i ++ ) {",
+
+ " float sampleWeight = sampleWeights[i];",
+ " vec2 sampleUvOffset = sampleUvOffsets[i] * vInvSize;",
+
+ " vec2 sampleUv = vUv + sampleUvOffset;",
+ " float viewZ = -getViewZ( getDepth( sampleUv ) );",
+
+ " if( abs( viewZ - centerViewZ ) > depthCutoff ) rBreak = true;",
+
+ " if( ! rBreak ) {",
+ " diffuseSum += texture2D( tDiffuse, sampleUv ) * sampleWeight;",
+ " weightSum += sampleWeight;",
+ " }",
+
+ " sampleUv = vUv - sampleUvOffset;",
+ " viewZ = -getViewZ( getDepth( sampleUv ) );",
+
+ " if( abs( viewZ - centerViewZ ) > depthCutoff ) lBreak = true;",
+
+ " if( ! lBreak ) {",
+ " diffuseSum += texture2D( tDiffuse, sampleUv ) * sampleWeight;",
+ " weightSum += sampleWeight;",
+ " }",
+
+ " }",
+
+ " gl_FragColor = diffuseSum / weightSum;",
+ "}"
+ ].join( "\n" )
+};
+
+var BlurShaderUtils = {
+
+ createSampleWeights: function ( kernelRadius, stdDev ) {
+
+ var gaussian = function ( x, stdDev ) {
+
+ return Math.exp( - ( x * x ) / ( 2.0 * ( stdDev * stdDev ) ) ) / ( Math.sqrt( 2.0 * Math.PI ) * stdDev );
+
+ };
+
+ var weights = [];
+
+ for ( var i = 0; i <= kernelRadius; i ++ ) {
+
+ weights.push( gaussian( i, stdDev ) );
+
+ }
+
+ return weights;
+
+ },
+
+ createSampleOffsets: function ( kernelRadius, uvIncrement ) {
+
+ var offsets = [];
+
+ for ( var i = 0; i <= kernelRadius; i ++ ) {
+
+ offsets.push( uvIncrement.clone().multiplyScalar( i ) );
+
+ }
+
+ return offsets;
+
+ },
+
+ configure: function ( material, kernelRadius, stdDev, uvIncrement ) {
+
+ material.defines[ 'KERNEL_RADIUS' ] = kernelRadius;
+ material.uniforms[ 'sampleUvOffsets' ].value = BlurShaderUtils.createSampleOffsets( kernelRadius, uvIncrement );
+ material.uniforms[ 'sampleWeights' ].value = BlurShaderUtils.createSampleWeights( kernelRadius, stdDev );
+ material.needsUpdate = true;
+
+ }
+
+};
+
+export { DepthLimitedBlurShader, BlurShaderUtils };
diff --git a/examples/jsm/shaders/DigitalGlitch.d.ts b/examples/jsm/shaders/DigitalGlitch.d.ts
new file mode 100644
index 0000000000000000000000000000000000000000..bac5c09052a06891f029e3561932a40e3885c69a
--- /dev/null
+++ b/examples/jsm/shaders/DigitalGlitch.d.ts
@@ -0,0 +1,21 @@
+import {
+ Uniform
+} from '../../../src/Three';
+
+export interface DigitalGlitch {
+ uniforms: {
+ tDiffuse: Uniform;
+ tDisp: Uniform;
+ byp: Uniform;
+ amount: Uniform;
+ angle: Uniform;
+ seed: Uniform;
+ seed_x: Uniform;
+ seed_y: Uniform;
+ distortion_x: Uniform;
+ distortion_y: Uniform;
+ col_s: Uniform;
+ };
+ vertexShader: string;
+ fragmentShader: string;
+}
diff --git a/examples/jsm/shaders/DigitalGlitch.js b/examples/jsm/shaders/DigitalGlitch.js
new file mode 100644
index 0000000000000000000000000000000000000000..eacc5a43ef25a8362d48e0e6904b407b3482e78b
--- /dev/null
+++ b/examples/jsm/shaders/DigitalGlitch.js
@@ -0,0 +1,107 @@
+/**
+ * @author felixturner / http://airtight.cc/
+ *
+ * RGB Shift Shader
+ * Shifts red and blue channels from center in opposite directions
+ * Ported from http://kriss.cx/tom/2009/05/rgb-shift/
+ * by Tom Butterworth / http://kriss.cx/tom/
+ *
+ * amount: shift distance (1 is width of input)
+ * angle: shift angle in radians
+ */
+
+
+
+var DigitalGlitch = {
+
+ uniforms: {
+
+ "tDiffuse": { value: null }, //diffuse texture
+ "tDisp": { value: null }, //displacement texture for digital glitch squares
+ "byp": { value: 0 }, //apply the glitch ?
+ "amount": { value: 0.08 },
+ "angle": { value: 0.02 },
+ "seed": { value: 0.02 },
+ "seed_x": { value: 0.02 }, //-1,1
+ "seed_y": { value: 0.02 }, //-1,1
+ "distortion_x": { value: 0.5 },
+ "distortion_y": { value: 0.6 },
+ "col_s": { value: 0.05 }
+ },
+
+ vertexShader: [
+
+ "varying vec2 vUv;",
+ "void main() {",
+ "vUv = uv;",
+ "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );",
+ "}"
+ ].join( "\n" ),
+
+ fragmentShader: [
+ "uniform int byp;",//should we apply the glitch ?
+
+ "uniform sampler2D tDiffuse;",
+ "uniform sampler2D tDisp;",
+
+ "uniform float amount;",
+ "uniform float angle;",
+ "uniform float seed;",
+ "uniform float seed_x;",
+ "uniform float seed_y;",
+ "uniform float distortion_x;",
+ "uniform float distortion_y;",
+ "uniform float col_s;",
+
+ "varying vec2 vUv;",
+
+
+ "float rand(vec2 co){",
+ "return fract(sin(dot(co.xy ,vec2(12.9898,78.233))) * 43758.5453);",
+ "}",
+
+ "void main() {",
+ "if(byp<1) {",
+ "vec2 p = vUv;",
+ "float xs = floor(gl_FragCoord.x / 0.5);",
+ "float ys = floor(gl_FragCoord.y / 0.5);",
+ //based on staffantans glitch shader for unity https://github.com/staffantan/unityglitch
+ "vec4 normal = texture2D (tDisp, p*seed*seed);",
+ "if(p.ydistortion_x-col_s*seed) {",
+ "if(seed_x>0.){",
+ "p.y = 1. - (p.y + distortion_y);",
+ "}",
+ "else {",
+ "p.y = distortion_y;",
+ "}",
+ "}",
+ "if(p.xdistortion_y-col_s*seed) {",
+ "if(seed_y>0.){",
+ "p.x=distortion_x;",
+ "}",
+ "else {",
+ "p.x = 1. - (p.x + distortion_x);",
+ "}",
+ "}",
+ "p.x+=normal.x*seed_x*(seed/5.);",
+ "p.y+=normal.y*seed_y*(seed/5.);",
+ //base from RGB shift shader
+ "vec2 offset = amount * vec2( cos(angle), sin(angle));",
+ "vec4 cr = texture2D(tDiffuse, p + offset);",
+ "vec4 cga = texture2D(tDiffuse, p);",
+ "vec4 cb = texture2D(tDiffuse, p - offset);",
+ "gl_FragColor = vec4(cr.r, cga.g, cb.b, cga.a);",
+ //add noise
+ "vec4 snow = 200.*amount*vec4(rand(vec2(xs * seed,ys * seed*50.))*0.2);",
+ "gl_FragColor = gl_FragColor+ snow;",
+ "}",
+ "else {",
+ "gl_FragColor=texture2D (tDiffuse, vUv);",
+ "}",
+ "}"
+
+ ].join( "\n" )
+
+};
+
+export { DigitalGlitch };
diff --git a/examples/jsm/shaders/DotScreenShader.d.ts b/examples/jsm/shaders/DotScreenShader.d.ts
index c485dee9c63f42ceac54e4a5d1ec1b17af629120..35eaac8b48dc26cb28bbe38ff92a10517bd6e154 100644
--- a/examples/jsm/shaders/DotScreenShader.d.ts
+++ b/examples/jsm/shaders/DotScreenShader.d.ts
@@ -11,5 +11,5 @@ export interface DotScreenShader {
scale: Uniform;
};
vertexShader: string;
- fragmentShader:string;
+ fragmentShader: string;
}
diff --git a/examples/jsm/shaders/FXAAShader.d.ts b/examples/jsm/shaders/FXAAShader.d.ts
new file mode 100644
index 0000000000000000000000000000000000000000..5d504a9b8b70a57fd599252c77be676865a1c964
--- /dev/null
+++ b/examples/jsm/shaders/FXAAShader.d.ts
@@ -0,0 +1,12 @@
+import {
+ Uniform
+} from '../../../src/Three';
+
+export interface FXAAShader {
+ uniforms: {
+ tDiffuse: Uniform;
+ resolution: Uniform;
+ };
+ vertexShader: string;
+ fragmentShader: string;
+}
diff --git a/examples/jsm/shaders/FXAAShader.js b/examples/jsm/shaders/FXAAShader.js
new file mode 100644
index 0000000000000000000000000000000000000000..487cab9bf1976c80b92adc2bf3f59a8feefc3d09
--- /dev/null
+++ b/examples/jsm/shaders/FXAAShader.js
@@ -0,0 +1,1121 @@
+/**
+ * @author alteredq / http://alteredqualia.com/
+ * @author davidedc / http://www.sketchpatch.net/
+ *
+ * NVIDIA FXAA by Timothy Lottes
+ * http://timothylottes.blogspot.com/2011/06/fxaa3-source-released.html
+ * - WebGL port by @supereggbert
+ * http://www.glge.org/demos/fxaa/
+ */
+
+import {
+ Vector2
+} from "../../../build/three.module.js";
+
+var FXAAShader = {
+
+ uniforms: {
+
+ "tDiffuse": { value: null },
+ "resolution": { value: new Vector2( 1 / 1024, 1 / 512 ) }
+
+ },
+
+ vertexShader: [
+
+ "varying vec2 vUv;",
+
+ "void main() {",
+
+ "vUv = uv;",
+ "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );",
+
+ "}"
+
+ ].join( "\n" ),
+
+ fragmentShader: [
+ "precision highp float;",
+ "",
+ "uniform sampler2D tDiffuse;",
+ "",
+ "uniform vec2 resolution;",
+ "",
+ "varying vec2 vUv;",
+ "",
+ "// FXAA 3.11 implementation by NVIDIA, ported to WebGL by Agost Biro (biro@archilogic.com)",
+ "",
+ "//----------------------------------------------------------------------------------",
+ "// File: es3-kepler\FXAA\assets\shaders/FXAA_DefaultES.frag",
+ "// SDK Version: v3.00",
+ "// Email: gameworks@nvidia.com",
+ "// Site: http://developer.nvidia.com/",
+ "//",
+ "// Copyright (c) 2014-2015, NVIDIA CORPORATION. All rights reserved.",
+ "//",
+ "// Redistribution and use in source and binary forms, with or without",
+ "// modification, are permitted provided that the following conditions",
+ "// are met:",
+ "// * Redistributions of source code must retain the above copyright",
+ "// notice, this list of conditions and the following disclaimer.",
+ "// * Redistributions in binary form must reproduce the above copyright",
+ "// notice, this list of conditions and the following disclaimer in the",
+ "// documentation and/or other materials provided with the distribution.",
+ "// * Neither the name of NVIDIA CORPORATION nor the names of its",
+ "// contributors may be used to endorse or promote products derived",
+ "// from this software without specific prior written permission.",
+ "//",
+ "// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY",
+ "// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE",
+ "// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR",
+ "// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR",
+ "// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,",
+ "// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,",
+ "// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR",
+ "// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY",
+ "// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT",
+ "// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE",
+ "// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.",
+ "//",
+ "//----------------------------------------------------------------------------------",
+ "",
+ "#define FXAA_PC 1",
+ "#define FXAA_GLSL_100 1",
+ "#define FXAA_QUALITY_PRESET 12",
+ "",
+ "#define FXAA_GREEN_AS_LUMA 1",
+ "",
+ "/*--------------------------------------------------------------------------*/",
+ "#ifndef FXAA_PC_CONSOLE",
+ " //",
+ " // The console algorithm for PC is included",
+ " // for developers targeting really low spec machines.",
+ " // Likely better to just run FXAA_PC, and use a really low preset.",
+ " //",
+ " #define FXAA_PC_CONSOLE 0",
+ "#endif",
+ "/*--------------------------------------------------------------------------*/",
+ "#ifndef FXAA_GLSL_120",
+ " #define FXAA_GLSL_120 0",
+ "#endif",
+ "/*--------------------------------------------------------------------------*/",
+ "#ifndef FXAA_GLSL_130",
+ " #define FXAA_GLSL_130 0",
+ "#endif",
+ "/*--------------------------------------------------------------------------*/",
+ "#ifndef FXAA_HLSL_3",
+ " #define FXAA_HLSL_3 0",
+ "#endif",
+ "/*--------------------------------------------------------------------------*/",
+ "#ifndef FXAA_HLSL_4",
+ " #define FXAA_HLSL_4 0",
+ "#endif",
+ "/*--------------------------------------------------------------------------*/",
+ "#ifndef FXAA_HLSL_5",
+ " #define FXAA_HLSL_5 0",
+ "#endif",
+ "/*==========================================================================*/",
+ "#ifndef FXAA_GREEN_AS_LUMA",
+ " //",
+ " // For those using non-linear color,",
+ " // and either not able to get luma in alpha, or not wanting to,",
+ " // this enables FXAA to run using green as a proxy for luma.",
+ " // So with this enabled, no need to pack luma in alpha.",
+ " //",
+ " // This will turn off AA on anything which lacks some amount of green.",
+ " // Pure red and blue or combination of only R and B, will get no AA.",
+ " //",
+ " // Might want to lower the settings for both,",
+ " // fxaaConsoleEdgeThresholdMin",
+ " // fxaaQualityEdgeThresholdMin",
+ " // In order to insure AA does not get turned off on colors",
+ " // which contain a minor amount of green.",
+ " //",
+ " // 1 = On.",
+ " // 0 = Off.",
+ " //",
+ " #define FXAA_GREEN_AS_LUMA 0",
+ "#endif",
+ "/*--------------------------------------------------------------------------*/",
+ "#ifndef FXAA_EARLY_EXIT",
+ " //",
+ " // Controls algorithm's early exit path.",
+ " // On PS3 turning this ON adds 2 cycles to the shader.",
+ " // On 360 turning this OFF adds 10ths of a millisecond to the shader.",
+ " // Turning this off on console will result in a more blurry image.",
+ " // So this defaults to on.",
+ " //",
+ " // 1 = On.",
+ " // 0 = Off.",
+ " //",
+ " #define FXAA_EARLY_EXIT 1",
+ "#endif",
+ "/*--------------------------------------------------------------------------*/",
+ "#ifndef FXAA_DISCARD",
+ " //",
+ " // Only valid for PC OpenGL currently.",
+ " // Probably will not work when FXAA_GREEN_AS_LUMA = 1.",
+ " //",
+ " // 1 = Use discard on pixels which don't need AA.",
+ " // For APIs which enable concurrent TEX+ROP from same surface.",
+ " // 0 = Return unchanged color on pixels which don't need AA.",
+ " //",
+ " #define FXAA_DISCARD 0",
+ "#endif",
+ "/*--------------------------------------------------------------------------*/",
+ "#ifndef FXAA_FAST_PIXEL_OFFSET",
+ " //",
+ " // Used for GLSL 120 only.",
+ " //",
+ " // 1 = GL API supports fast pixel offsets",
+ " // 0 = do not use fast pixel offsets",
+ " //",
+ " #ifdef GL_EXT_gpu_shader4",
+ " #define FXAA_FAST_PIXEL_OFFSET 1",
+ " #endif",
+ " #ifdef GL_NV_gpu_shader5",
+ " #define FXAA_FAST_PIXEL_OFFSET 1",
+ " #endif",
+ " #ifdef GL_ARB_gpu_shader5",
+ " #define FXAA_FAST_PIXEL_OFFSET 1",
+ " #endif",
+ " #ifndef FXAA_FAST_PIXEL_OFFSET",
+ " #define FXAA_FAST_PIXEL_OFFSET 0",
+ " #endif",
+ "#endif",
+ "/*--------------------------------------------------------------------------*/",
+ "#ifndef FXAA_GATHER4_ALPHA",
+ " //",
+ " // 1 = API supports gather4 on alpha channel.",
+ " // 0 = API does not support gather4 on alpha channel.",
+ " //",
+ " #if (FXAA_HLSL_5 == 1)",
+ " #define FXAA_GATHER4_ALPHA 1",
+ " #endif",
+ " #ifdef GL_ARB_gpu_shader5",
+ " #define FXAA_GATHER4_ALPHA 1",
+ " #endif",
+ " #ifdef GL_NV_gpu_shader5",
+ " #define FXAA_GATHER4_ALPHA 1",
+ " #endif",
+ " #ifndef FXAA_GATHER4_ALPHA",
+ " #define FXAA_GATHER4_ALPHA 0",
+ " #endif",
+ "#endif",
+ "",
+ "",
+ "/*============================================================================",
+ " FXAA QUALITY - TUNING KNOBS",
+ "------------------------------------------------------------------------------",
+ "NOTE the other tuning knobs are now in the shader function inputs!",
+ "============================================================================*/",
+ "#ifndef FXAA_QUALITY_PRESET",
+ " //",
+ " // Choose the quality preset.",
+ " // This needs to be compiled into the shader as it effects code.",
+ " // Best option to include multiple presets is to",
+ " // in each shader define the preset, then include this file.",
+ " //",
+ " // OPTIONS",
+ " // -----------------------------------------------------------------------",
+ " // 10 to 15 - default medium dither (10=fastest, 15=highest quality)",
+ " // 20 to 29 - less dither, more expensive (20=fastest, 29=highest quality)",
+ " // 39 - no dither, very expensive",
+ " //",
+ " // NOTES",
+ " // -----------------------------------------------------------------------",
+ " // 12 = slightly faster then FXAA 3.9 and higher edge quality (default)",
+ " // 13 = about same speed as FXAA 3.9 and better than 12",
+ " // 23 = closest to FXAA 3.9 visually and performance wise",
+ " // _ = the lowest digit is directly related to performance",
+ " // _ = the highest digit is directly related to style",
+ " //",
+ " #define FXAA_QUALITY_PRESET 12",
+ "#endif",
+ "",
+ "",
+ "/*============================================================================",
+ "",
+ " FXAA QUALITY - PRESETS",
+ "",
+ "============================================================================*/",
+ "",
+ "/*============================================================================",
+ " FXAA QUALITY - MEDIUM DITHER PRESETS",
+ "============================================================================*/",
+ "#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",
+ "",
+ "/*============================================================================",
+ " FXAA QUALITY - LOW DITHER PRESETS",
+ "============================================================================*/",
+ "#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",
+ "",
+ "/*============================================================================",
+ " FXAA QUALITY - EXTREME QUALITY",
+ "============================================================================*/",
+ "#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",
+ "",
+ "",
+ "",
+ "/*============================================================================",
+ "",
+ " API PORTING",
+ "",
+ "============================================================================*/",
+ "#if (FXAA_GLSL_100 == 1) || (FXAA_GLSL_120 == 1) || (FXAA_GLSL_130 == 1)",
+ " #define FxaaBool bool",
+ " #define FxaaDiscard discard",
+ " #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 ivec2",
+ " #define FxaaSat(x) clamp(x, 0.0, 1.0)",
+ " #define FxaaTex sampler2D",
+ "#else",
+ " #define FxaaBool bool",
+ " #define FxaaDiscard clip(-1)",
+ " #define FxaaFloat float",
+ " #define FxaaFloat2 float2",
+ " #define FxaaFloat3 float3",
+ " #define FxaaFloat4 float4",
+ " #define FxaaHalf half",
+ " #define FxaaHalf2 half2",
+ " #define FxaaHalf3 half3",
+ " #define FxaaHalf4 half4",
+ " #define FxaaSat(x) saturate(x)",
+ "#endif",
+ "/*--------------------------------------------------------------------------*/",
+ "#if (FXAA_GLSL_100 == 1)",
+ " #define FxaaTexTop(t, p) texture2D(t, p, 0.0)",
+ " #define FxaaTexOff(t, p, o, r) texture2D(t, p + (o * r), 0.0)",
+ "#endif",
+ "/*--------------------------------------------------------------------------*/",
+ "#if (FXAA_GLSL_120 == 1)",
+ " // Requires,",
+ " // #version 120",
+ " // And at least,",
+ " // #extension GL_EXT_gpu_shader4 : enable",
+ " // (or set FXAA_FAST_PIXEL_OFFSET 1 to work like DX9)",
+ " #define FxaaTexTop(t, p) texture2DLod(t, p, 0.0)",
+ " #if (FXAA_FAST_PIXEL_OFFSET == 1)",
+ " #define FxaaTexOff(t, p, o, r) texture2DLodOffset(t, p, 0.0, o)",
+ " #else",
+ " #define FxaaTexOff(t, p, o, r) texture2DLod(t, p + (o * r), 0.0)",
+ " #endif",
+ " #if (FXAA_GATHER4_ALPHA == 1)",
+ " // use #extension GL_ARB_gpu_shader5 : enable",
+ " #define FxaaTexAlpha4(t, p) textureGather(t, p, 3)",
+ " #define FxaaTexOffAlpha4(t, p, o) textureGatherOffset(t, p, o, 3)",
+ " #define FxaaTexGreen4(t, p) textureGather(t, p, 1)",
+ " #define FxaaTexOffGreen4(t, p, o) textureGatherOffset(t, p, o, 1)",
+ " #endif",
+ "#endif",
+ "/*--------------------------------------------------------------------------*/",
+ "#if (FXAA_GLSL_130 == 1)",
+ " // Requires \"#version 130\" or better",
+ " #define FxaaTexTop(t, p) textureLod(t, p, 0.0)",
+ " #define FxaaTexOff(t, p, o, r) textureLodOffset(t, p, 0.0, o)",
+ " #if (FXAA_GATHER4_ALPHA == 1)",
+ " // use #extension GL_ARB_gpu_shader5 : enable",
+ " #define FxaaTexAlpha4(t, p) textureGather(t, p, 3)",
+ " #define FxaaTexOffAlpha4(t, p, o) textureGatherOffset(t, p, o, 3)",
+ " #define FxaaTexGreen4(t, p) textureGather(t, p, 1)",
+ " #define FxaaTexOffGreen4(t, p, o) textureGatherOffset(t, p, o, 1)",
+ " #endif",
+ "#endif",
+ "/*--------------------------------------------------------------------------*/",
+ "#if (FXAA_HLSL_3 == 1)",
+ " #define FxaaInt2 float2",
+ " #define FxaaTex sampler2D",
+ " #define FxaaTexTop(t, p) tex2Dlod(t, float4(p, 0.0, 0.0))",
+ " #define FxaaTexOff(t, p, o, r) tex2Dlod(t, float4(p + (o * r), 0, 0))",
+ "#endif",
+ "/*--------------------------------------------------------------------------*/",
+ "#if (FXAA_HLSL_4 == 1)",
+ " #define FxaaInt2 int2",
+ " struct FxaaTex { SamplerState smpl; Texture2D tex; };",
+ " #define FxaaTexTop(t, p) t.tex.SampleLevel(t.smpl, p, 0.0)",
+ " #define FxaaTexOff(t, p, o, r) t.tex.SampleLevel(t.smpl, p, 0.0, o)",
+ "#endif",
+ "/*--------------------------------------------------------------------------*/",
+ "#if (FXAA_HLSL_5 == 1)",
+ " #define FxaaInt2 int2",
+ " struct FxaaTex { SamplerState smpl; Texture2D tex; };",
+ " #define FxaaTexTop(t, p) t.tex.SampleLevel(t.smpl, p, 0.0)",
+ " #define FxaaTexOff(t, p, o, r) t.tex.SampleLevel(t.smpl, p, 0.0, o)",
+ " #define FxaaTexAlpha4(t, p) t.tex.GatherAlpha(t.smpl, p)",
+ " #define FxaaTexOffAlpha4(t, p, o) t.tex.GatherAlpha(t.smpl, p, o)",
+ " #define FxaaTexGreen4(t, p) t.tex.GatherGreen(t.smpl, p)",
+ " #define FxaaTexOffGreen4(t, p, o) t.tex.GatherGreen(t.smpl, p, o)",
+ "#endif",
+ "",
+ "",
+ "/*============================================================================",
+ " GREEN AS LUMA OPTION SUPPORT FUNCTION",
+ "============================================================================*/",
+ "#if (FXAA_GREEN_AS_LUMA == 0)",
+ " FxaaFloat FxaaLuma(FxaaFloat4 rgba) { return rgba.w; }",
+ "#else",
+ " FxaaFloat FxaaLuma(FxaaFloat4 rgba) { return rgba.y; }",
+ "#endif",
+ "",
+ "",
+ "",
+ "",
+ "/*============================================================================",
+ "",
+ " FXAA3 QUALITY - PC",
+ "",
+ "============================================================================*/",
+ "#if (FXAA_PC == 1)",
+ "/*--------------------------------------------------------------------------*/",
+ "FxaaFloat4 FxaaPixelShader(",
+ " //",
+ " // Use noperspective interpolation here (turn off perspective interpolation).",
+ " // {xy} = center of pixel",
+ " FxaaFloat2 pos,",
+ " //",
+ " // Used only for FXAA Console, and not used on the 360 version.",
+ " // Use noperspective interpolation here (turn off perspective interpolation).",
+ " // {xy_} = upper left of pixel",
+ " // {_zw} = lower right of pixel",
+ " FxaaFloat4 fxaaConsolePosPos,",
+ " //",
+ " // 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 the optimized 360 version of FXAA Console.",
+ " // For everything but 360, just use the same input here as for \"tex\".",
+ " // For 360, same texture, just alias with a 2nd sampler.",
+ " // This sampler needs to have an exponent bias of -1.",
+ " FxaaTex fxaaConsole360TexExpBiasNegOne,",
+ " //",
+ " // Only used on the optimized 360 version of FXAA Console.",
+ " // For everything but 360, just use the same input here as for \"tex\".",
+ " // For 360, same texture, just alias with a 3nd sampler.",
+ " // This sampler needs to have an exponent bias of -2.",
+ " FxaaTex fxaaConsole360TexExpBiasNegTwo,",
+ " //",
+ " // 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 Console.",
+ " // This must be from a constant/uniform.",
+ " // This effects sub-pixel AA quality and inversely sharpness.",
+ " // Where N ranges between,",
+ " // N = 0.50 (default)",
+ " // N = 0.33 (sharper)",
+ " // {x__} = -N/screenWidthInPixels",
+ " // {_y_} = -N/screenHeightInPixels",
+ " // {_z_} = N/screenWidthInPixels",
+ " // {__w} = N/screenHeightInPixels",
+ " FxaaFloat4 fxaaConsoleRcpFrameOpt,",
+ " //",
+ " // Only used on FXAA Console.",
+ " // Not used on 360, but used on PS3 and PC.",
+ " // This must be from a constant/uniform.",
+ " // {x__} = -2.0/screenWidthInPixels",
+ " // {_y_} = -2.0/screenHeightInPixels",
+ " // {_z_} = 2.0/screenWidthInPixels",
+ " // {__w} = 2.0/screenHeightInPixels",
+ " FxaaFloat4 fxaaConsoleRcpFrameOpt2,",
+ " //",
+ " // Only used on FXAA Console.",
+ " // Only used on 360 in place of fxaaConsoleRcpFrameOpt2.",
+ " // This must be from a constant/uniform.",
+ " // {x__} = 8.0/screenWidthInPixels",
+ " // {_y_} = 8.0/screenHeightInPixels",
+ " // {_z_} = -4.0/screenWidthInPixels",
+ " // {__w} = -4.0/screenHeightInPixels",
+ " FxaaFloat4 fxaaConsole360RcpFrameOpt2,",
+ " //",
+ " // 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,",
+ " //",
+ " // Only used on FXAA Console.",
+ " // This used to be the FXAA_CONSOLE_EDGE_SHARPNESS define.",
+ " // It is here now to allow easier tuning.",
+ " // This does not effect PS3, as this needs to be compiled in.",
+ " // Use FXAA_CONSOLE_PS3_EDGE_SHARPNESS for PS3.",
+ " // Due to the PS3 being ALU bound,",
+ " // there are only three safe values here: 2 and 4 and 8.",
+ " // These options use the shaders ability to a free *|/ by 2|4|8.",
+ " // For all other platforms can be a non-power of two.",
+ " // 8.0 is sharper (default!!!)",
+ " // 4.0 is softer",
+ " // 2.0 is really soft (good only for vector graphics inputs)",
+ " FxaaFloat fxaaConsoleEdgeSharpness,",
+ " //",
+ " // Only used on FXAA Console.",
+ " // This used to be the FXAA_CONSOLE_EDGE_THRESHOLD define.",
+ " // It is here now to allow easier tuning.",
+ " // This does not effect PS3, as this needs to be compiled in.",
+ " // Use FXAA_CONSOLE_PS3_EDGE_THRESHOLD for PS3.",
+ " // Due to the PS3 being ALU bound,",
+ " // there are only two safe values here: 1/4 and 1/8.",
+ " // These options use the shaders ability to a free *|/ by 2|4|8.",
+ " // The console setting has a different mapping than the quality setting.",
+ " // Other platforms can use other values.",
+ " // 0.125 leaves less aliasing, but is softer (default!!!)",
+ " // 0.25 leaves more aliasing, and is sharper",
+ " FxaaFloat fxaaConsoleEdgeThreshold,",
+ " //",
+ " // Only used on FXAA Console.",
+ " // This used to be the FXAA_CONSOLE_EDGE_THRESHOLD_MIN define.",
+ " // It is here now to allow easier tuning.",
+ " // Trims the algorithm from processing darks.",
+ " // The console setting has a different mapping than the quality setting.",
+ " // This only applies when FXAA_EARLY_EXIT is 1.",
+ " // This does not apply to PS3,",
+ " // PS3 was simplified to avoid more shader instructions.",
+ " // 0.06 - faster but more aliasing in darks",
+ " // 0.05 - default",
+ " // 0.04 - slower and less aliasing in darks",
+ " // 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 fxaaConsoleEdgeThresholdMin,",
+ " //",
+ " // Extra constants for 360 FXAA Console only.",
+ " // Use zeros or anything else for other platforms.",
+ " // These must be in physical constant registers and NOT immediates.",
+ " // Immediates will result in compiler un-optimizing.",
+ " // {xyzw} = float4(1.0, -1.0, 0.25, -0.25)",
+ " FxaaFloat4 fxaaConsole360ConstDir",
+ ") {",
+ "/*--------------------------------------------------------------------------*/",
+ " FxaaFloat2 posM;",
+ " posM.x = pos.x;",
+ " posM.y = pos.y;",
+ " #if (FXAA_GATHER4_ALPHA == 1)",
+ " #if (FXAA_DISCARD == 0)",
+ " FxaaFloat4 rgbyM = FxaaTexTop(tex, posM);",
+ " #if (FXAA_GREEN_AS_LUMA == 0)",
+ " #define lumaM rgbyM.w",
+ " #else",
+ " #define lumaM rgbyM.y",
+ " #endif",
+ " #endif",
+ " #if (FXAA_GREEN_AS_LUMA == 0)",
+ " FxaaFloat4 luma4A = FxaaTexAlpha4(tex, posM);",
+ " FxaaFloat4 luma4B = FxaaTexOffAlpha4(tex, posM, FxaaInt2(-1, -1));",
+ " #else",
+ " FxaaFloat4 luma4A = FxaaTexGreen4(tex, posM);",
+ " FxaaFloat4 luma4B = FxaaTexOffGreen4(tex, posM, FxaaInt2(-1, -1));",
+ " #endif",
+ " #if (FXAA_DISCARD == 1)",
+ " #define lumaM luma4A.w",
+ " #endif",
+ " #define lumaE luma4A.z",
+ " #define lumaS luma4A.x",
+ " #define lumaSE luma4A.y",
+ " #define lumaNW luma4B.w",
+ " #define lumaN luma4B.z",
+ " #define lumaW luma4B.x",
+ " #else",
+ " FxaaFloat4 rgbyM = FxaaTexTop(tex, posM);",
+ " #if (FXAA_GREEN_AS_LUMA == 0)",
+ " #define lumaM rgbyM.w",
+ " #else",
+ " #define lumaM rgbyM.y",
+ " #endif",
+ " #if (FXAA_GLSL_100 == 1)",
+ " FxaaFloat lumaS = FxaaLuma(FxaaTexOff(tex, posM, FxaaFloat2( 0.0, 1.0), fxaaQualityRcpFrame.xy));",
+ " FxaaFloat lumaE = FxaaLuma(FxaaTexOff(tex, posM, FxaaFloat2( 1.0, 0.0), fxaaQualityRcpFrame.xy));",
+ " FxaaFloat lumaN = FxaaLuma(FxaaTexOff(tex, posM, FxaaFloat2( 0.0,-1.0), fxaaQualityRcpFrame.xy));",
+ " FxaaFloat lumaW = FxaaLuma(FxaaTexOff(tex, posM, FxaaFloat2(-1.0, 0.0), fxaaQualityRcpFrame.xy));",
+ " #else",
+ " FxaaFloat lumaS = FxaaLuma(FxaaTexOff(tex, posM, FxaaInt2( 0, 1), fxaaQualityRcpFrame.xy));",
+ " FxaaFloat lumaE = FxaaLuma(FxaaTexOff(tex, posM, FxaaInt2( 1, 0), fxaaQualityRcpFrame.xy));",
+ " FxaaFloat lumaN = FxaaLuma(FxaaTexOff(tex, posM, FxaaInt2( 0,-1), fxaaQualityRcpFrame.xy));",
+ " FxaaFloat lumaW = FxaaLuma(FxaaTexOff(tex, posM, FxaaInt2(-1, 0), fxaaQualityRcpFrame.xy));",
+ " #endif",
+ " #endif",
+ "/*--------------------------------------------------------------------------*/",
+ " FxaaFloat maxSM = max(lumaS, lumaM);",
+ " FxaaFloat minSM = min(lumaS, lumaM);",
+ " FxaaFloat maxESM = max(lumaE, maxSM);",
+ " FxaaFloat minESM = min(lumaE, minSM);",
+ " FxaaFloat maxWN = max(lumaN, lumaW);",
+ " FxaaFloat minWN = min(lumaN, lumaW);",
+ " FxaaFloat rangeMax = max(maxWN, maxESM);",
+ " FxaaFloat rangeMin = min(minWN, minESM);",
+ " FxaaFloat rangeMaxScaled = rangeMax * fxaaQualityEdgeThreshold;",
+ " FxaaFloat range = rangeMax - rangeMin;",
+ " FxaaFloat rangeMaxClamped = max(fxaaQualityEdgeThresholdMin, rangeMaxScaled);",
+ " FxaaBool earlyExit = range < rangeMaxClamped;",
+ "/*--------------------------------------------------------------------------*/",
+ " if(earlyExit)",
+ " #if (FXAA_DISCARD == 1)",
+ " FxaaDiscard;",
+ " #else",
+ " return rgbyM;",
+ " #endif",
+ "/*--------------------------------------------------------------------------*/",
+ " #if (FXAA_GATHER4_ALPHA == 0)",
+ " #if (FXAA_GLSL_100 == 1)",
+ " FxaaFloat lumaNW = FxaaLuma(FxaaTexOff(tex, posM, FxaaFloat2(-1.0,-1.0), fxaaQualityRcpFrame.xy));",
+ " FxaaFloat lumaSE = FxaaLuma(FxaaTexOff(tex, posM, FxaaFloat2( 1.0, 1.0), fxaaQualityRcpFrame.xy));",
+ " FxaaFloat lumaNE = FxaaLuma(FxaaTexOff(tex, posM, FxaaFloat2( 1.0,-1.0), fxaaQualityRcpFrame.xy));",
+ " FxaaFloat lumaSW = FxaaLuma(FxaaTexOff(tex, posM, FxaaFloat2(-1.0, 1.0), fxaaQualityRcpFrame.xy));",
+ " #else",
+ " FxaaFloat lumaNW = FxaaLuma(FxaaTexOff(tex, posM, FxaaInt2(-1,-1), fxaaQualityRcpFrame.xy));",
+ " FxaaFloat lumaSE = FxaaLuma(FxaaTexOff(tex, posM, FxaaInt2( 1, 1), fxaaQualityRcpFrame.xy));",
+ " FxaaFloat lumaNE = FxaaLuma(FxaaTexOff(tex, posM, FxaaInt2( 1,-1), fxaaQualityRcpFrame.xy));",
+ " FxaaFloat lumaSW = FxaaLuma(FxaaTexOff(tex, posM, FxaaInt2(-1, 1), fxaaQualityRcpFrame.xy));",
+ " #endif",
+ " #else",
+ " FxaaFloat lumaNE = FxaaLuma(FxaaTexOff(tex, posM, FxaaInt2(1, -1), fxaaQualityRcpFrame.xy));",
+ " FxaaFloat lumaSW = FxaaLuma(FxaaTexOff(tex, posM, FxaaInt2(-1, 1), fxaaQualityRcpFrame.xy));",
+ " #endif",
+ "/*--------------------------------------------------------------------------*/",
+ " FxaaFloat lumaNS = lumaN + lumaS;",
+ " FxaaFloat lumaWE = lumaW + lumaE;",
+ " FxaaFloat subpixRcpRange = 1.0/range;",
+ " FxaaFloat subpixNSWE = lumaNS + lumaWE;",
+ " FxaaFloat edgeHorz1 = (-2.0 * lumaM) + lumaNS;",
+ " FxaaFloat edgeVert1 = (-2.0 * lumaM) + lumaWE;",
+ "/*--------------------------------------------------------------------------*/",
+ " FxaaFloat lumaNESE = lumaNE + lumaSE;",
+ " FxaaFloat lumaNWNE = lumaNW + lumaNE;",
+ " FxaaFloat edgeHorz2 = (-2.0 * lumaE) + lumaNESE;",
+ " FxaaFloat edgeVert2 = (-2.0 * lumaN) + lumaNWNE;",
+ "/*--------------------------------------------------------------------------*/",
+ " FxaaFloat lumaNWSW = lumaNW + lumaSW;",
+ " FxaaFloat lumaSWSE = lumaSW + lumaSE;",
+ " FxaaFloat edgeHorz4 = (abs(edgeHorz1) * 2.0) + abs(edgeHorz2);",
+ " FxaaFloat edgeVert4 = (abs(edgeVert1) * 2.0) + abs(edgeVert2);",
+ " FxaaFloat edgeHorz3 = (-2.0 * lumaW) + lumaNWSW;",
+ " FxaaFloat edgeVert3 = (-2.0 * lumaS) + lumaSWSE;",
+ " FxaaFloat edgeHorz = abs(edgeHorz3) + edgeHorz4;",
+ " FxaaFloat edgeVert = abs(edgeVert3) + edgeVert4;",
+ "/*--------------------------------------------------------------------------*/",
+ " FxaaFloat subpixNWSWNESE = lumaNWSW + lumaNESE;",
+ " FxaaFloat lengthSign = fxaaQualityRcpFrame.x;",
+ " FxaaBool horzSpan = edgeHorz >= edgeVert;",
+ " FxaaFloat subpixA = subpixNSWE * 2.0 + subpixNWSWNESE;",
+ "/*--------------------------------------------------------------------------*/",
+ " if(!horzSpan) lumaN = lumaW;",
+ " if(!horzSpan) lumaS = lumaE;",
+ " if(horzSpan) lengthSign = fxaaQualityRcpFrame.y;",
+ " FxaaFloat subpixB = (subpixA * (1.0/12.0)) - lumaM;",
+ "/*--------------------------------------------------------------------------*/",
+ " FxaaFloat gradientN = lumaN - lumaM;",
+ " FxaaFloat gradientS = lumaS - lumaM;",
+ " FxaaFloat lumaNN = lumaN + lumaM;",
+ " FxaaFloat lumaSS = lumaS + lumaM;",
+ " FxaaBool pairN = abs(gradientN) >= abs(gradientS);",
+ " FxaaFloat gradient = max(abs(gradientN), abs(gradientS));",
+ " if(pairN) lengthSign = -lengthSign;",
+ " FxaaFloat subpixC = FxaaSat(abs(subpixB) * subpixRcpRange);",
+ "/*--------------------------------------------------------------------------*/",
+ " FxaaFloat2 posB;",
+ " posB.x = posM.x;",
+ " posB.y = posM.y;",
+ " FxaaFloat2 offNP;",
+ " offNP.x = (!horzSpan) ? 0.0 : fxaaQualityRcpFrame.x;",
+ " offNP.y = ( horzSpan) ? 0.0 : fxaaQualityRcpFrame.y;",
+ " if(!horzSpan) posB.x += lengthSign * 0.5;",
+ " if( horzSpan) posB.y += lengthSign * 0.5;",
+ "/*--------------------------------------------------------------------------*/",
+ " FxaaFloat2 posN;",
+ " posN.x = posB.x - offNP.x * FXAA_QUALITY_P0;",
+ " posN.y = posB.y - offNP.y * FXAA_QUALITY_P0;",
+ " FxaaFloat2 posP;",
+ " posP.x = posB.x + offNP.x * FXAA_QUALITY_P0;",
+ " posP.y = posB.y + offNP.y * FXAA_QUALITY_P0;",
+ " FxaaFloat subpixD = ((-2.0)*subpixC) + 3.0;",
+ " FxaaFloat lumaEndN = FxaaLuma(FxaaTexTop(tex, posN));",
+ " FxaaFloat subpixE = subpixC * subpixC;",
+ " FxaaFloat lumaEndP = FxaaLuma(FxaaTexTop(tex, posP));",
+ "/*--------------------------------------------------------------------------*/",
+ " if(!pairN) lumaNN = lumaSS;",
+ " FxaaFloat gradientScaled = gradient * 1.0/4.0;",
+ " FxaaFloat lumaMM = lumaM - lumaNN * 0.5;",
+ " FxaaFloat subpixF = subpixD * subpixE;",
+ " FxaaBool lumaMLTZero = lumaMM < 0.0;",
+ "/*--------------------------------------------------------------------------*/",
+ " lumaEndN -= lumaNN * 0.5;",
+ " lumaEndP -= lumaNN * 0.5;",
+ " FxaaBool doneN = abs(lumaEndN) >= gradientScaled;",
+ " FxaaBool doneP = abs(lumaEndP) >= gradientScaled;",
+ " if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P1;",
+ " if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P1;",
+ " FxaaBool doneNP = (!doneN) || (!doneP);",
+ " if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P1;",
+ " if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P1;",
+ "/*--------------------------------------------------------------------------*/",
+ " if(doneNP) {",
+ " if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));",
+ " if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));",
+ " if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;",
+ " if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;",
+ " doneN = abs(lumaEndN) >= gradientScaled;",
+ " doneP = abs(lumaEndP) >= gradientScaled;",
+ " if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P2;",
+ " if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P2;",
+ " doneNP = (!doneN) || (!doneP);",
+ " if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P2;",
+ " if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P2;",
+ "/*--------------------------------------------------------------------------*/",
+ " #if (FXAA_QUALITY_PS > 3)",
+ " if(doneNP) {",
+ " if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));",
+ " if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));",
+ " if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;",
+ " if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;",
+ " doneN = abs(lumaEndN) >= gradientScaled;",
+ " doneP = abs(lumaEndP) >= gradientScaled;",
+ " if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P3;",
+ " if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P3;",
+ " doneNP = (!doneN) || (!doneP);",
+ " if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P3;",
+ " if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P3;",
+ "/*--------------------------------------------------------------------------*/",
+ " #if (FXAA_QUALITY_PS > 4)",
+ " if(doneNP) {",
+ " if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));",
+ " if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));",
+ " if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;",
+ " if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;",
+ " doneN = abs(lumaEndN) >= gradientScaled;",
+ " doneP = abs(lumaEndP) >= gradientScaled;",
+ " if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P4;",
+ " if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P4;",
+ " doneNP = (!doneN) || (!doneP);",
+ " if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P4;",
+ " if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P4;",
+ "/*--------------------------------------------------------------------------*/",
+ " #if (FXAA_QUALITY_PS > 5)",
+ " if(doneNP) {",
+ " if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));",
+ " if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));",
+ " if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;",
+ " if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;",
+ " doneN = abs(lumaEndN) >= gradientScaled;",
+ " doneP = abs(lumaEndP) >= gradientScaled;",
+ " if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P5;",
+ " if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P5;",
+ " doneNP = (!doneN) || (!doneP);",
+ " if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P5;",
+ " if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P5;",
+ "/*--------------------------------------------------------------------------*/",
+ " #if (FXAA_QUALITY_PS > 6)",
+ " if(doneNP) {",
+ " if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));",
+ " if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));",
+ " if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;",
+ " if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;",
+ " doneN = abs(lumaEndN) >= gradientScaled;",
+ " doneP = abs(lumaEndP) >= gradientScaled;",
+ " if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P6;",
+ " if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P6;",
+ " doneNP = (!doneN) || (!doneP);",
+ " if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P6;",
+ " if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P6;",
+ "/*--------------------------------------------------------------------------*/",
+ " #if (FXAA_QUALITY_PS > 7)",
+ " if(doneNP) {",
+ " if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));",
+ " if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));",
+ " if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;",
+ " if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;",
+ " doneN = abs(lumaEndN) >= gradientScaled;",
+ " doneP = abs(lumaEndP) >= gradientScaled;",
+ " if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P7;",
+ " if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P7;",
+ " doneNP = (!doneN) || (!doneP);",
+ " if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P7;",
+ " if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P7;",
+ "/*--------------------------------------------------------------------------*/",
+ " #if (FXAA_QUALITY_PS > 8)",
+ " if(doneNP) {",
+ " if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));",
+ " if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));",
+ " if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;",
+ " if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;",
+ " doneN = abs(lumaEndN) >= gradientScaled;",
+ " doneP = abs(lumaEndP) >= gradientScaled;",
+ " if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P8;",
+ " if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P8;",
+ " doneNP = (!doneN) || (!doneP);",
+ " if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P8;",
+ " if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P8;",
+ "/*--------------------------------------------------------------------------*/",
+ " #if (FXAA_QUALITY_PS > 9)",
+ " if(doneNP) {",
+ " if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));",
+ " if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));",
+ " if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;",
+ " if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;",
+ " doneN = abs(lumaEndN) >= gradientScaled;",
+ " doneP = abs(lumaEndP) >= gradientScaled;",
+ " if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P9;",
+ " if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P9;",
+ " doneNP = (!doneN) || (!doneP);",
+ " if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P9;",
+ " if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P9;",
+ "/*--------------------------------------------------------------------------*/",
+ " #if (FXAA_QUALITY_PS > 10)",
+ " if(doneNP) {",
+ " if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));",
+ " if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));",
+ " if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;",
+ " if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;",
+ " doneN = abs(lumaEndN) >= gradientScaled;",
+ " doneP = abs(lumaEndP) >= gradientScaled;",
+ " if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P10;",
+ " if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P10;",
+ " doneNP = (!doneN) || (!doneP);",
+ " if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P10;",
+ " if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P10;",
+ "/*--------------------------------------------------------------------------*/",
+ " #if (FXAA_QUALITY_PS > 11)",
+ " if(doneNP) {",
+ " if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));",
+ " if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));",
+ " if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;",
+ " if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;",
+ " doneN = abs(lumaEndN) >= gradientScaled;",
+ " doneP = abs(lumaEndP) >= gradientScaled;",
+ " if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P11;",
+ " if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P11;",
+ " doneNP = (!doneN) || (!doneP);",
+ " if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P11;",
+ " if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P11;",
+ "/*--------------------------------------------------------------------------*/",
+ " #if (FXAA_QUALITY_PS > 12)",
+ " if(doneNP) {",
+ " if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));",
+ " if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));",
+ " if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;",
+ " if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;",
+ " doneN = abs(lumaEndN) >= gradientScaled;",
+ " doneP = abs(lumaEndP) >= gradientScaled;",
+ " if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P12;",
+ " if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P12;",
+ " doneNP = (!doneN) || (!doneP);",
+ " if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P12;",
+ " if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P12;",
+ "/*--------------------------------------------------------------------------*/",
+ " }",
+ " #endif",
+ "/*--------------------------------------------------------------------------*/",
+ " }",
+ " #endif",
+ "/*--------------------------------------------------------------------------*/",
+ " }",
+ " #endif",
+ "/*--------------------------------------------------------------------------*/",
+ " }",
+ " #endif",
+ "/*--------------------------------------------------------------------------*/",
+ " }",
+ " #endif",
+ "/*--------------------------------------------------------------------------*/",
+ " }",
+ " #endif",
+ "/*--------------------------------------------------------------------------*/",
+ " }",
+ " #endif",
+ "/*--------------------------------------------------------------------------*/",
+ " }",
+ " #endif",
+ "/*--------------------------------------------------------------------------*/",
+ " }",
+ " #endif",
+ "/*--------------------------------------------------------------------------*/",
+ " }",
+ " #endif",
+ "/*--------------------------------------------------------------------------*/",
+ " }",
+ "/*--------------------------------------------------------------------------*/",
+ " FxaaFloat dstN = posM.x - posN.x;",
+ " FxaaFloat dstP = posP.x - posM.x;",
+ " if(!horzSpan) dstN = posM.y - posN.y;",
+ " if(!horzSpan) dstP = posP.y - posM.y;",
+ "/*--------------------------------------------------------------------------*/",
+ " FxaaBool goodSpanN = (lumaEndN < 0.0) != lumaMLTZero;",
+ " FxaaFloat spanLength = (dstP + dstN);",
+ " FxaaBool goodSpanP = (lumaEndP < 0.0) != lumaMLTZero;",
+ " FxaaFloat spanLengthRcp = 1.0/spanLength;",
+ "/*--------------------------------------------------------------------------*/",
+ " FxaaBool directionN = dstN < dstP;",
+ " FxaaFloat dst = min(dstN, dstP);",
+ " FxaaBool goodSpan = directionN ? goodSpanN : goodSpanP;",
+ " FxaaFloat subpixG = subpixF * subpixF;",
+ " FxaaFloat pixelOffset = (dst * (-spanLengthRcp)) + 0.5;",
+ " FxaaFloat subpixH = subpixG * fxaaQualitySubpix;",
+ "/*--------------------------------------------------------------------------*/",
+ " FxaaFloat pixelOffsetGood = goodSpan ? pixelOffset : 0.0;",
+ " FxaaFloat pixelOffsetSubpix = max(pixelOffsetGood, subpixH);",
+ " if(!horzSpan) posM.x += pixelOffsetSubpix * lengthSign;",
+ " if( horzSpan) posM.y += pixelOffsetSubpix * lengthSign;",
+ " #if (FXAA_DISCARD == 1)",
+ " return FxaaTexTop(tex, posM);",
+ " #else",
+ " return FxaaFloat4(FxaaTexTop(tex, posM).xyz, lumaM);",
+ " #endif",
+ "}",
+ "/*==========================================================================*/",
+ "#endif",
+ "",
+ "void main() {",
+ " gl_FragColor = FxaaPixelShader(",
+ " vUv,",
+ " vec4(0.0),",
+ " tDiffuse,",
+ " tDiffuse,",
+ " tDiffuse,",
+ " resolution,",
+ " vec4(0.0),",
+ " vec4(0.0),",
+ " vec4(0.0),",
+ " 0.75,",
+ " 0.166,",
+ " 0.0833,",
+ " 0.0,",
+ " 0.0,",
+ " 0.0,",
+ " vec4(0.0)",
+ " );",
+ "",
+ " // TODO avoid querying texture twice for same texel",
+ " gl_FragColor.a = texture2D(tDiffuse, vUv).a;",
+ "}"
+ ].join("\n")
+
+};
+
+export { FXAAShader };
diff --git a/examples/jsm/shaders/FilmShader.d.ts b/examples/jsm/shaders/FilmShader.d.ts
new file mode 100644
index 0000000000000000000000000000000000000000..8e42891c2e191b09bcf503f6dbec115771b33d35
--- /dev/null
+++ b/examples/jsm/shaders/FilmShader.d.ts
@@ -0,0 +1,16 @@
+import {
+ Uniform
+} from '../../../src/Three';
+
+export interface FilmShader {
+ uniforms: {
+ tDiffuse: Uniform;
+ time: Uniform;
+ nIntensity: Uniform;
+ sIntensity: Uniform;
+ sCount: Uniform;
+ grayscale: Uniform;
+ };
+ vertexShader: string;
+ fragmentShader: string;
+}
diff --git a/examples/jsm/shaders/FilmShader.js b/examples/jsm/shaders/FilmShader.js
new file mode 100644
index 0000000000000000000000000000000000000000..c6ba32cd02a8c6d6dc416e9ff094e78b8b4627db
--- /dev/null
+++ b/examples/jsm/shaders/FilmShader.js
@@ -0,0 +1,108 @@
+/**
+ * @author alteredq / http://alteredqualia.com/
+ *
+ * Film grain & scanlines shader
+ *
+ * - ported from HLSL to WebGL / GLSL
+ * http://www.truevision3d.com/forums/showcase/staticnoise_colorblackwhite_scanline_shaders-t18698.0.html
+ *
+ * Screen Space Static Postprocessor
+ *
+ * Produces an analogue noise overlay similar to a film grain / TV static
+ *
+ * Original implementation and noise algorithm
+ * Pat 'Hawthorne' Shearon
+ *
+ * Optimized scanlines + noise version with intensity scaling
+ * Georg 'Leviathan' Steinrohder
+ *
+ * This version is provided under a Creative Commons Attribution 3.0 License
+ * http://creativecommons.org/licenses/by/3.0/
+ */
+
+
+
+var FilmShader = {
+
+ uniforms: {
+
+ "tDiffuse": { value: null },
+ "time": { value: 0.0 },
+ "nIntensity": { value: 0.5 },
+ "sIntensity": { value: 0.05 },
+ "sCount": { value: 4096 },
+ "grayscale": { value: 1 }
+
+ },
+
+ vertexShader: [
+
+ "varying vec2 vUv;",
+
+ "void main() {",
+
+ "vUv = uv;",
+ "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );",
+
+ "}"
+
+ ].join( "\n" ),
+
+ fragmentShader: [
+
+ "#include ",
+
+ // control parameter
+ "uniform float time;",
+
+ "uniform bool grayscale;",
+
+ // noise effect intensity value (0 = no effect, 1 = full effect)
+ "uniform float nIntensity;",
+
+ // scanlines effect intensity value (0 = no effect, 1 = full effect)
+ "uniform float sIntensity;",
+
+ // scanlines effect count value (0 = no effect, 4096 = full effect)
+ "uniform float sCount;",
+
+ "uniform sampler2D tDiffuse;",
+
+ "varying vec2 vUv;",
+
+ "void main() {",
+
+ // sample the source
+ "vec4 cTextureScreen = texture2D( tDiffuse, vUv );",
+
+ // make some noise
+ "float dx = rand( vUv + time );",
+
+ // add noise
+ "vec3 cResult = cTextureScreen.rgb + cTextureScreen.rgb * clamp( 0.1 + dx, 0.0, 1.0 );",
+
+ // get us a sine and cosine
+ "vec2 sc = vec2( sin( vUv.y * sCount ), cos( vUv.y * sCount ) );",
+
+ // add scanlines
+ "cResult += cTextureScreen.rgb * vec3( sc.x, sc.y, sc.x ) * sIntensity;",
+
+ // interpolate between source and result by intensity
+ "cResult = cTextureScreen.rgb + clamp( nIntensity, 0.0,1.0 ) * ( cResult - cTextureScreen.rgb );",
+
+ // convert to grayscale if desired
+ "if( grayscale ) {",
+
+ "cResult = vec3( cResult.r * 0.3 + cResult.g * 0.59 + cResult.b * 0.11 );",
+
+ "}",
+
+ "gl_FragColor = vec4( cResult, cTextureScreen.a );",
+
+ "}"
+
+ ].join( "\n" )
+
+};
+
+export { FilmShader };
diff --git a/examples/jsm/shaders/FocusShader.d.ts b/examples/jsm/shaders/FocusShader.d.ts
new file mode 100644
index 0000000000000000000000000000000000000000..9f0c80880e70dd7ee750c0ae07cadec736acab11
--- /dev/null
+++ b/examples/jsm/shaders/FocusShader.d.ts
@@ -0,0 +1,15 @@
+import {
+ Uniform
+} from '../../../src/Three';
+
+export interface FocusShader {
+ uniforms: {
+ tDiffuse: Uniform;
+ screenWidth: Uniform;
+ screenHeight: Uniform;
+ sampleDistance: Uniform;
+ waveFactor: Uniform;
+ };
+ vertexShader: string;
+ fragmentShader: string;
+}
diff --git a/examples/jsm/shaders/FocusShader.js b/examples/jsm/shaders/FocusShader.js
new file mode 100644
index 0000000000000000000000000000000000000000..2b6538dab2e81afe7e4fddc80b315576f8f1773c
--- /dev/null
+++ b/examples/jsm/shaders/FocusShader.js
@@ -0,0 +1,95 @@
+/**
+ * @author alteredq / http://alteredqualia.com/
+ *
+ * Focus shader
+ * based on PaintEffect postprocess from ro.me
+ * http://code.google.com/p/3-dreams-of-black/source/browse/deploy/js/effects/PaintEffect.js
+ */
+
+
+
+var FocusShader = {
+
+ uniforms: {
+
+ "tDiffuse": { value: null },
+ "screenWidth": { value: 1024 },
+ "screenHeight": { value: 1024 },
+ "sampleDistance": { value: 0.94 },
+ "waveFactor": { value: 0.00125 }
+
+ },
+
+ vertexShader: [
+
+ "varying vec2 vUv;",
+
+ "void main() {",
+
+ "vUv = uv;",
+ "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );",
+
+ "}"
+
+ ].join( "\n" ),
+
+ fragmentShader: [
+
+ "uniform float screenWidth;",
+ "uniform float screenHeight;",
+ "uniform float sampleDistance;",
+ "uniform float waveFactor;",
+
+ "uniform sampler2D tDiffuse;",
+
+ "varying vec2 vUv;",
+
+ "void main() {",
+
+ "vec4 color, org, tmp, add;",
+ "float sample_dist, f;",
+ "vec2 vin;",
+ "vec2 uv = vUv;",
+
+ "add = color = org = texture2D( tDiffuse, uv );",
+
+ "vin = ( uv - vec2( 0.5 ) ) * vec2( 1.4 );",
+ "sample_dist = dot( vin, vin ) * 2.0;",
+
+ "f = ( waveFactor * 100.0 + sample_dist ) * sampleDistance * 4.0;",
+
+ "vec2 sampleSize = vec2( 1.0 / screenWidth, 1.0 / screenHeight ) * vec2( f );",
+
+ "add += tmp = texture2D( tDiffuse, uv + vec2( 0.111964, 0.993712 ) * sampleSize );",
+ "if( tmp.b < color.b ) color = tmp;",
+
+ "add += tmp = texture2D( tDiffuse, uv + vec2( 0.846724, 0.532032 ) * sampleSize );",
+ "if( tmp.b < color.b ) color = tmp;",
+
+ "add += tmp = texture2D( tDiffuse, uv + vec2( 0.943883, -0.330279 ) * sampleSize );",
+ "if( tmp.b < color.b ) color = tmp;",
+
+ "add += tmp = texture2D( tDiffuse, uv + vec2( 0.330279, -0.943883 ) * sampleSize );",
+ "if( tmp.b < color.b ) color = tmp;",
+
+ "add += tmp = texture2D( tDiffuse, uv + vec2( -0.532032, -0.846724 ) * sampleSize );",
+ "if( tmp.b < color.b ) color = tmp;",
+
+ "add += tmp = texture2D( tDiffuse, uv + vec2( -0.993712, -0.111964 ) * sampleSize );",
+ "if( tmp.b < color.b ) color = tmp;",
+
+ "add += tmp = texture2D( tDiffuse, uv + vec2( -0.707107, 0.707107 ) * sampleSize );",
+ "if( tmp.b < color.b ) color = tmp;",
+
+ "color = color * vec4( 2.0 ) - ( add / vec4( 8.0 ) );",
+ "color = color + ( add / vec4( 8.0 ) - color ) * ( vec4( 1.0 ) - vec4( sample_dist * 0.5 ) );",
+
+ "gl_FragColor = vec4( color.rgb * color.rgb * vec3( 0.95 ) + color.rgb, 1.0 );",
+
+ "}"
+
+
+ ].join( "\n" )
+};
+
+export { FocusShader };
diff --git a/examples/jsm/shaders/FreiChenShader.d.ts b/examples/jsm/shaders/FreiChenShader.d.ts
new file mode 100644
index 0000000000000000000000000000000000000000..fe7d29b454c74f980738c7b2713fbbd3c23f121c
--- /dev/null
+++ b/examples/jsm/shaders/FreiChenShader.d.ts
@@ -0,0 +1,12 @@
+import {
+ Uniform
+} from '../../../src/Three';
+
+export interface FreiChenShader {
+ uniforms: {
+ tDiffuse: Uniform;
+ aspect: Uniform;
+ };
+ vertexShader: string;
+ fragmentShader: string;
+}
diff --git a/examples/jsm/shaders/FreiChenShader.js b/examples/jsm/shaders/FreiChenShader.js
new file mode 100644
index 0000000000000000000000000000000000000000..7d68db4928bd47f7fbae1f30f2c6a59fe348a626
--- /dev/null
+++ b/examples/jsm/shaders/FreiChenShader.js
@@ -0,0 +1,99 @@
+/**
+ * @author zz85 / https://github.com/zz85 | https://www.lab4games.net/zz85/blog
+ *
+ * Edge Detection Shader using Frei-Chen filter
+ * Based on http://rastergrid.com/blog/2011/01/frei-chen-edge-detector
+ *
+ * aspect: vec2 of (1/width, 1/height)
+ */
+
+import {
+ Vector2
+} from "../../../build/three.module.js";
+
+var FreiChenShader = {
+
+ uniforms: {
+
+ "tDiffuse": { value: null },
+ "aspect": { value: new Vector2( 512, 512 ) }
+ },
+
+ vertexShader: [
+
+ "varying vec2 vUv;",
+
+ "void main() {",
+
+ "vUv = uv;",
+ "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );",
+
+ "}"
+
+ ].join( "\n" ),
+
+ fragmentShader: [
+
+ "uniform sampler2D tDiffuse;",
+ "varying vec2 vUv;",
+
+ "uniform vec2 aspect;",
+
+ "vec2 texel = vec2(1.0 / aspect.x, 1.0 / aspect.y);",
+
+
+ "mat3 G[9];",
+
+ // hard coded matrix values!!!! as suggested in https://github.com/neilmendoza/ofxPostProcessing/blob/master/src/EdgePass.cpp#L45
+
+ "const mat3 g0 = mat3( 0.3535533845424652, 0, -0.3535533845424652, 0.5, 0, -0.5, 0.3535533845424652, 0, -0.3535533845424652 );",
+ "const mat3 g1 = mat3( 0.3535533845424652, 0.5, 0.3535533845424652, 0, 0, 0, -0.3535533845424652, -0.5, -0.3535533845424652 );",
+ "const mat3 g2 = mat3( 0, 0.3535533845424652, -0.5, -0.3535533845424652, 0, 0.3535533845424652, 0.5, -0.3535533845424652, 0 );",
+ "const mat3 g3 = mat3( 0.5, -0.3535533845424652, 0, -0.3535533845424652, 0, 0.3535533845424652, 0, 0.3535533845424652, -0.5 );",
+ "const mat3 g4 = mat3( 0, -0.5, 0, 0.5, 0, 0.5, 0, -0.5, 0 );",
+ "const mat3 g5 = mat3( -0.5, 0, 0.5, 0, 0, 0, 0.5, 0, -0.5 );",
+ "const mat3 g6 = mat3( 0.1666666716337204, -0.3333333432674408, 0.1666666716337204, -0.3333333432674408, 0.6666666865348816, -0.3333333432674408, 0.1666666716337204, -0.3333333432674408, 0.1666666716337204 );",
+ "const mat3 g7 = mat3( -0.3333333432674408, 0.1666666716337204, -0.3333333432674408, 0.1666666716337204, 0.6666666865348816, 0.1666666716337204, -0.3333333432674408, 0.1666666716337204, -0.3333333432674408 );",
+ "const mat3 g8 = mat3( 0.3333333432674408, 0.3333333432674408, 0.3333333432674408, 0.3333333432674408, 0.3333333432674408, 0.3333333432674408, 0.3333333432674408, 0.3333333432674408, 0.3333333432674408 );",
+
+ "void main(void)",
+ "{",
+
+ "G[0] = g0,",
+ "G[1] = g1,",
+ "G[2] = g2,",
+ "G[3] = g3,",
+ "G[4] = g4,",
+ "G[5] = g5,",
+ "G[6] = g6,",
+ "G[7] = g7,",
+ "G[8] = g8;",
+
+ "mat3 I;",
+ "float cnv[9];",
+ "vec3 sample;",
+
+ /* fetch the 3x3 neighbourhood and use the RGB vector's length as intensity value */
+ "for (float i=0.0; i<3.0; i++) {",
+ "for (float j=0.0; j<3.0; j++) {",
+ "sample = texture2D(tDiffuse, vUv + texel * vec2(i-1.0,j-1.0) ).rgb;",
+ "I[int(i)][int(j)] = length(sample);",
+ "}",
+ "}",
+
+ /* calculate the convolution values for all the masks */
+ "for (int i=0; i<9; i++) {",
+ "float dp3 = dot(G[i][0], I[0]) + dot(G[i][1], I[1]) + dot(G[i][2], I[2]);",
+ "cnv[i] = dp3 * dp3;",
+ "}",
+
+ "float M = (cnv[0] + cnv[1]) + (cnv[2] + cnv[3]);",
+ "float S = (cnv[4] + cnv[5]) + (cnv[6] + cnv[7]) + (cnv[8] + M);",
+
+ "gl_FragColor = vec4(vec3(sqrt(M/S)), 1.0);",
+ "}"
+
+ ].join( "\n" )
+};
+
+export { FreiChenShader };
diff --git a/examples/jsm/shaders/FresnelShader.d.ts b/examples/jsm/shaders/FresnelShader.d.ts
new file mode 100644
index 0000000000000000000000000000000000000000..646e8314aeb4787cb49128f401cc177e03fcb8f0
--- /dev/null
+++ b/examples/jsm/shaders/FresnelShader.d.ts
@@ -0,0 +1,15 @@
+import {
+ Uniform
+} from '../../../src/Three';
+
+export interface FresnelShader {
+ uniforms: {
+ mRefractionRatio: Uniform;
+ mFresnelBias: Uniform;
+ mFresnelPower: Uniform;
+ mFresnelScale: Uniform;
+ tCube: Uniform;
+ };
+ vertexShader: string;
+ fragmentShader: string;
+}
diff --git a/examples/jsm/shaders/FresnelShader.js b/examples/jsm/shaders/FresnelShader.js
new file mode 100644
index 0000000000000000000000000000000000000000..bed45240ab35bd509231d744a0e30ba69072026c
--- /dev/null
+++ b/examples/jsm/shaders/FresnelShader.js
@@ -0,0 +1,78 @@
+/**
+ * @author alteredq / http://alteredqualia.com/
+ *
+ * Based on Nvidia Cg tutorial
+ */
+
+
+
+var FresnelShader = {
+
+ uniforms: {
+
+ "mRefractionRatio": { value: 1.02 },
+ "mFresnelBias": { value: 0.1 },
+ "mFresnelPower": { value: 2.0 },
+ "mFresnelScale": { value: 1.0 },
+ "tCube": { value: null }
+
+ },
+
+ vertexShader: [
+
+ "uniform float mRefractionRatio;",
+ "uniform float mFresnelBias;",
+ "uniform float mFresnelScale;",
+ "uniform float mFresnelPower;",
+
+ "varying vec3 vReflect;",
+ "varying vec3 vRefract[3];",
+ "varying float vReflectionFactor;",
+
+ "void main() {",
+
+ "vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );",
+ "vec4 worldPosition = modelMatrix * vec4( position, 1.0 );",
+
+ "vec3 worldNormal = normalize( mat3( modelMatrix[0].xyz, modelMatrix[1].xyz, modelMatrix[2].xyz ) * normal );",
+
+ "vec3 I = worldPosition.xyz - cameraPosition;",
+
+ "vReflect = reflect( I, worldNormal );",
+ "vRefract[0] = refract( normalize( I ), worldNormal, mRefractionRatio );",
+ "vRefract[1] = refract( normalize( I ), worldNormal, mRefractionRatio * 0.99 );",
+ "vRefract[2] = refract( normalize( I ), worldNormal, mRefractionRatio * 0.98 );",
+ "vReflectionFactor = mFresnelBias + mFresnelScale * pow( 1.0 + dot( normalize( I ), worldNormal ), mFresnelPower );",
+
+ "gl_Position = projectionMatrix * mvPosition;",
+
+ "}"
+
+ ].join( "\n" ),
+
+ fragmentShader: [
+
+ "uniform samplerCube tCube;",
+
+ "varying vec3 vReflect;",
+ "varying vec3 vRefract[3];",
+ "varying float vReflectionFactor;",
+
+ "void main() {",
+
+ "vec4 reflectedColor = textureCube( tCube, vec3( -vReflect.x, vReflect.yz ) );",
+ "vec4 refractedColor = vec4( 1.0 );",
+
+ "refractedColor.r = textureCube( tCube, vec3( -vRefract[0].x, vRefract[0].yz ) ).r;",
+ "refractedColor.g = textureCube( tCube, vec3( -vRefract[1].x, vRefract[1].yz ) ).g;",
+ "refractedColor.b = textureCube( tCube, vec3( -vRefract[2].x, vRefract[2].yz ) ).b;",
+
+ "gl_FragColor = mix( refractedColor, reflectedColor, clamp( vReflectionFactor, 0.0, 1.0 ) );",
+
+ "}"
+
+ ].join( "\n" )
+
+};
+
+export { FresnelShader };
diff --git a/examples/jsm/shaders/GammaCorrectionShader.d.ts b/examples/jsm/shaders/GammaCorrectionShader.d.ts
new file mode 100644
index 0000000000000000000000000000000000000000..4daf903da0483922dcafd7047c1cc0a12ec8da1e
--- /dev/null
+++ b/examples/jsm/shaders/GammaCorrectionShader.d.ts
@@ -0,0 +1,11 @@
+import {
+ Uniform
+} from '../../../src/Three';
+
+export interface GammaCorrectionShader {
+ uniforms: {
+ tDiffuse: Uniform;
+ };
+ vertexShader: string;
+ fragmentShader: string;
+}
diff --git a/examples/jsm/shaders/GammaCorrectionShader.js b/examples/jsm/shaders/GammaCorrectionShader.js
new file mode 100644
index 0000000000000000000000000000000000000000..f5bf34bbf3a9cec3d202c24ac7457055be9f447e
--- /dev/null
+++ b/examples/jsm/shaders/GammaCorrectionShader.js
@@ -0,0 +1,49 @@
+/**
+ * @author WestLangley / http://github.com/WestLangley
+ *
+ * Gamma Correction Shader
+ * http://en.wikipedia.org/wiki/gamma_correction
+ */
+
+
+
+var GammaCorrectionShader = {
+
+ uniforms: {
+
+ "tDiffuse": { value: null }
+
+ },
+
+ vertexShader: [
+
+ "varying vec2 vUv;",
+
+ "void main() {",
+
+ "vUv = uv;",
+ "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );",
+
+ "}"
+
+ ].join( "\n" ),
+
+ fragmentShader: [
+
+ "uniform sampler2D tDiffuse;",
+
+ "varying vec2 vUv;",
+
+ "void main() {",
+
+ "vec4 tex = texture2D( tDiffuse, vec2( vUv.x, vUv.y ) );",
+
+ "gl_FragColor = LinearToGamma( tex, float( GAMMA_FACTOR ) );",
+
+ "}"
+
+ ].join( "\n" )
+
+};
+
+export { GammaCorrectionShader };
diff --git a/examples/jsm/shaders/HalftoneShader.d.ts b/examples/jsm/shaders/HalftoneShader.d.ts
new file mode 100644
index 0000000000000000000000000000000000000000..6b12835a960f3017855ae1ad874debf4a15ff6c2
--- /dev/null
+++ b/examples/jsm/shaders/HalftoneShader.d.ts
@@ -0,0 +1,23 @@
+import {
+ Uniform
+} from '../../../src/Three';
+
+export interface HalftoneShader {
+ uniforms: {
+ tDiffuse: Uniform;
+ shape: Uniform;
+ radius: Uniform;
+ rotateR: Uniform;
+ rotateG: Uniform;
+ rotateB: Uniform;
+ scatter: Uniform;
+ width: Uniform;
+ height: Uniform;
+ blending: Uniform;
+ blendingMode: Uniform;
+ greyscale: Uniform;
+ disable: Uniform;
+ };
+ vertexShader: string;
+ fragmentShader: string;
+}
diff --git a/examples/jsm/shaders/HalftoneShader.js b/examples/jsm/shaders/HalftoneShader.js
new file mode 100644
index 0000000000000000000000000000000000000000..d70eefc79e988599989dda15506c48bfda6013fb
--- /dev/null
+++ b/examples/jsm/shaders/HalftoneShader.js
@@ -0,0 +1,318 @@
+/**
+ * @author meatbags / xavierburrow.com, github/meatbags
+ *
+ * RGB Halftone shader for three.js.
+ * NOTE:
+ * Shape (1 = Dot, 2 = Ellipse, 3 = Line, 4 = Square)
+ * Blending Mode (1 = Linear, 2 = Multiply, 3 = Add, 4 = Lighter, 5 = Darker)
+ */
+
+
+
+var HalftoneShader = {
+
+ uniforms: {
+ "tDiffuse": { value: null },
+ "shape": { value: 1 },
+ "radius": { value: 4 },
+ "rotateR": { value: Math.PI / 12 * 1 },
+ "rotateG": { value: Math.PI / 12 * 2 },
+ "rotateB": { value: Math.PI / 12 * 3 },
+ "scatter": { value: 0 },
+ "width": { value: 1 },
+ "height": { value: 1 },
+ "blending": { value: 1 },
+ "blendingMode": { value: 1 },
+ "greyscale": { value: false },
+ "disable": { value: false }
+ },
+
+ vertexShader: [
+
+ "varying vec2 vUV;",
+
+ "void main() {",
+
+ "vUV = uv;",
+ "gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);",
+
+ "}"
+
+ ].join( "\n" ),
+
+ fragmentShader: [
+
+ "#define SQRT2_MINUS_ONE 0.41421356",
+ "#define SQRT2_HALF_MINUS_ONE 0.20710678",
+ "#define PI2 6.28318531",
+ "#define SHAPE_DOT 1",
+ "#define SHAPE_ELLIPSE 2",
+ "#define SHAPE_LINE 3",
+ "#define SHAPE_SQUARE 4",
+ "#define BLENDING_LINEAR 1",
+ "#define BLENDING_MULTIPLY 2",
+ "#define BLENDING_ADD 3",
+ "#define BLENDING_LIGHTER 4",
+ "#define BLENDING_DARKER 5",
+ "uniform sampler2D tDiffuse;",
+ "uniform float radius;",
+ "uniform float rotateR;",
+ "uniform float rotateG;",
+ "uniform float rotateB;",
+ "uniform float scatter;",
+ "uniform float width;",
+ "uniform float height;",
+ "uniform int shape;",
+ "uniform bool disable;",
+ "uniform float blending;",
+ "uniform int blendingMode;",
+ "varying vec2 vUV;",
+ "uniform bool greyscale;",
+ "const int samples = 8;",
+
+ "float blend( float a, float b, float t ) {",
+
+ // linear blend
+ "return a * ( 1.0 - t ) + b * t;",
+
+ "}",
+
+ "float hypot( float x, float y ) {",
+
+ // vector magnitude
+ "return sqrt( x * x + y * y );",
+
+ "}",
+
+ "float rand( vec2 seed ){",
+
+ // get pseudo-random number
+ "return fract( sin( dot( seed.xy, vec2( 12.9898, 78.233 ) ) ) * 43758.5453 );",
+
+ "}",
+
+ "float distanceToDotRadius( float channel, vec2 coord, vec2 normal, vec2 p, float angle, float rad_max ) {",
+
+ // apply shape-specific transforms
+ "float dist = hypot( coord.x - p.x, coord.y - p.y );",
+ "float rad = channel;",
+
+ "if ( shape == SHAPE_DOT ) {",
+
+ "rad = pow( abs( rad ), 1.125 ) * rad_max;",
+
+ "} else if ( shape == SHAPE_ELLIPSE ) {",
+
+ "rad = pow( abs( rad ), 1.125 ) * rad_max;",
+
+ "if ( dist != 0.0 ) {",
+ "float dot_p = abs( ( p.x - coord.x ) / dist * normal.x + ( p.y - coord.y ) / dist * normal.y );",
+ "dist = ( dist * ( 1.0 - SQRT2_HALF_MINUS_ONE ) ) + dot_p * dist * SQRT2_MINUS_ONE;",
+ "}",
+
+ "} else if ( shape == SHAPE_LINE ) {",
+
+ "rad = pow( abs( rad ), 1.5) * rad_max;",
+ "float dot_p = ( p.x - coord.x ) * normal.x + ( p.y - coord.y ) * normal.y;",
+ "dist = hypot( normal.x * dot_p, normal.y * dot_p );",
+
+ "} else if ( shape == SHAPE_SQUARE ) {",
+
+ "float theta = atan( p.y - coord.y, p.x - coord.x ) - angle;",
+ "float sin_t = abs( sin( theta ) );",
+ "float cos_t = abs( cos( theta ) );",
+ "rad = pow( abs( rad ), 1.4 );",
+ "rad = rad_max * ( rad + ( ( sin_t > cos_t ) ? rad - sin_t * rad : rad - cos_t * rad ) );",
+
+ "}",
+
+ "return rad - dist;",
+
+ "}",
+
+ "struct Cell {",
+
+ // grid sample positions
+ "vec2 normal;",
+ "vec2 p1;",
+ "vec2 p2;",
+ "vec2 p3;",
+ "vec2 p4;",
+ "float samp2;",
+ "float samp1;",
+ "float samp3;",
+ "float samp4;",
+
+ "};",
+
+ "vec4 getSample( vec2 point ) {",
+
+ // multi-sampled point
+ "vec4 tex = texture2D( tDiffuse, vec2( point.x / width, point.y / height ) );",
+ "float base = rand( vec2( floor( point.x ), floor( point.y ) ) ) * PI2;",
+ "float step = PI2 / float( samples );",
+ "float dist = radius * 0.66;",
+
+ "for ( int i = 0; i < samples; ++i ) {",
+
+ "float r = base + step * float( i );",
+ "vec2 coord = point + vec2( cos( r ) * dist, sin( r ) * dist );",
+ "tex += texture2D( tDiffuse, vec2( coord.x / width, coord.y / height ) );",
+
+ "}",
+
+ "tex /= float( samples ) + 1.0;",
+ "return tex;",
+
+ "}",
+
+ "float getDotColour( Cell c, vec2 p, int channel, float angle, float aa ) {",
+
+ // get colour for given point
+ "float dist_c_1, dist_c_2, dist_c_3, dist_c_4, res;",
+
+ "if ( channel == 0 ) {",
+
+ "c.samp1 = getSample( c.p1 ).r;",
+ "c.samp2 = getSample( c.p2 ).r;",
+ "c.samp3 = getSample( c.p3 ).r;",
+ "c.samp4 = getSample( c.p4 ).r;",
+
+ "} else if (channel == 1) {",
+
+ "c.samp1 = getSample( c.p1 ).g;",
+ "c.samp2 = getSample( c.p2 ).g;",
+ "c.samp3 = getSample( c.p3 ).g;",
+ "c.samp4 = getSample( c.p4 ).g;",
+
+ "} else {",
+
+ "c.samp1 = getSample( c.p1 ).b;",
+ "c.samp3 = getSample( c.p3 ).b;",
+ "c.samp2 = getSample( c.p2 ).b;",
+ "c.samp4 = getSample( c.p4 ).b;",
+
+ "}",
+
+ "dist_c_1 = distanceToDotRadius( c.samp1, c.p1, c.normal, p, angle, radius );",
+ "dist_c_2 = distanceToDotRadius( c.samp2, c.p2, c.normal, p, angle, radius );",
+ "dist_c_3 = distanceToDotRadius( c.samp3, c.p3, c.normal, p, angle, radius );",
+ "dist_c_4 = distanceToDotRadius( c.samp4, c.p4, c.normal, p, angle, radius );",
+ "res = ( dist_c_1 > 0.0 ) ? clamp( dist_c_1 / aa, 0.0, 1.0 ) : 0.0;",
+ "res += ( dist_c_2 > 0.0 ) ? clamp( dist_c_2 / aa, 0.0, 1.0 ) : 0.0;",
+ "res += ( dist_c_3 > 0.0 ) ? clamp( dist_c_3 / aa, 0.0, 1.0 ) : 0.0;",
+ "res += ( dist_c_4 > 0.0 ) ? clamp( dist_c_4 / aa, 0.0, 1.0 ) : 0.0;",
+ "res = clamp( res, 0.0, 1.0 );",
+
+ "return res;",
+
+ "}",
+
+ "Cell getReferenceCell( vec2 p, vec2 origin, float grid_angle, float step ) {",
+
+ // get containing cell
+ "Cell c;",
+
+ // calc grid
+ "vec2 n = vec2( cos( grid_angle ), sin( grid_angle ) );",
+ "float threshold = step * 0.5;",
+ "float dot_normal = n.x * ( p.x - origin.x ) + n.y * ( p.y - origin.y );",
+ "float dot_line = -n.y * ( p.x - origin.x ) + n.x * ( p.y - origin.y );",
+ "vec2 offset = vec2( n.x * dot_normal, n.y * dot_normal );",
+ "float offset_normal = mod( hypot( offset.x, offset.y ), step );",
+ "float normal_dir = ( dot_normal < 0.0 ) ? 1.0 : -1.0;",
+ "float normal_scale = ( ( offset_normal < threshold ) ? -offset_normal : step - offset_normal ) * normal_dir;",
+ "float offset_line = mod( hypot( ( p.x - offset.x ) - origin.x, ( p.y - offset.y ) - origin.y ), step );",
+ "float line_dir = ( dot_line < 0.0 ) ? 1.0 : -1.0;",
+ "float line_scale = ( ( offset_line < threshold ) ? -offset_line : step - offset_line ) * line_dir;",
+
+ // get closest corner
+ "c.normal = n;",
+ "c.p1.x = p.x - n.x * normal_scale + n.y * line_scale;",
+ "c.p1.y = p.y - n.y * normal_scale - n.x * line_scale;",
+
+ // scatter
+ "if ( scatter != 0.0 ) {",
+
+ "float off_mag = scatter * threshold * 0.5;",
+ "float off_angle = rand( vec2( floor( c.p1.x ), floor( c.p1.y ) ) ) * PI2;",
+ "c.p1.x += cos( off_angle ) * off_mag;",
+ "c.p1.y += sin( off_angle ) * off_mag;",
+
+ "}",
+
+ // find corners
+ "float normal_step = normal_dir * ( ( offset_normal < threshold ) ? step : -step );",
+ "float line_step = line_dir * ( ( offset_line < threshold ) ? step : -step );",
+ "c.p2.x = c.p1.x - n.x * normal_step;",
+ "c.p2.y = c.p1.y - n.y * normal_step;",
+ "c.p3.x = c.p1.x + n.y * line_step;",
+ "c.p3.y = c.p1.y - n.x * line_step;",
+ "c.p4.x = c.p1.x - n.x * normal_step + n.y * line_step;",
+ "c.p4.y = c.p1.y - n.y * normal_step - n.x * line_step;",
+
+ "return c;",
+
+ "}",
+
+ "float blendColour( float a, float b, float t ) {",
+
+ // blend colours
+ "if ( blendingMode == BLENDING_LINEAR ) {",
+ "return blend( a, b, 1.0 - t );",
+ "} else if ( blendingMode == BLENDING_ADD ) {",
+ "return blend( a, min( 1.0, a + b ), t );",
+ "} else if ( blendingMode == BLENDING_MULTIPLY ) {",
+ "return blend( a, max( 0.0, a * b ), t );",
+ "} else if ( blendingMode == BLENDING_LIGHTER ) {",
+ "return blend( a, max( a, b ), t );",
+ "} else if ( blendingMode == BLENDING_DARKER ) {",
+ "return blend( a, min( a, b ), t );",
+ "} else {",
+ "return blend( a, b, 1.0 - t );",
+ "}",
+
+ "}",
+
+ "void main() {",
+
+ "if ( ! disable ) {",
+
+ // setup
+ "vec2 p = vec2( vUV.x * width, vUV.y * height );",
+ "vec2 origin = vec2( 0, 0 );",
+ "float aa = ( radius < 2.5 ) ? radius * 0.5 : 1.25;",
+
+ // get channel samples
+ "Cell cell_r = getReferenceCell( p, origin, rotateR, radius );",
+ "Cell cell_g = getReferenceCell( p, origin, rotateG, radius );",
+ "Cell cell_b = getReferenceCell( p, origin, rotateB, radius );",
+ "float r = getDotColour( cell_r, p, 0, rotateR, aa );",
+ "float g = getDotColour( cell_g, p, 1, rotateG, aa );",
+ "float b = getDotColour( cell_b, p, 2, rotateB, aa );",
+
+ // blend with original
+ "vec4 colour = texture2D( tDiffuse, vUV );",
+ "r = blendColour( r, colour.r, blending );",
+ "g = blendColour( g, colour.g, blending );",
+ "b = blendColour( b, colour.b, blending );",
+
+ "if ( greyscale ) {",
+ "r = g = b = (r + b + g) / 3.0;",
+ "}",
+
+ "gl_FragColor = vec4( r, g, b, 1.0 );",
+
+ "} else {",
+
+ "gl_FragColor = texture2D( tDiffuse, vUV );",
+
+ "}",
+
+ "}"
+
+ ].join( "\n" )
+
+};
+
+export { HalftoneShader };
diff --git a/examples/jsm/shaders/HorizontalBlurShader.d.ts b/examples/jsm/shaders/HorizontalBlurShader.d.ts
new file mode 100644
index 0000000000000000000000000000000000000000..5ed2b9c5c2bde8f844340029b9aef4a4ae721544
--- /dev/null
+++ b/examples/jsm/shaders/HorizontalBlurShader.d.ts
@@ -0,0 +1,12 @@
+import {
+ Uniform
+} from '../../../src/Three';
+
+export interface HorizontalBlurShader {
+ uniforms: {
+ tDiffuse: Uniform;
+ h: Uniform;
+ };
+ vertexShader: string;
+ fragmentShader: string;
+}
diff --git a/examples/jsm/shaders/HorizontalBlurShader.js b/examples/jsm/shaders/HorizontalBlurShader.js
new file mode 100644
index 0000000000000000000000000000000000000000..f249ce483c6ac8f3b2ea0f238d17fb0084160c92
--- /dev/null
+++ b/examples/jsm/shaders/HorizontalBlurShader.js
@@ -0,0 +1,66 @@
+/**
+ * @author zz85 / http://www.lab4games.net/zz85/blog
+ *
+ * Two pass Gaussian blur filter (horizontal and vertical blur shaders)
+ * - described in http://www.gamerendering.com/2008/10/11/gaussian-blur-filter-shader/
+ * and used in http://www.cake23.de/traveling-wavefronts-lit-up.html
+ *
+ * - 9 samples per pass
+ * - standard deviation 2.7
+ * - "h" and "v" parameters should be set to "1 / width" and "1 / height"
+ */
+
+
+
+var HorizontalBlurShader = {
+
+ uniforms: {
+
+ "tDiffuse": { value: null },
+ "h": { value: 1.0 / 512.0 }
+
+ },
+
+ vertexShader: [
+
+ "varying vec2 vUv;",
+
+ "void main() {",
+
+ "vUv = uv;",
+ "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );",
+
+ "}"
+
+ ].join( "\n" ),
+
+ fragmentShader: [
+
+ "uniform sampler2D tDiffuse;",
+ "uniform float h;",
+
+ "varying vec2 vUv;",
+
+ "void main() {",
+
+ "vec4 sum = vec4( 0.0 );",
+
+ "sum += texture2D( tDiffuse, vec2( vUv.x - 4.0 * h, vUv.y ) ) * 0.051;",
+ "sum += texture2D( tDiffuse, vec2( vUv.x - 3.0 * h, vUv.y ) ) * 0.0918;",
+ "sum += texture2D( tDiffuse, vec2( vUv.x - 2.0 * h, vUv.y ) ) * 0.12245;",
+ "sum += texture2D( tDiffuse, vec2( vUv.x - 1.0 * h, vUv.y ) ) * 0.1531;",
+ "sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y ) ) * 0.1633;",
+ "sum += texture2D( tDiffuse, vec2( vUv.x + 1.0 * h, vUv.y ) ) * 0.1531;",
+ "sum += texture2D( tDiffuse, vec2( vUv.x + 2.0 * h, vUv.y ) ) * 0.12245;",
+ "sum += texture2D( tDiffuse, vec2( vUv.x + 3.0 * h, vUv.y ) ) * 0.0918;",
+ "sum += texture2D( tDiffuse, vec2( vUv.x + 4.0 * h, vUv.y ) ) * 0.051;",
+
+ "gl_FragColor = sum;",
+
+ "}"
+
+ ].join( "\n" )
+
+};
+
+export { HorizontalBlurShader };
diff --git a/examples/jsm/shaders/HorizontalTiltShiftShader.d.ts b/examples/jsm/shaders/HorizontalTiltShiftShader.d.ts
new file mode 100644
index 0000000000000000000000000000000000000000..0b7284a8d33d4cd0860c3961fe57960cf022fd12
--- /dev/null
+++ b/examples/jsm/shaders/HorizontalTiltShiftShader.d.ts
@@ -0,0 +1,13 @@
+import {
+ Uniform
+} from '../../../src/Three';
+
+export interface HorizontalTiltShiftShader {
+ uniforms: {
+ tDiffuse: Uniform;
+ h: Uniform;
+ r: Uniform;
+ };
+ vertexShader: string;
+ fragmentShader: string;
+}
diff --git a/examples/jsm/shaders/HorizontalTiltShiftShader.js b/examples/jsm/shaders/HorizontalTiltShiftShader.js
new file mode 100644
index 0000000000000000000000000000000000000000..fdd2a24c4847ae9e35285de858355b8c59d941a2
--- /dev/null
+++ b/examples/jsm/shaders/HorizontalTiltShiftShader.js
@@ -0,0 +1,69 @@
+/**
+ * @author alteredq / http://alteredqualia.com/
+ *
+ * Simple fake tilt-shift effect, modulating two pass Gaussian blur (see above) by vertical position
+ *
+ * - 9 samples per pass
+ * - standard deviation 2.7
+ * - "h" and "v" parameters should be set to "1 / width" and "1 / height"
+ * - "r" parameter control where "focused" horizontal line lies
+ */
+
+
+
+var HorizontalTiltShiftShader = {
+
+ uniforms: {
+
+ "tDiffuse": { value: null },
+ "h": { value: 1.0 / 512.0 },
+ "r": { value: 0.35 }
+
+ },
+
+ vertexShader: [
+
+ "varying vec2 vUv;",
+
+ "void main() {",
+
+ "vUv = uv;",
+ "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );",
+
+ "}"
+
+ ].join( "\n" ),
+
+ fragmentShader: [
+
+ "uniform sampler2D tDiffuse;",
+ "uniform float h;",
+ "uniform float r;",
+
+ "varying vec2 vUv;",
+
+ "void main() {",
+
+ "vec4 sum = vec4( 0.0 );",
+
+ "float hh = h * abs( r - vUv.y );",
+
+ "sum += texture2D( tDiffuse, vec2( vUv.x - 4.0 * hh, vUv.y ) ) * 0.051;",
+ "sum += texture2D( tDiffuse, vec2( vUv.x - 3.0 * hh, vUv.y ) ) * 0.0918;",
+ "sum += texture2D( tDiffuse, vec2( vUv.x - 2.0 * hh, vUv.y ) ) * 0.12245;",
+ "sum += texture2D( tDiffuse, vec2( vUv.x - 1.0 * hh, vUv.y ) ) * 0.1531;",
+ "sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y ) ) * 0.1633;",
+ "sum += texture2D( tDiffuse, vec2( vUv.x + 1.0 * hh, vUv.y ) ) * 0.1531;",
+ "sum += texture2D( tDiffuse, vec2( vUv.x + 2.0 * hh, vUv.y ) ) * 0.12245;",
+ "sum += texture2D( tDiffuse, vec2( vUv.x + 3.0 * hh, vUv.y ) ) * 0.0918;",
+ "sum += texture2D( tDiffuse, vec2( vUv.x + 4.0 * hh, vUv.y ) ) * 0.051;",
+
+ "gl_FragColor = sum;",
+
+ "}"
+
+ ].join( "\n" )
+
+};
+
+export { HorizontalTiltShiftShader };
diff --git a/examples/jsm/shaders/HueSaturationShader.d.ts b/examples/jsm/shaders/HueSaturationShader.d.ts
new file mode 100644
index 0000000000000000000000000000000000000000..bd458f7f3ed1c7cf137b246f4b624bcfa34a5c2c
--- /dev/null
+++ b/examples/jsm/shaders/HueSaturationShader.d.ts
@@ -0,0 +1,13 @@
+import {
+ Uniform
+} from '../../../src/Three';
+
+export interface HueSaturationShader {
+ uniforms: {
+ tDiffuse: Uniform;
+ hue: Uniform;
+ saturation: Uniform;
+ };
+ vertexShader: string;
+ fragmentShader: string;
+}
diff --git a/examples/jsm/shaders/HueSaturationShader.js b/examples/jsm/shaders/HueSaturationShader.js
new file mode 100644
index 0000000000000000000000000000000000000000..96aa4f0f54e42fb52e815f888ec6ff3372e0aadf
--- /dev/null
+++ b/examples/jsm/shaders/HueSaturationShader.js
@@ -0,0 +1,73 @@
+/**
+ * @author tapio / http://tapio.github.com/
+ *
+ * Hue and saturation adjustment
+ * https://github.com/evanw/glfx.js
+ * hue: -1 to 1 (-1 is 180 degrees in the negative direction, 0 is no change, etc.
+ * saturation: -1 to 1 (-1 is solid gray, 0 is no change, and 1 is maximum contrast)
+ */
+
+
+
+var HueSaturationShader = {
+
+ uniforms: {
+
+ "tDiffuse": { value: null },
+ "hue": { value: 0 },
+ "saturation": { value: 0 }
+
+ },
+
+ vertexShader: [
+
+ "varying vec2 vUv;",
+
+ "void main() {",
+
+ "vUv = uv;",
+
+ "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );",
+
+ "}"
+
+ ].join( "\n" ),
+
+ fragmentShader: [
+
+ "uniform sampler2D tDiffuse;",
+ "uniform float hue;",
+ "uniform float saturation;",
+
+ "varying vec2 vUv;",
+
+ "void main() {",
+
+ "gl_FragColor = texture2D( tDiffuse, vUv );",
+
+ // hue
+ "float angle = 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(gl_FragColor.rgb);",
+ "gl_FragColor.rgb = vec3(",
+ "dot(gl_FragColor.rgb, weights.xyz),",
+ "dot(gl_FragColor.rgb, weights.zxy),",
+ "dot(gl_FragColor.rgb, weights.yzx)",
+ ");",
+
+ // saturation
+ "float average = (gl_FragColor.r + gl_FragColor.g + gl_FragColor.b) / 3.0;",
+ "if (saturation > 0.0) {",
+ "gl_FragColor.rgb += (average - gl_FragColor.rgb) * (1.0 - 1.0 / (1.001 - saturation));",
+ "} else {",
+ "gl_FragColor.rgb += (average - gl_FragColor.rgb) * (-saturation);",
+ "}",
+
+ "}"
+
+ ].join( "\n" )
+
+};
+
+export { HueSaturationShader };
diff --git a/examples/jsm/shaders/KaleidoShader.d.ts b/examples/jsm/shaders/KaleidoShader.d.ts
new file mode 100644
index 0000000000000000000000000000000000000000..c07602b084dffae1bdfff00a473cf6a4a641957c
--- /dev/null
+++ b/examples/jsm/shaders/KaleidoShader.d.ts
@@ -0,0 +1,13 @@
+import {
+ Uniform
+} from '../../../src/Three';
+
+export interface KaleidoShader {
+ uniforms: {
+ tDiffuse: Uniform;
+ sides: Uniform;
+ angle: Uniform;
+ };
+ vertexShader: string;
+ fragmentShader: string;
+}
diff --git a/examples/jsm/shaders/KaleidoShader.js b/examples/jsm/shaders/KaleidoShader.js
new file mode 100644
index 0000000000000000000000000000000000000000..7a3478dae1e59ccf5939eadd65a9bb8701d57275
--- /dev/null
+++ b/examples/jsm/shaders/KaleidoShader.js
@@ -0,0 +1,64 @@
+/**
+ * @author felixturner / http://airtight.cc/
+ *
+ * Kaleidoscope Shader
+ * Radial reflection around center point
+ * Ported from: http://pixelshaders.com/editor/
+ * by Toby Schachman / http://tobyschachman.com/
+ *
+ * sides: number of reflections
+ * angle: initial angle in radians
+ */
+
+
+
+var KaleidoShader = {
+
+ uniforms: {
+
+ "tDiffuse": { value: null },
+ "sides": { value: 6.0 },
+ "angle": { value: 0.0 }
+
+ },
+
+ vertexShader: [
+
+ "varying vec2 vUv;",
+
+ "void main() {",
+
+ "vUv = uv;",
+ "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );",
+
+ "}"
+
+ ].join( "\n" ),
+
+ fragmentShader: [
+
+ "uniform sampler2D tDiffuse;",
+ "uniform float sides;",
+ "uniform float angle;",
+
+ "varying vec2 vUv;",
+
+ "void main() {",
+
+ "vec2 p = vUv - 0.5;",
+ "float r = length(p);",
+ "float a = atan(p.y, p.x) + angle;",
+ "float tau = 2. * 3.1416 ;",
+ "a = mod(a, tau/sides);",
+ "a = abs(a - tau/sides/2.) ;",
+ "p = r * vec2(cos(a), sin(a));",
+ "vec4 color = texture2D(tDiffuse, p + 0.5);",
+ "gl_FragColor = color;",
+
+ "}"
+
+ ].join( "\n" )
+
+};
+
+export { KaleidoShader };
diff --git a/examples/jsm/shaders/LuminosityHighPassShader.d.ts b/examples/jsm/shaders/LuminosityHighPassShader.d.ts
new file mode 100644
index 0000000000000000000000000000000000000000..10c96b29d71c5391208abe433a2657bbced499b4
--- /dev/null
+++ b/examples/jsm/shaders/LuminosityHighPassShader.d.ts
@@ -0,0 +1,16 @@
+import {
+ Uniform
+} from '../../../src/Three';
+
+export interface LuminosityHighPassShader {
+ shaderID: string;
+ uniforms: {
+ tDiffuse: Uniform;
+ luminosityThreshold: Uniform;
+ smoothWidth: Uniform;
+ defaultColor: Uniform;
+ defaultOpacity: Uniform;
+ };
+ vertexShader: string;
+ fragmentShader: string;
+}
diff --git a/examples/jsm/shaders/LuminosityHighPassShader.js b/examples/jsm/shaders/LuminosityHighPassShader.js
new file mode 100644
index 0000000000000000000000000000000000000000..854de04f512a08f9d61d75eac9eabfaa08932cc8
--- /dev/null
+++ b/examples/jsm/shaders/LuminosityHighPassShader.js
@@ -0,0 +1,70 @@
+/**
+ * @author bhouston / http://clara.io/
+ *
+ * Luminosity
+ * http://en.wikipedia.org/wiki/Luminosity
+ */
+
+import {
+ Color
+} from "../../../build/three.module.js";
+
+var LuminosityHighPassShader = {
+
+ shaderID: "luminosityHighPass",
+
+ uniforms: {
+
+ "tDiffuse": { value: null },
+ "luminosityThreshold": { value: 1.0 },
+ "smoothWidth": { value: 1.0 },
+ "defaultColor": { value: new Color( 0x000000 ) },
+ "defaultOpacity": { value: 0.0 }
+
+ },
+
+ vertexShader: [
+
+ "varying vec2 vUv;",
+
+ "void main() {",
+
+ "vUv = uv;",
+
+ "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );",
+
+ "}"
+
+ ].join("\n"),
+
+ fragmentShader: [
+
+ "uniform sampler2D tDiffuse;",
+ "uniform vec3 defaultColor;",
+ "uniform float defaultOpacity;",
+ "uniform float luminosityThreshold;",
+ "uniform float smoothWidth;",
+
+ "varying vec2 vUv;",
+
+ "void main() {",
+
+ "vec4 texel = texture2D( tDiffuse, vUv );",
+
+ "vec3 luma = vec3( 0.299, 0.587, 0.114 );",
+
+ "float v = dot( texel.xyz, luma );",
+
+ "vec4 outputColor = vec4( defaultColor.rgb, defaultOpacity );",
+
+ "float alpha = smoothstep( luminosityThreshold, luminosityThreshold + smoothWidth, v );",
+
+ "gl_FragColor = mix( outputColor, texel, alpha );",
+
+ "}"
+
+ ].join("\n")
+
+};
+
+export { LuminosityHighPassShader };
diff --git a/examples/jsm/shaders/LuminosityShader.d.ts b/examples/jsm/shaders/LuminosityShader.d.ts
new file mode 100644
index 0000000000000000000000000000000000000000..c4b1781543752dbfdac0088910b87580e250dc2c
--- /dev/null
+++ b/examples/jsm/shaders/LuminosityShader.d.ts
@@ -0,0 +1,11 @@
+import {
+ Uniform
+} from '../../../src/Three';
+
+export interface LuminosityShader {
+ uniforms: {
+ tDiffuse: Uniform;
+ };
+ vertexShader: string;
+ fragmentShader: string;
+}
diff --git a/examples/jsm/shaders/LuminosityShader.js b/examples/jsm/shaders/LuminosityShader.js
new file mode 100644
index 0000000000000000000000000000000000000000..37f1c30a9c3e60912f2b89d295cec0093a1227f4
--- /dev/null
+++ b/examples/jsm/shaders/LuminosityShader.js
@@ -0,0 +1,54 @@
+/**
+ * @author alteredq / http://alteredqualia.com/
+ *
+ * Luminosity
+ * http://en.wikipedia.org/wiki/Luminosity
+ */
+
+
+
+var LuminosityShader = {
+
+ uniforms: {
+
+ "tDiffuse": { value: null }
+
+ },
+
+ vertexShader: [
+
+ "varying vec2 vUv;",
+
+ "void main() {",
+
+ "vUv = uv;",
+
+ "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );",
+
+ "}"
+
+ ].join( "\n" ),
+
+ fragmentShader: [
+
+ "#include ",
+
+ "uniform sampler2D tDiffuse;",
+
+ "varying vec2 vUv;",
+
+ "void main() {",
+
+ "vec4 texel = texture2D( tDiffuse, vUv );",
+
+ "float l = linearToRelativeLuminance( texel.rgb );",
+
+ "gl_FragColor = vec4( l, l, l, texel.w );",
+
+ "}"
+
+ ].join( "\n" )
+
+};
+
+export { LuminosityShader };
diff --git a/examples/jsm/shaders/MirrorShader.d.ts b/examples/jsm/shaders/MirrorShader.d.ts
new file mode 100644
index 0000000000000000000000000000000000000000..93c7c447f46afb623f25d73986095e9c63dd1005
--- /dev/null
+++ b/examples/jsm/shaders/MirrorShader.d.ts
@@ -0,0 +1,12 @@
+import {
+ Uniform
+} from '../../../src/Three';
+
+export interface MirrorShader {
+ uniforms: {
+ tDiffuse: Uniform;
+ side: Uniform;
+ };
+ vertexShader: string;
+ fragmentShader: string;
+}
diff --git a/examples/jsm/shaders/MirrorShader.js b/examples/jsm/shaders/MirrorShader.js
new file mode 100644
index 0000000000000000000000000000000000000000..b2d45525f76b94a15976f77e795fd423bc76dae6
--- /dev/null
+++ b/examples/jsm/shaders/MirrorShader.js
@@ -0,0 +1,62 @@
+/**
+ * @author felixturner / http://airtight.cc/
+ *
+ * Mirror Shader
+ * Copies half the input to the other half
+ *
+ * side: side of input to mirror (0 = left, 1 = right, 2 = top, 3 = bottom)
+ */
+
+
+
+var MirrorShader = {
+
+ uniforms: {
+
+ "tDiffuse": { value: null },
+ "side": { value: 1 }
+
+ },
+
+ vertexShader: [
+
+ "varying vec2 vUv;",
+
+ "void main() {",
+
+ "vUv = uv;",
+ "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );",
+
+ "}"
+
+ ].join( "\n" ),
+
+ fragmentShader: [
+
+ "uniform sampler2D tDiffuse;",
+ "uniform int side;",
+
+ "varying vec2 vUv;",
+
+ "void main() {",
+
+ "vec2 p = vUv;",
+ "if (side == 0){",
+ "if (p.x > 0.5) p.x = 1.0 - p.x;",
+ "}else if (side == 1){",
+ "if (p.x < 0.5) p.x = 1.0 - p.x;",
+ "}else if (side == 2){",
+ "if (p.y < 0.5) p.y = 1.0 - p.y;",
+ "}else if (side == 3){",
+ "if (p.y > 0.5) p.y = 1.0 - p.y;",
+ "} ",
+ "vec4 color = texture2D(tDiffuse, p);",
+ "gl_FragColor = color;",
+
+ "}"
+
+ ].join( "\n" )
+
+};
+
+export { MirrorShader };
diff --git a/examples/jsm/shaders/NormalMapShader.d.ts b/examples/jsm/shaders/NormalMapShader.d.ts
new file mode 100644
index 0000000000000000000000000000000000000000..8b54d4c7aed2a4caa8e323d24a77dd11904aae6a
--- /dev/null
+++ b/examples/jsm/shaders/NormalMapShader.d.ts
@@ -0,0 +1,14 @@
+import {
+ Uniform
+} from '../../../src/Three';
+
+export interface NormalMapShader {
+ uniforms: {
+ heightMap: Uniform;
+ resolution: Uniform;
+ scale: Uniform;
+ height: Uniform;
+ };
+ vertexShader: string;
+ fragmentShader: string;
+}
diff --git a/examples/jsm/shaders/NormalMapShader.js b/examples/jsm/shaders/NormalMapShader.js
new file mode 100644
index 0000000000000000000000000000000000000000..3c897f78bdda0c7b63346970fbac57f98d2a7a75
--- /dev/null
+++ b/examples/jsm/shaders/NormalMapShader.js
@@ -0,0 +1,59 @@
+/**
+ * @author alteredq / http://alteredqualia.com/
+ *
+ * Normal map shader
+ * - compute normals from heightmap
+ */
+
+import {
+ Vector2
+} from "../../../build/three.module.js";
+
+var NormalMapShader = {
+
+ uniforms: {
+
+ "heightMap": { value: null },
+ "resolution": { value: new Vector2( 512, 512 ) },
+ "scale": { value: new Vector2( 1, 1 ) },
+ "height": { value: 0.05 }
+
+ },
+
+ vertexShader: [
+
+ "varying vec2 vUv;",
+
+ "void main() {",
+
+ "vUv = uv;",
+ "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );",
+
+ "}"
+
+ ].join( "\n" ),
+
+ fragmentShader: [
+
+ "uniform float height;",
+ "uniform vec2 resolution;",
+ "uniform sampler2D heightMap;",
+
+ "varying vec2 vUv;",
+
+ "void main() {",
+
+ "float val = texture2D( heightMap, vUv ).x;",
+
+ "float valU = texture2D( heightMap, vUv + vec2( 1.0 / resolution.x, 0.0 ) ).x;",
+ "float valV = texture2D( heightMap, vUv + vec2( 0.0, 1.0 / resolution.y ) ).x;",
+
+ "gl_FragColor = vec4( ( 0.5 * normalize( vec3( val - valU, val - valV, height ) ) + 0.5 ), 1.0 );",
+
+ "}"
+
+ ].join( "\n" )
+
+};
+
+export { NormalMapShader };
diff --git a/examples/jsm/shaders/ParallaxShader.d.ts b/examples/jsm/shaders/ParallaxShader.d.ts
new file mode 100644
index 0000000000000000000000000000000000000000..8aa993e2b2c303a41f129dfe1173ade87143afed
--- /dev/null
+++ b/examples/jsm/shaders/ParallaxShader.d.ts
@@ -0,0 +1,22 @@
+import {
+ Uniform
+} from '../../../src/Three';
+
+export interface ParallaxShader {
+ modes: {
+ none: string;
+ basic: string;
+ steep: string;
+ occlusion: string;
+ relief: string;
+ };
+ uniforms: {
+ bumpMap: Uniform;
+ map: Uniform;
+ parallaxScale: Uniform;
+ parallaxMinLayers: Uniform;
+ parallaxMaxLayers: Uniform;
+ };
+ vertexShader: string;
+ fragmentShader: string;
+}
diff --git a/examples/jsm/shaders/ParallaxShader.js b/examples/jsm/shaders/ParallaxShader.js
new file mode 100644
index 0000000000000000000000000000000000000000..2079911753980cc6bdb3ff368bbfc5ad3a19f20b
--- /dev/null
+++ b/examples/jsm/shaders/ParallaxShader.js
@@ -0,0 +1,186 @@
+// Parallax Occlusion shaders from
+// http://sunandblackcat.com/tipFullView.php?topicid=28
+// No tangent-space transforms logic based on
+// http://mmikkelsen3d.blogspot.sk/2012/02/parallaxpoc-mapping-and-no-tangent.html
+
+var ParallaxShader = {
+ // Ordered from fastest to best quality.
+ modes: {
+ none: 'NO_PARALLAX',
+ basic: 'USE_BASIC_PARALLAX',
+ steep: 'USE_STEEP_PARALLAX',
+ occlusion: 'USE_OCLUSION_PARALLAX', // a.k.a. POM
+ relief: 'USE_RELIEF_PARALLAX'
+ },
+
+ uniforms: {
+ "bumpMap": { value: null },
+ "map": { value: null },
+ "parallaxScale": { value: null },
+ "parallaxMinLayers": { value: null },
+ "parallaxMaxLayers": { value: null }
+ },
+
+ vertexShader: [
+ "varying vec2 vUv;",
+ "varying vec3 vViewPosition;",
+ "varying vec3 vNormal;",
+
+ "void main() {",
+
+ "vUv = uv;",
+ "vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );",
+ "vViewPosition = -mvPosition.xyz;",
+ "vNormal = normalize( normalMatrix * normal );",
+ "gl_Position = projectionMatrix * mvPosition;",
+
+ "}"
+
+ ].join( "\n" ),
+
+ fragmentShader: [
+ "uniform sampler2D bumpMap;",
+ "uniform sampler2D map;",
+
+ "uniform float parallaxScale;",
+ "uniform float parallaxMinLayers;",
+ "uniform float parallaxMaxLayers;",
+
+ "varying vec2 vUv;",
+ "varying vec3 vViewPosition;",
+ "varying vec3 vNormal;",
+
+ "#ifdef USE_BASIC_PARALLAX",
+
+ "vec2 parallaxMap( in vec3 V ) {",
+
+ "float initialHeight = texture2D( bumpMap, vUv ).r;",
+
+ // No Offset Limitting: messy, floating output at grazing angles.
+ //"vec2 texCoordOffset = parallaxScale * V.xy / V.z * initialHeight;",
+
+ // Offset Limiting
+ "vec2 texCoordOffset = parallaxScale * V.xy * initialHeight;",
+ "return vUv - texCoordOffset;",
+
+ "}",
+
+ "#else",
+
+ "vec2 parallaxMap( in vec3 V ) {",
+
+ // Determine number of layers from angle between V and N
+ "float numLayers = mix( parallaxMaxLayers, parallaxMinLayers, abs( dot( vec3( 0.0, 0.0, 1.0 ), V ) ) );",
+
+ "float layerHeight = 1.0 / numLayers;",
+ "float currentLayerHeight = 0.0;",
+ // Shift of texture coordinates for each iteration
+ "vec2 dtex = parallaxScale * V.xy / V.z / numLayers;",
+
+ "vec2 currentTextureCoords = vUv;",
+
+ "float heightFromTexture = texture2D( bumpMap, currentTextureCoords ).r;",
+
+ // while ( heightFromTexture > currentLayerHeight )
+ // Infinite loops are not well supported. Do a "large" finite
+ // loop, but not too large, as it slows down some compilers.
+ "for ( int i = 0; i < 30; i += 1 ) {",
+ "if ( heightFromTexture <= currentLayerHeight ) {",
+ "break;",
+ "}",
+ "currentLayerHeight += layerHeight;",
+ // Shift texture coordinates along vector V
+ "currentTextureCoords -= dtex;",
+ "heightFromTexture = texture2D( bumpMap, currentTextureCoords ).r;",
+ "}",
+
+ "#ifdef USE_STEEP_PARALLAX",
+
+ "return currentTextureCoords;",
+
+ "#elif defined( USE_RELIEF_PARALLAX )",
+
+ "vec2 deltaTexCoord = dtex / 2.0;",
+ "float deltaHeight = layerHeight / 2.0;",
+
+ // Return to the mid point of previous layer
+ "currentTextureCoords += deltaTexCoord;",
+ "currentLayerHeight -= deltaHeight;",
+
+ // Binary search to increase precision of Steep Parallax Mapping
+ "const int numSearches = 5;",
+ "for ( int i = 0; i < numSearches; i += 1 ) {",
+
+ "deltaTexCoord /= 2.0;",
+ "deltaHeight /= 2.0;",
+ "heightFromTexture = texture2D( bumpMap, currentTextureCoords ).r;",
+ // Shift along or against vector V
+ "if( heightFromTexture > currentLayerHeight ) {", // Below the surface
+
+ "currentTextureCoords -= deltaTexCoord;",
+ "currentLayerHeight += deltaHeight;",
+
+ "} else {", // above the surface
+
+ "currentTextureCoords += deltaTexCoord;",
+ "currentLayerHeight -= deltaHeight;",
+
+ "}",
+
+ "}",
+ "return currentTextureCoords;",
+
+ "#elif defined( USE_OCLUSION_PARALLAX )",
+
+ "vec2 prevTCoords = currentTextureCoords + dtex;",
+
+ // Heights for linear interpolation
+ "float nextH = heightFromTexture - currentLayerHeight;",
+ "float prevH = texture2D( bumpMap, prevTCoords ).r - currentLayerHeight + layerHeight;",
+
+ // Proportions for linear interpolation
+ "float weight = nextH / ( nextH - prevH );",
+
+ // Interpolation of texture coordinates
+ "return prevTCoords * weight + currentTextureCoords * ( 1.0 - weight );",
+
+ "#else", // NO_PARALLAX
+
+ "return vUv;",
+
+ "#endif",
+
+ "}",
+ "#endif",
+
+ "vec2 perturbUv( vec3 surfPosition, vec3 surfNormal, vec3 viewPosition ) {",
+
+ "vec2 texDx = dFdx( vUv );",
+ "vec2 texDy = dFdy( vUv );",
+
+ "vec3 vSigmaX = dFdx( surfPosition );",
+ "vec3 vSigmaY = dFdy( surfPosition );",
+ "vec3 vR1 = cross( vSigmaY, surfNormal );",
+ "vec3 vR2 = cross( surfNormal, vSigmaX );",
+ "float fDet = dot( vSigmaX, vR1 );",
+
+ "vec2 vProjVscr = ( 1.0 / fDet ) * vec2( dot( vR1, viewPosition ), dot( vR2, viewPosition ) );",
+ "vec3 vProjVtex;",
+ "vProjVtex.xy = texDx * vProjVscr.x + texDy * vProjVscr.y;",
+ "vProjVtex.z = dot( surfNormal, viewPosition );",
+
+ "return parallaxMap( vProjVtex );",
+ "}",
+
+ "void main() {",
+
+ "vec2 mapUv = perturbUv( -vViewPosition, normalize( vNormal ), normalize( vViewPosition ) );",
+ "gl_FragColor = texture2D( map, mapUv );",
+
+ "}"
+
+ ].join( "\n" )
+
+};
+
+export { ParallaxShader };
diff --git a/examples/jsm/shaders/PixelShader.d.ts b/examples/jsm/shaders/PixelShader.d.ts
new file mode 100644
index 0000000000000000000000000000000000000000..b5a753d22f4a6fef41feb4570255031105d13df3
--- /dev/null
+++ b/examples/jsm/shaders/PixelShader.d.ts
@@ -0,0 +1,13 @@
+import {
+ Uniform
+} from '../../../src/Three';
+
+export interface PixelShader {
+ uniforms: {
+ tDiffuse: Uniform;
+ resolution: Uniform;
+ pixelSize: Uniform;
+ };
+ vertexShader: string;
+ fragmentShader: string;
+}
diff --git a/examples/jsm/shaders/PixelShader.js b/examples/jsm/shaders/PixelShader.js
new file mode 100644
index 0000000000000000000000000000000000000000..4104fcfa90a67afd1e06f4568ba14a6e01a48cdd
--- /dev/null
+++ b/examples/jsm/shaders/PixelShader.js
@@ -0,0 +1,51 @@
+/**
+ * @author wongbryan / http://wongbryan.github.io
+ *
+ * Pixelation shader
+ */
+
+
+
+var PixelShader = {
+
+ uniforms: {
+
+ "tDiffuse": { value: null },
+ "resolution": { value: null },
+ "pixelSize": { value: 1. },
+
+ },
+
+ vertexShader: [
+
+ "varying highp vec2 vUv;",
+
+ "void main() {",
+
+ "vUv = uv;",
+ "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );",
+
+ "}"
+
+ ].join( "\n" ),
+
+ fragmentShader: [
+
+ "uniform sampler2D tDiffuse;",
+ "uniform float pixelSize;",
+ "uniform vec2 resolution;",
+
+ "varying highp vec2 vUv;",
+
+ "void main(){",
+
+ "vec2 dxy = pixelSize / resolution;",
+ "vec2 coord = dxy * floor( vUv / dxy );",
+ "gl_FragColor = texture2D(tDiffuse, coord);",
+
+ "}"
+
+ ].join( "\n" )
+};
+
+export { PixelShader };
diff --git a/examples/jsm/shaders/RGBShiftShader.d.ts b/examples/jsm/shaders/RGBShiftShader.d.ts
index 33db30134f8d6cefa5d608143d3774de7c43bcfe..bde65f07d0df7bff7db089a6906826490a78c205 100644
--- a/examples/jsm/shaders/RGBShiftShader.d.ts
+++ b/examples/jsm/shaders/RGBShiftShader.d.ts
@@ -9,5 +9,5 @@ export interface RGBShiftShader {
angle: Uniform;
};
vertexShader: string;
- fragmentShader:string;
+ fragmentShader: string;
}
diff --git a/examples/jsm/shaders/RGBShiftShader.js b/examples/jsm/shaders/RGBShiftShader.js
index cf5d6b7e8bc1b1f2d7d2a503833cd9b192fe3125..befd2cb0fe48254e5330ba7d5074d84a15a09ed7 100644
--- a/examples/jsm/shaders/RGBShiftShader.js
+++ b/examples/jsm/shaders/RGBShiftShader.js
@@ -17,8 +17,8 @@ var RGBShiftShader = {
uniforms: {
"tDiffuse": { value: null },
- "amount": { value: 0.005 },
- "angle": { value: 0.0 }
+ "amount": { value: 0.005 },
+ "angle": { value: 0.0 }
},
diff --git a/examples/jsm/shaders/SAOShader.d.ts b/examples/jsm/shaders/SAOShader.d.ts
new file mode 100644
index 0000000000000000000000000000000000000000..5b965241780f8bc6c04c40d07b5ce515442e25ec
--- /dev/null
+++ b/examples/jsm/shaders/SAOShader.d.ts
@@ -0,0 +1,32 @@
+import {
+ Uniform
+} from '../../../src/Three';
+
+export interface SAOShader {
+ defines: {
+ NUM_SAMPLES: number;
+ NUM_RINGS: number;
+ NORMAL_TEXTURE: number;
+ DIFFUSE_TEXTURE: number;
+ DEPTH_PACKING: number;
+ PERSPECTIVE_CAMERA: number;
+ };
+ uniforms: {
+ tDepth: Uniform;
+ tDiffuse: Uniform;
+ tNormal: Uniform;
+ size: Uniform;
+ cameraNear: Uniform;
+ cameraFar: Uniform;
+ cameraProjectionMatrix: Uniform;
+ cameraInverseProjectionMatrix: Uniform;
+ scale: Uniform;
+ intensity: Uniform;
+ bias: Uniform;
+ minResolution: Uniform;
+ kernelRadius: Uniform;
+ randomSeed: Uniform;
+ };
+ vertexShader: string;
+ fragmentShader: string;
+}
diff --git a/examples/jsm/shaders/SAOShader.js b/examples/jsm/shaders/SAOShader.js
new file mode 100644
index 0000000000000000000000000000000000000000..9d103743e0d064ee1258085f5c7f57b0a05b07a1
--- /dev/null
+++ b/examples/jsm/shaders/SAOShader.js
@@ -0,0 +1,188 @@
+/**
+ * TODO
+ */
+
+import {
+ Matrix4,
+ Vector2
+} from "../../../build/three.module.js";
+
+var SAOShader = {
+ defines: {
+ 'NUM_SAMPLES': 7,
+ 'NUM_RINGS': 4,
+ 'NORMAL_TEXTURE': 0,
+ 'DIFFUSE_TEXTURE': 0,
+ 'DEPTH_PACKING': 1,
+ 'PERSPECTIVE_CAMERA': 1
+ },
+ uniforms: {
+
+ 'tDepth': { value: null },
+ 'tDiffuse': { value: null },
+ 'tNormal': { value: null },
+ 'size': { value: new Vector2( 512, 512 ) },
+
+ 'cameraNear': { value: 1 },
+ 'cameraFar': { value: 100 },
+ 'cameraProjectionMatrix': { value: new Matrix4() },
+ 'cameraInverseProjectionMatrix': { value: new Matrix4() },
+
+ 'scale': { value: 1.0 },
+ 'intensity': { value: 0.1 },
+ 'bias': { value: 0.5 },
+
+ 'minResolution': { value: 0.0 },
+ 'kernelRadius': { value: 100.0 },
+ 'randomSeed': { value: 0.0 }
+ },
+ vertexShader: [
+ "varying vec2 vUv;",
+
+ "void main() {",
+ " vUv = uv;",
+ " gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );",
+ "}"
+
+ ].join( "\n" ),
+ fragmentShader: [
+ "#include ",
+
+ "varying vec2 vUv;",
+
+ "#if DIFFUSE_TEXTURE == 1",
+ "uniform sampler2D tDiffuse;",
+ "#endif",
+
+ "uniform sampler2D tDepth;",
+
+ "#if NORMAL_TEXTURE == 1",
+ "uniform sampler2D tNormal;",
+ "#endif",
+
+ "uniform float cameraNear;",
+ "uniform float cameraFar;",
+ "uniform mat4 cameraProjectionMatrix;",
+ "uniform mat4 cameraInverseProjectionMatrix;",
+
+ "uniform float scale;",
+ "uniform float intensity;",
+ "uniform float bias;",
+ "uniform float kernelRadius;",
+ "uniform float minResolution;",
+ "uniform vec2 size;",
+ "uniform float randomSeed;",
+
+ "// RGBA depth",
+
+ "#include ",
+
+ "vec4 getDefaultColor( const in vec2 screenPosition ) {",
+ " #if DIFFUSE_TEXTURE == 1",
+ " return texture2D( tDiffuse, vUv );",
+ " #else",
+ " return vec4( 1.0 );",
+ " #endif",
+ "}",
+
+ "float getDepth( const in vec2 screenPosition ) {",
+ " #if DEPTH_PACKING == 1",
+ " return unpackRGBAToDepth( texture2D( tDepth, screenPosition ) );",
+ " #else",
+ " return texture2D( tDepth, screenPosition ).x;",
+ " #endif",
+ "}",
+
+ "float getViewZ( const in float depth ) {",
+ " #if PERSPECTIVE_CAMERA == 1",
+ " return perspectiveDepthToViewZ( depth, cameraNear, cameraFar );",
+ " #else",
+ " return orthographicDepthToViewZ( depth, cameraNear, cameraFar );",
+ " #endif",
+ "}",
+
+ "vec3 getViewPosition( const in vec2 screenPosition, const in float depth, const in float viewZ ) {",
+ " float clipW = cameraProjectionMatrix[2][3] * viewZ + cameraProjectionMatrix[3][3];",
+ " vec4 clipPosition = vec4( ( vec3( screenPosition, depth ) - 0.5 ) * 2.0, 1.0 );",
+ " clipPosition *= clipW; // unprojection.",
+
+ " return ( cameraInverseProjectionMatrix * clipPosition ).xyz;",
+ "}",
+
+ "vec3 getViewNormal( const in vec3 viewPosition, const in vec2 screenPosition ) {",
+ " #if NORMAL_TEXTURE == 1",
+ " return unpackRGBToNormal( texture2D( tNormal, screenPosition ).xyz );",
+ " #else",
+ " return normalize( cross( dFdx( viewPosition ), dFdy( viewPosition ) ) );",
+ " #endif",
+ "}",
+
+ "float scaleDividedByCameraFar;",
+ "float minResolutionMultipliedByCameraFar;",
+
+ "float getOcclusion( const in vec3 centerViewPosition, const in vec3 centerViewNormal, const in vec3 sampleViewPosition ) {",
+ " vec3 viewDelta = sampleViewPosition - centerViewPosition;",
+ " float viewDistance = length( viewDelta );",
+ " float scaledScreenDistance = scaleDividedByCameraFar * viewDistance;",
+
+ " return max(0.0, (dot(centerViewNormal, viewDelta) - minResolutionMultipliedByCameraFar) / scaledScreenDistance - bias) / (1.0 + pow2( scaledScreenDistance ) );",
+ "}",
+
+ "// moving costly divides into consts",
+ "const float ANGLE_STEP = PI2 * float( NUM_RINGS ) / float( NUM_SAMPLES );",
+ "const float INV_NUM_SAMPLES = 1.0 / float( NUM_SAMPLES );",
+
+ "float getAmbientOcclusion( const in vec3 centerViewPosition ) {",
+ " // precompute some variables require in getOcclusion.",
+ " scaleDividedByCameraFar = scale / cameraFar;",
+ " minResolutionMultipliedByCameraFar = minResolution * cameraFar;",
+ " vec3 centerViewNormal = getViewNormal( centerViewPosition, vUv );",
+
+ " // jsfiddle that shows sample pattern: https://jsfiddle.net/a16ff1p7/",
+ " float angle = rand( vUv + randomSeed ) * PI2;",
+ " vec2 radius = vec2( kernelRadius * INV_NUM_SAMPLES ) / size;",
+ " vec2 radiusStep = radius;",
+
+ " float occlusionSum = 0.0;",
+ " float weightSum = 0.0;",
+
+ " for( int i = 0; i < NUM_SAMPLES; i ++ ) {",
+ " vec2 sampleUv = vUv + vec2( cos( angle ), sin( angle ) ) * radius;",
+ " radius += radiusStep;",
+ " angle += ANGLE_STEP;",
+
+ " float sampleDepth = getDepth( sampleUv );",
+ " if( sampleDepth >= ( 1.0 - EPSILON ) ) {",
+ " continue;",
+ " }",
+
+ " float sampleViewZ = getViewZ( sampleDepth );",
+ " vec3 sampleViewPosition = getViewPosition( sampleUv, sampleDepth, sampleViewZ );",
+ " occlusionSum += getOcclusion( centerViewPosition, centerViewNormal, sampleViewPosition );",
+ " weightSum += 1.0;",
+ " }",
+
+ " if( weightSum == 0.0 ) discard;",
+
+ " return occlusionSum * ( intensity / weightSum );",
+ "}",
+
+
+ "void main() {",
+ " float centerDepth = getDepth( vUv );",
+ " if( centerDepth >= ( 1.0 - EPSILON ) ) {",
+ " discard;",
+ " }",
+
+ " float centerViewZ = getViewZ( centerDepth );",
+ " vec3 viewPosition = getViewPosition( vUv, centerDepth, centerViewZ );",
+
+ " float ambientOcclusion = getAmbientOcclusion( viewPosition );",
+
+ " gl_FragColor = getDefaultColor( vUv );",
+ " gl_FragColor.xyz *= 1.0 - ambientOcclusion;",
+ "}"
+ ].join( "\n" )
+};
+
+export { SAOShader };
diff --git a/examples/jsm/shaders/SSAOShader.d.ts b/examples/jsm/shaders/SSAOShader.d.ts
new file mode 100644
index 0000000000000000000000000000000000000000..e30555bbe610ac214ecabb4c66cee648d909d902
--- /dev/null
+++ b/examples/jsm/shaders/SSAOShader.d.ts
@@ -0,0 +1,49 @@
+import {
+ Uniform
+} from '../../../src/Three';
+
+export interface SSAOShader {
+ defines: {
+ PERSPECTIVE_CAMERA: number;
+ KERNEL_SIZE: number;
+ };
+ uniforms: {
+ tDiffuse: Uniform;
+ tNormal: Uniform;
+ tDepth: Uniform;
+ tNoise: Uniform;
+ kernel: Uniform;
+ cameraNear: Uniform;
+ cameraFar: Uniform;
+ resolution: Uniform;
+ cameraProjectionMatrix: Uniform;
+ cameraInverseProjectionMatrix: Uniform;
+ kernelRadius: Uniform;
+ minDistance: Uniform;
+ maxDistance: Uniform;
+ };
+ vertexShader: string;
+ fragmentShader: string;
+}
+
+export interface SSAODepthShader {
+ defines: {
+ PERSPECTIVE_CAMERA: number;
+ };
+ uniforms: {
+ tDepth: Uniform;
+ cameraNear: Uniform;
+ cameraFar: Uniform;
+ };
+ vertexShader: string;
+ fragmentShader: string;
+}
+
+export interface SSAOBlurShader {
+ uniforms: {
+ tDiffuse: Uniform;
+ resolution: Uniform;
+ };
+ vertexShader: string;
+ fragmentShader: string;
+}
diff --git a/examples/jsm/shaders/SSAOShader.js b/examples/jsm/shaders/SSAOShader.js
new file mode 100644
index 0000000000000000000000000000000000000000..5d0c6ffd025508ba39f1f768aec595ecfe890ed3
--- /dev/null
+++ b/examples/jsm/shaders/SSAOShader.js
@@ -0,0 +1,302 @@
+/**
+ * @author Mugen87 / https://github.com/Mugen87
+ *
+ * References:
+ * http://john-chapman-graphics.blogspot.com/2013/01/ssao-tutorial.html
+ * https://learnopengl.com/Advanced-Lighting/SSAO
+ * https://github.com/McNopper/OpenGL/blob/master/Example28/shader/ssao.frag.glsl
+ */
+
+import {
+ Matrix4,
+ Vector2
+} from "../../../build/three.module.js";
+
+var SSAOShader = {
+
+ defines: {
+ "PERSPECTIVE_CAMERA": 1,
+ "KERNEL_SIZE": 32
+ },
+
+ uniforms: {
+
+ "tDiffuse": { value: null },
+ "tNormal": { value: null },
+ "tDepth": { value: null },
+ "tNoise": { value: null },
+ "kernel": { value: null },
+ "cameraNear": { value: null },
+ "cameraFar": { value: null },
+ "resolution": { value: new Vector2() },
+ "cameraProjectionMatrix": { value: new Matrix4() },
+ "cameraInverseProjectionMatrix": { value: new Matrix4() },
+ "kernelRadius": { value: 8 },
+ "minDistance": { value: 0.005 },
+ "maxDistance": { value: 0.05 },
+
+ },
+
+ vertexShader: [
+
+ "varying vec2 vUv;",
+
+ "void main() {",
+
+ " vUv = uv;",
+
+ " gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );",
+
+ "}"
+
+ ].join( "\n" ),
+
+ fragmentShader: [
+
+ "uniform sampler2D tDiffuse;",
+ "uniform sampler2D tNormal;",
+ "uniform sampler2D tDepth;",
+ "uniform sampler2D tNoise;",
+
+ "uniform vec3 kernel[ KERNEL_SIZE ];",
+
+ "uniform vec2 resolution;",
+
+ "uniform float cameraNear;",
+ "uniform float cameraFar;",
+ "uniform mat4 cameraProjectionMatrix;",
+ "uniform mat4 cameraInverseProjectionMatrix;",
+
+ "uniform float kernelRadius;",
+ "uniform float minDistance;", // avoid artifacts caused by neighbour fragments with minimal depth difference
+ "uniform float maxDistance;", // avoid the influence of fragments which are too far away
+
+ "varying vec2 vUv;",
+
+ "#include ",
+
+ "float getDepth( const in vec2 screenPosition ) {",
+
+ " return texture2D( tDepth, screenPosition ).x;",
+
+ "}",
+
+ "float getLinearDepth( const in vec2 screenPosition ) {",
+
+ " #if PERSPECTIVE_CAMERA == 1",
+
+ " float fragCoordZ = texture2D( tDepth, screenPosition ).x;",
+ " float viewZ = perspectiveDepthToViewZ( fragCoordZ, cameraNear, cameraFar );",
+ " return viewZToOrthographicDepth( viewZ, cameraNear, cameraFar );",
+
+ " #else",
+
+ " return texture2D( depthSampler, coord ).x;",
+
+ " #endif",
+
+ "}",
+
+ "float getViewZ( const in float depth ) {",
+
+ " #if PERSPECTIVE_CAMERA == 1",
+
+ " return perspectiveDepthToViewZ( depth, cameraNear, cameraFar );",
+
+ " #else",
+
+ " return orthographicDepthToViewZ( depth, cameraNear, cameraFar );",
+
+ " #endif",
+
+ "}",
+
+ "vec3 getViewPosition( const in vec2 screenPosition, const in float depth, const in float viewZ ) {",
+
+ " float clipW = cameraProjectionMatrix[2][3] * viewZ + cameraProjectionMatrix[3][3];",
+
+ " vec4 clipPosition = vec4( ( vec3( screenPosition, depth ) - 0.5 ) * 2.0, 1.0 );",
+
+ " clipPosition *= clipW; // unprojection.",
+
+ " return ( cameraInverseProjectionMatrix * clipPosition ).xyz;",
+
+ "}",
+
+ "vec3 getViewNormal( const in vec2 screenPosition ) {",
+
+ " return unpackRGBToNormal( texture2D( tNormal, screenPosition ).xyz );",
+
+ "}",
+
+ "void main() {",
+
+ " float depth = getDepth( vUv );",
+ " float viewZ = getViewZ( depth );",
+
+ " vec3 viewPosition = getViewPosition( vUv, depth, viewZ );",
+ " vec3 viewNormal = getViewNormal( vUv );",
+
+ " vec2 noiseScale = vec2( resolution.x / 4.0, resolution.y / 4.0 );",
+ " vec3 random = texture2D( tNoise, vUv * noiseScale ).xyz;",
+
+ // compute matrix used to reorient a kernel vector
+
+ " vec3 tangent = normalize( random - viewNormal * dot( random, viewNormal ) );",
+ " vec3 bitangent = cross( viewNormal, tangent );",
+ " mat3 kernelMatrix = mat3( tangent, bitangent, viewNormal );",
+
+ " float occlusion = 0.0;",
+
+ " for ( int i = 0; i < KERNEL_SIZE; i ++ ) {",
+
+ " vec3 sampleVector = kernelMatrix * kernel[ i ];", // reorient sample vector in view space
+ " vec3 samplePoint = viewPosition + ( sampleVector * kernelRadius );", // calculate sample point
+
+ " vec4 samplePointNDC = cameraProjectionMatrix * vec4( samplePoint, 1.0 );", // project point and calculate NDC
+ " samplePointNDC /= samplePointNDC.w;",
+
+ " vec2 samplePointUv = samplePointNDC.xy * 0.5 + 0.5;", // compute uv coordinates
+
+ " float realDepth = getLinearDepth( samplePointUv );", // get linear depth from depth texture
+ " float sampleDepth = viewZToOrthographicDepth( samplePoint.z, cameraNear, cameraFar );", // compute linear depth of the sample view Z value
+ " float delta = sampleDepth - realDepth;",
+
+ " if ( delta > minDistance && delta < maxDistance ) {", // if fragment is before sample point, increase occlusion
+
+ " occlusion += 1.0;",
+
+ " }",
+
+ " }",
+
+ " occlusion = clamp( occlusion / float( KERNEL_SIZE ), 0.0, 1.0 );",
+
+ " gl_FragColor = vec4( vec3( 1.0 - occlusion ), 1.0 );",
+
+ "}"
+
+ ].join( "\n" )
+
+};
+
+var SSAODepthShader = {
+
+ defines: {
+ "PERSPECTIVE_CAMERA": 1
+ },
+
+ uniforms: {
+
+ "tDepth": { value: null },
+ "cameraNear": { value: null },
+ "cameraFar": { value: null },
+
+ },
+
+ vertexShader: [
+
+ "varying vec2 vUv;",
+
+ "void main() {",
+
+ " vUv = uv;",
+ " gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );",
+
+ "}"
+
+ ].join( "\n" ),
+
+ fragmentShader: [
+
+ "uniform sampler2D tDepth;",
+
+ "uniform float cameraNear;",
+ "uniform float cameraFar;",
+
+ "varying vec2 vUv;",
+
+ "#include ",
+
+ "float getLinearDepth( const in vec2 screenPosition ) {",
+
+ " #if PERSPECTIVE_CAMERA == 1",
+
+ " float fragCoordZ = texture2D( tDepth, screenPosition ).x;",
+ " float viewZ = perspectiveDepthToViewZ( fragCoordZ, cameraNear, cameraFar );",
+ " return viewZToOrthographicDepth( viewZ, cameraNear, cameraFar );",
+
+ " #else",
+
+ " return texture2D( depthSampler, coord ).x;",
+
+ " #endif",
+
+ "}",
+
+ "void main() {",
+
+ " float depth = getLinearDepth( vUv );",
+ " gl_FragColor = vec4( vec3( 1.0 - depth ), 1.0 );",
+
+ "}"
+
+ ].join( "\n" )
+
+};
+
+var SSAOBlurShader = {
+
+ uniforms: {
+
+ "tDiffuse": { value: null },
+ "resolution": { value: new Vector2() }
+
+ },
+
+ vertexShader: [
+
+ "varying vec2 vUv;",
+
+ "void main() {",
+
+ " vUv = uv;",
+ " gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );",
+
+ "}"
+
+ ].join( "\n" ),
+
+ fragmentShader: [
+
+ "uniform sampler2D tDiffuse;",
+
+ "uniform vec2 resolution;",
+
+ "varying vec2 vUv;",
+
+ "void main() {",
+
+ " vec2 texelSize = ( 1.0 / resolution );",
+ " float result = 0.0;",
+
+ " for ( int i = - 2; i <= 2; i ++ ) {",
+
+ " for ( int j = - 2; j <= 2; j ++ ) {",
+
+ " vec2 offset = ( vec2( float( i ), float( j ) ) ) * texelSize;",
+ " result += texture2D( tDiffuse, vUv + offset ).r;",
+
+ " }",
+
+ " }",
+
+ " gl_FragColor = vec4( vec3( result / ( 5.0 * 5.0 ) ), 1.0 );",
+
+ "}"
+
+ ].join( "\n" )
+
+};
+
+export { SSAOShader, SSAODepthShader, SSAOBlurShader };
diff --git a/examples/jsm/shaders/SepiaShader.d.ts b/examples/jsm/shaders/SepiaShader.d.ts
new file mode 100644
index 0000000000000000000000000000000000000000..9d32a6eeab933ff7024289e4ee454ec39ac4057b
--- /dev/null
+++ b/examples/jsm/shaders/SepiaShader.d.ts
@@ -0,0 +1,12 @@
+import {
+ Uniform
+} from '../../../src/Three';
+
+export interface SepiaShader {
+ uniforms: {
+ tDiffuse: Uniform;
+ amount: Uniform;
+ };
+ vertexShader: string;
+ fragmentShader: string;
+}
diff --git a/examples/jsm/shaders/SepiaShader.js b/examples/jsm/shaders/SepiaShader.js
new file mode 100644
index 0000000000000000000000000000000000000000..849906fe88ed32e02d1e416a5450d84453de4011
--- /dev/null
+++ b/examples/jsm/shaders/SepiaShader.js
@@ -0,0 +1,58 @@
+/**
+ * @author alteredq / http://alteredqualia.com/
+ *
+ * Sepia tone shader
+ * based on glfx.js sepia shader
+ * https://github.com/evanw/glfx.js
+ */
+
+
+
+var SepiaShader = {
+
+ uniforms: {
+
+ "tDiffuse": { value: null },
+ "amount": { value: 1.0 }
+
+ },
+
+ vertexShader: [
+
+ "varying vec2 vUv;",
+
+ "void main() {",
+
+ "vUv = uv;",
+ "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );",
+
+ "}"
+
+ ].join( "\n" ),
+
+ fragmentShader: [
+
+ "uniform float amount;",
+
+ "uniform sampler2D tDiffuse;",
+
+ "varying vec2 vUv;",
+
+ "void main() {",
+
+ "vec4 color = texture2D( tDiffuse, vUv );",
+ "vec3 c = color.rgb;",
+
+ "color.r = dot( c, vec3( 1.0 - 0.607 * amount, 0.769 * amount, 0.189 * amount ) );",
+ "color.g = dot( c, vec3( 0.349 * amount, 1.0 - 0.314 * amount, 0.168 * amount ) );",
+ "color.b = dot( c, vec3( 0.272 * amount, 0.534 * amount, 1.0 - 0.869 * amount ) );",
+
+ "gl_FragColor = vec4( min( vec3( 1.0 ), color.rgb ), color.a );",
+
+ "}"
+
+ ].join( "\n" )
+
+};
+
+export { SepiaShader };
diff --git a/examples/jsm/shaders/SobelOperatorShader.d.ts b/examples/jsm/shaders/SobelOperatorShader.d.ts
new file mode 100644
index 0000000000000000000000000000000000000000..66e6b995d0e5e642c4a7f6c3ef3dee52b3124f9b
--- /dev/null
+++ b/examples/jsm/shaders/SobelOperatorShader.d.ts
@@ -0,0 +1,12 @@
+import {
+ Uniform
+} from '../../../src/Three';
+
+export interface SobelOperatorShader {
+ uniforms: {
+ tDiffuse: Uniform;
+ resolution: Uniform;
+ };
+ vertexShader: string;
+ fragmentShader: string;
+}
diff --git a/examples/jsm/shaders/SobelOperatorShader.js b/examples/jsm/shaders/SobelOperatorShader.js
new file mode 100644
index 0000000000000000000000000000000000000000..d09392bebdf7dba1aa46f6a885a3a704a6febb78
--- /dev/null
+++ b/examples/jsm/shaders/SobelOperatorShader.js
@@ -0,0 +1,96 @@
+/**
+ * @author Mugen87 / https://github.com/Mugen87
+ *
+ * Sobel Edge Detection (see https://youtu.be/uihBwtPIBxM)
+ *
+ * As mentioned in the video the Sobel operator expects a grayscale image as input.
+ *
+ */
+
+import {
+ Vector2
+} from "../../../build/three.module.js";
+
+var SobelOperatorShader = {
+
+ uniforms: {
+
+ "tDiffuse": { value: null },
+ "resolution": { value: new Vector2() }
+
+ },
+
+ vertexShader: [
+
+ "varying vec2 vUv;",
+
+ "void main() {",
+
+ "vUv = uv;",
+
+ "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );",
+
+ "}"
+
+ ].join( "\n" ),
+
+ fragmentShader: [
+
+ "uniform sampler2D tDiffuse;",
+ "uniform vec2 resolution;",
+ "varying vec2 vUv;",
+
+ "void main() {",
+
+ "vec2 texel = vec2( 1.0 / resolution.x, 1.0 / resolution.y );",
+
+ // kernel definition (in glsl matrices are filled in column-major order)
+
+ "const mat3 Gx = mat3( -1, -2, -1, 0, 0, 0, 1, 2, 1 );", // x direction kernel
+ "const mat3 Gy = mat3( -1, 0, 1, -2, 0, 2, -1, 0, 1 );", // y direction kernel
+
+ // fetch the 3x3 neighbourhood of a fragment
+
+ // first column
+
+ "float tx0y0 = texture2D( tDiffuse, vUv + texel * vec2( -1, -1 ) ).r;",
+ "float tx0y1 = texture2D( tDiffuse, vUv + texel * vec2( -1, 0 ) ).r;",
+ "float tx0y2 = texture2D( tDiffuse, vUv + texel * vec2( -1, 1 ) ).r;",
+
+ // second column
+
+ "float tx1y0 = texture2D( tDiffuse, vUv + texel * vec2( 0, -1 ) ).r;",
+ "float tx1y1 = texture2D( tDiffuse, vUv + texel * vec2( 0, 0 ) ).r;",
+ "float tx1y2 = texture2D( tDiffuse, vUv + texel * vec2( 0, 1 ) ).r;",
+
+ // third column
+
+ "float tx2y0 = texture2D( tDiffuse, vUv + texel * vec2( 1, -1 ) ).r;",
+ "float tx2y1 = texture2D( tDiffuse, vUv + texel * vec2( 1, 0 ) ).r;",
+ "float tx2y2 = texture2D( tDiffuse, vUv + texel * vec2( 1, 1 ) ).r;",
+
+ // gradient value in x direction
+
+ "float valueGx = Gx[0][0] * tx0y0 + Gx[1][0] * tx1y0 + Gx[2][0] * tx2y0 + ",
+ "Gx[0][1] * tx0y1 + Gx[1][1] * tx1y1 + Gx[2][1] * tx2y1 + ",
+ "Gx[0][2] * tx0y2 + Gx[1][2] * tx1y2 + Gx[2][2] * tx2y2; ",
+
+ // gradient value in y direction
+
+ "float valueGy = Gy[0][0] * tx0y0 + Gy[1][0] * tx1y0 + Gy[2][0] * tx2y0 + ",
+ "Gy[0][1] * tx0y1 + Gy[1][1] * tx1y1 + Gy[2][1] * tx2y1 + ",
+ "Gy[0][2] * tx0y2 + Gy[1][2] * tx1y2 + Gy[2][2] * tx2y2; ",
+
+ // magnitute of the total gradient
+
+ "float G = sqrt( ( valueGx * valueGx ) + ( valueGy * valueGy ) );",
+
+ "gl_FragColor = vec4( vec3( G ), 1 );",
+
+ "}"
+
+ ].join( "\n" )
+
+};
+
+export { SobelOperatorShader };
diff --git a/examples/jsm/shaders/TechnicolorShader.d.ts b/examples/jsm/shaders/TechnicolorShader.d.ts
new file mode 100644
index 0000000000000000000000000000000000000000..b3dec06620584fdcf01d161f39cdbb93530d7dc0
--- /dev/null
+++ b/examples/jsm/shaders/TechnicolorShader.d.ts
@@ -0,0 +1,11 @@
+import {
+ Uniform
+} from '../../../src/Three';
+
+export interface TechnicolorShader {
+ uniforms: {
+ tDiffuse: Uniform;
+ };
+ vertexShader: string;
+ fragmentShader: string;
+}
diff --git a/examples/jsm/shaders/TechnicolorShader.js b/examples/jsm/shaders/TechnicolorShader.js
new file mode 100644
index 0000000000000000000000000000000000000000..60fdfed652d4cbbff12ef7d0bbcd4d2ad80cd9e3
--- /dev/null
+++ b/examples/jsm/shaders/TechnicolorShader.js
@@ -0,0 +1,51 @@
+/**
+ * @author flimshaw / http://charliehoey.com
+ *
+ * Technicolor Shader
+ * Simulates the look of the two-strip technicolor process popular in early 20th century films.
+ * More historical info here: http://www.widescreenmuseum.com/oldcolor/technicolor1.htm
+ * Demo here: http://charliehoey.com/technicolor_shader/shader_test.html
+ */
+
+
+
+var TechnicolorShader = {
+
+ uniforms: {
+
+ "tDiffuse": { value: null }
+
+ },
+
+ vertexShader: [
+
+ "varying vec2 vUv;",
+
+ "void main() {",
+
+ "vUv = uv;",
+ "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );",
+
+ "}"
+
+ ].join( "\n" ),
+
+ fragmentShader: [
+
+ "uniform sampler2D tDiffuse;",
+ "varying vec2 vUv;",
+
+ "void main() {",
+
+ "vec4 tex = texture2D( tDiffuse, vec2( vUv.x, vUv.y ) );",
+ "vec4 newTex = vec4(tex.r, (tex.g + tex.b) * .5, (tex.g + tex.b) * .5, 1.0);",
+
+ "gl_FragColor = newTex;",
+
+ "}"
+
+ ].join( "\n" )
+
+};
+
+export { TechnicolorShader };
diff --git a/examples/jsm/shaders/UnpackDepthRGBAShader.d.ts b/examples/jsm/shaders/UnpackDepthRGBAShader.d.ts
index bec1664ba0a88aed6ff340bcd150ae2c57bfef51..30563e05920430887f847b506da538118a7d32e3 100644
--- a/examples/jsm/shaders/UnpackDepthRGBAShader.d.ts
+++ b/examples/jsm/shaders/UnpackDepthRGBAShader.d.ts
@@ -8,5 +8,5 @@ export interface UnpackDepthRGBAShader {
opacity: Uniform;
};
vertexShader: string;
- fragmentShader:string;
+ fragmentShader: string;
}
diff --git a/examples/jsm/shaders/UnpackDepthRGBAShader.js b/examples/jsm/shaders/UnpackDepthRGBAShader.js
index a344304c54a8591e99f9ff2662f349cbaebcf701..6aaeb6ee5d94003d75f9983aa084b97fc9631728 100644
--- a/examples/jsm/shaders/UnpackDepthRGBAShader.js
+++ b/examples/jsm/shaders/UnpackDepthRGBAShader.js
@@ -12,7 +12,7 @@ var UnpackDepthRGBAShader = {
uniforms: {
"tDiffuse": { value: null },
- "opacity": { value: 1.0 }
+ "opacity": { value: 1.0 }
},
diff --git a/examples/jsm/shaders/VerticalBlurShader.d.ts b/examples/jsm/shaders/VerticalBlurShader.d.ts
new file mode 100644
index 0000000000000000000000000000000000000000..1284d3da0be664e455340030c2a79466e9dba106
--- /dev/null
+++ b/examples/jsm/shaders/VerticalBlurShader.d.ts
@@ -0,0 +1,12 @@
+import {
+ Uniform
+} from '../../../src/Three';
+
+export interface VerticalBlurShader {
+ uniforms: {
+ tDiffuse: Uniform;
+ v: Uniform;
+ };
+ vertexShader: string;
+ fragmentShader: string;
+}
diff --git a/examples/jsm/shaders/VerticalBlurShader.js b/examples/jsm/shaders/VerticalBlurShader.js
new file mode 100644
index 0000000000000000000000000000000000000000..0d4104b6bf0f36f09447273655f1494a1b46bcf3
--- /dev/null
+++ b/examples/jsm/shaders/VerticalBlurShader.js
@@ -0,0 +1,66 @@
+/**
+ * @author zz85 / http://www.lab4games.net/zz85/blog
+ *
+ * Two pass Gaussian blur filter (horizontal and vertical blur shaders)
+ * - described in http://www.gamerendering.com/2008/10/11/gaussian-blur-filter-shader/
+ * and used in http://www.cake23.de/traveling-wavefronts-lit-up.html
+ *
+ * - 9 samples per pass
+ * - standard deviation 2.7
+ * - "h" and "v" parameters should be set to "1 / width" and "1 / height"
+ */
+
+
+
+var VerticalBlurShader = {
+
+ uniforms: {
+
+ "tDiffuse": { value: null },
+ "v": { value: 1.0 / 512.0 }
+
+ },
+
+ vertexShader: [
+
+ "varying vec2 vUv;",
+
+ "void main() {",
+
+ "vUv = uv;",
+ "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );",
+
+ "}"
+
+ ].join( "\n" ),
+
+ fragmentShader: [
+
+ "uniform sampler2D tDiffuse;",
+ "uniform float v;",
+
+ "varying vec2 vUv;",
+
+ "void main() {",
+
+ "vec4 sum = vec4( 0.0 );",
+
+ "sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y - 4.0 * v ) ) * 0.051;",
+ "sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y - 3.0 * v ) ) * 0.0918;",
+ "sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y - 2.0 * v ) ) * 0.12245;",
+ "sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y - 1.0 * v ) ) * 0.1531;",
+ "sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y ) ) * 0.1633;",
+ "sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y + 1.0 * v ) ) * 0.1531;",
+ "sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y + 2.0 * v ) ) * 0.12245;",
+ "sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y + 3.0 * v ) ) * 0.0918;",
+ "sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y + 4.0 * v ) ) * 0.051;",
+
+ "gl_FragColor = sum;",
+
+ "}"
+
+ ].join( "\n" )
+
+};
+
+export { VerticalBlurShader };
diff --git a/examples/jsm/shaders/VerticalTiltShiftShader.d.ts b/examples/jsm/shaders/VerticalTiltShiftShader.d.ts
new file mode 100644
index 0000000000000000000000000000000000000000..99e49529ce227ff12b4eeba9a9035f8c1a7bfb13
--- /dev/null
+++ b/examples/jsm/shaders/VerticalTiltShiftShader.d.ts
@@ -0,0 +1,13 @@
+import {
+ Uniform
+} from '../../../src/Three';
+
+export interface VerticalTiltShiftShader {
+ uniforms: {
+ tDiffuse: Uniform;
+ v: Uniform;
+ r: Uniform;
+ };
+ vertexShader: string;
+ fragmentShader: string;
+}
diff --git a/examples/jsm/shaders/VerticalTiltShiftShader.js b/examples/jsm/shaders/VerticalTiltShiftShader.js
new file mode 100644
index 0000000000000000000000000000000000000000..495a802854128161152d9389fe44d20f3cca37d1
--- /dev/null
+++ b/examples/jsm/shaders/VerticalTiltShiftShader.js
@@ -0,0 +1,69 @@
+/**
+ * @author alteredq / http://alteredqualia.com/
+ *
+ * Simple fake tilt-shift effect, modulating two pass Gaussian blur (see above) by vertical position
+ *
+ * - 9 samples per pass
+ * - standard deviation 2.7
+ * - "h" and "v" parameters should be set to "1 / width" and "1 / height"
+ * - "r" parameter control where "focused" horizontal line lies
+ */
+
+
+
+var VerticalTiltShiftShader = {
+
+ uniforms: {
+
+ "tDiffuse": { value: null },
+ "v": { value: 1.0 / 512.0 },
+ "r": { value: 0.35 }
+
+ },
+
+ vertexShader: [
+
+ "varying vec2 vUv;",
+
+ "void main() {",
+
+ "vUv = uv;",
+ "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );",
+
+ "}"
+
+ ].join( "\n" ),
+
+ fragmentShader: [
+
+ "uniform sampler2D tDiffuse;",
+ "uniform float v;",
+ "uniform float r;",
+
+ "varying vec2 vUv;",
+
+ "void main() {",
+
+ "vec4 sum = vec4( 0.0 );",
+
+ "float vv = v * abs( r - vUv.y );",
+
+ "sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y - 4.0 * vv ) ) * 0.051;",
+ "sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y - 3.0 * vv ) ) * 0.0918;",
+ "sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y - 2.0 * vv ) ) * 0.12245;",
+ "sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y - 1.0 * vv ) ) * 0.1531;",
+ "sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y ) ) * 0.1633;",
+ "sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y + 1.0 * vv ) ) * 0.1531;",
+ "sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y + 2.0 * vv ) ) * 0.12245;",
+ "sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y + 3.0 * vv ) ) * 0.0918;",
+ "sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y + 4.0 * vv ) ) * 0.051;",
+
+ "gl_FragColor = sum;",
+
+ "}"
+
+ ].join( "\n" )
+
+};
+
+export { VerticalTiltShiftShader };
diff --git a/examples/jsm/shaders/VignetteShader.d.ts b/examples/jsm/shaders/VignetteShader.d.ts
new file mode 100644
index 0000000000000000000000000000000000000000..ea8d0fdad8382447c88ebbfb1a871d25d3248a88
--- /dev/null
+++ b/examples/jsm/shaders/VignetteShader.d.ts
@@ -0,0 +1,13 @@
+import {
+ Uniform
+} from '../../../src/Three';
+
+export interface VignetteShader {
+ uniforms: {
+ tDiffuse: Uniform;
+ offset: Uniform;
+ darkness: Uniform;
+ };
+ vertexShader: string;
+ fragmentShader: string;
+}
diff --git a/examples/jsm/shaders/VignetteShader.js b/examples/jsm/shaders/VignetteShader.js
new file mode 100644
index 0000000000000000000000000000000000000000..e0c04d674a042bd56fc23c266552823792453e91
--- /dev/null
+++ b/examples/jsm/shaders/VignetteShader.js
@@ -0,0 +1,67 @@
+/**
+ * @author alteredq / http://alteredqualia.com/
+ *
+ * Vignette shader
+ * based on PaintEffect postprocess from ro.me
+ * http://code.google.com/p/3-dreams-of-black/source/browse/deploy/js/effects/PaintEffect.js
+ */
+
+
+
+var VignetteShader = {
+
+ uniforms: {
+
+ "tDiffuse": { value: null },
+ "offset": { value: 1.0 },
+ "darkness": { value: 1.0 }
+
+ },
+
+ vertexShader: [
+
+ "varying vec2 vUv;",
+
+ "void main() {",
+
+ "vUv = uv;",
+ "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );",
+
+ "}"
+
+ ].join( "\n" ),
+
+ fragmentShader: [
+
+ "uniform float offset;",
+ "uniform float darkness;",
+
+ "uniform sampler2D tDiffuse;",
+
+ "varying vec2 vUv;",
+
+ "void main() {",
+
+ // Eskil's vignette
+
+ "vec4 texel = texture2D( tDiffuse, vUv );",
+ "vec2 uv = ( vUv - vec2( 0.5 ) ) * vec2( offset );",
+ "gl_FragColor = vec4( mix( texel.rgb, vec3( 1.0 - darkness ), dot( uv, uv ) ), texel.a );",
+
+ /*
+ // alternative version from glfx.js
+ // this one makes more "dusty" look (as opposed to "burned")
+
+ "vec4 color = texture2D( tDiffuse, vUv );",
+ "float dist = distance( vUv, vec2( 0.5 ) );",
+ "color.rgb *= smoothstep( 0.8, offset * 0.799, dist *( darkness + offset ) );",
+ "gl_FragColor = color;",
+ */
+
+ "}"
+
+ ].join( "\n" )
+
+};
+
+export { VignetteShader };
diff --git a/examples/jsm/shaders/WaterRefractionShader.d.ts b/examples/jsm/shaders/WaterRefractionShader.d.ts
index a65d18eb3f159ce2191ea4589bca8169009e19ae..21bd02de3f3b4e32725857672a8bd11fee57bf5a 100644
--- a/examples/jsm/shaders/WaterRefractionShader.d.ts
+++ b/examples/jsm/shaders/WaterRefractionShader.d.ts
@@ -11,5 +11,5 @@ export interface WaterRefractionShader {
textureMatrix: Uniform;
};
vertexShader: string;
- fragmentShader:string;
+ fragmentShader: string;
}
diff --git a/examples/webgl_postprocessing_sobel.html b/examples/webgl_postprocessing_sobel.html
index ece0bfd4be4e55acd963e7703fc671e6f6cdd820..7e3b542d47e6a86265e16d535300869f5dd85a16 100644
--- a/examples/webgl_postprocessing_sobel.html
+++ b/examples/webgl_postprocessing_sobel.html
@@ -31,30 +31,34 @@
-
-
-
-
-
-
-
-
-
-
-
three.js - webgl - postprocessing - sobel (edge detection)
-