|
1 | 1 | /** |
2 | | - * postprocessing v2.1.0 build Mar 15 2017 |
| 2 | + * postprocessing v2.1.1 build Apr 17 2017 |
3 | 3 | * https://github.com/vanruesc/postprocessing |
4 | 4 | * Copyright 2017 Raoul van Rüschen, Zlib |
5 | 5 | */ |
|
10 | 10 | (factory((global.POSTPROCESSING = global.POSTPROCESSING || {}),global.THREE)); |
11 | 11 | }(this, (function (exports,three) { 'use strict'; |
12 | 12 |
|
13 | | - var fragment = "uniform sampler2D tPreviousLum;\r\nuniform sampler2D tCurrentLum;\r\nuniform float delta;\r\nuniform float tau;\r\n\r\nvarying vec2 vUv;\r\n\r\nvoid main() {\r\n\r\n\tfloat previousLum = texture2D(tPreviousLum, vUv, MIP_LEVEL_1X1).r;\r\n\tfloat currentLum = texture2D(tCurrentLum, vUv, MIP_LEVEL_1X1).r;\r\n\r\n\t// Adapt the luminance using Pattanaik's technique.\r\n\tfloat adaptedLum = previousLum + (currentLum - previousLum) * (1.0 - exp(-delta * tau));\r\n\r\n\tgl_FragColor = vec4(adaptedLum, adaptedLum, adaptedLum, 1.0);\r\n\r\n}\r\n"; |
| 13 | + var fragment = "uniform sampler2D tPreviousLum;\r\nuniform sampler2D tCurrentLum;\r\nuniform float minLuminance;\r\nuniform float delta;\r\nuniform float tau;\r\n\r\nvarying vec2 vUv;\r\n\r\nvoid main() {\r\n\r\n\tfloat previousLum = texture2D(tPreviousLum, vUv, MIP_LEVEL_1X1).r;\r\n\tfloat currentLum = texture2D(tCurrentLum, vUv, MIP_LEVEL_1X1).r;\r\n\r\n\tpreviousLum = max(minLuminance, previousLum);\r\n\tcurrentLum = max(minLuminance, currentLum);\r\n\r\n\t// Adapt the luminance using Pattanaik's technique.\r\n\tfloat adaptedLum = previousLum + (currentLum - previousLum) * (1.0 - exp(-delta * tau));\r\n\r\n\tgl_FragColor.r = adaptedLum;\r\n\r\n}\r\n"; |
14 | 14 |
|
15 | 15 | var vertex = "varying vec2 vUv;\r\n\r\nvoid main() {\r\n\r\n\tvUv = uv;\r\n\tgl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\r\n\r\n}\r\n"; |
16 | 16 |
|
|
108 | 108 |
|
109 | 109 | tPreviousLum: new three.Uniform(null), |
110 | 110 | tCurrentLum: new three.Uniform(null), |
| 111 | + minLuminance: new three.Uniform(0.01), |
111 | 112 | delta: new three.Uniform(0.0), |
112 | 113 | tau: new three.Uniform(1.0) |
113 | 114 |
|
|
1106 | 1107 |
|
1107 | 1108 | tDiffuse: new three.Uniform(null), |
1108 | 1109 | distinction: new three.Uniform(1.0), |
1109 | | - range: new three.Uniform(range) |
| 1110 | + range: new three.Uniform(range !== null ? range : new three.Vector2()) |
1110 | 1111 |
|
1111 | 1112 | }, |
1112 | 1113 |
|
|
1128 | 1129 | return LuminosityMaterial; |
1129 | 1130 | }(three.ShaderMaterial); |
1130 | 1131 |
|
1131 | | - var fragment$12 = "uniform sampler2D tDiffuse;\r\nuniform float granularity;\r\nuniform vec2 resolution;\r\n\r\nvarying vec2 vUv;\r\n\r\nvoid main() {\r\n\r\n\tvec4 texel;\r\n\r\n\tif(granularity > 0.0) {\r\n\r\n\t\tfloat dx = granularity / resolution.x;\r\n\t\tfloat dy = granularity / resolution.y;\r\n\r\n\t\tvec2 coord = vec2(\r\n\t\t\tdx * (floor(vUv.x / dx) + 0.5),\r\n\t\t\tdy * (floor(vUv.y / dy) + 0.5)\r\n\t\t);\r\n\r\n\t\ttexel = texture2D(tDiffuse, coord);\r\n\r\n\t} else {\r\n\r\n\t\ttexel = texture2D(tDiffuse, vUv);\r\n\r\n\t}\r\n\r\n\tgl_FragColor = texel;\r\n\r\n}\r\n"; |
| 1132 | + var fragment$12 = "uniform sampler2D tDiffuse;\r\nuniform float granularity;\r\nuniform float dx;\r\nuniform float dy;\r\n\r\nvarying vec2 vUv;\r\n\r\nvoid main() {\r\n\r\n\tvec4 texel;\r\n\r\n\tif(granularity > 0.0) {\r\n\r\n\t\tvec2 coord = vec2(\r\n\t\t\tdx * (floor(vUv.x / dx) + 0.5),\r\n\t\t\tdy * (floor(vUv.y / dy) + 0.5)\r\n\t\t);\r\n\r\n\t\ttexel = texture2D(tDiffuse, coord);\r\n\r\n\t} else {\r\n\r\n\t\ttexel = texture2D(tDiffuse, vUv);\r\n\r\n\t}\r\n\r\n\tgl_FragColor = texel;\r\n\r\n}\r\n"; |
1132 | 1133 |
|
1133 | 1134 | var vertex$12 = "varying vec2 vUv;\r\n\r\nvoid main() {\r\n\r\n\tvUv = uv;\r\n\tgl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\r\n\r\n}\r\n"; |
1134 | 1135 |
|
|
1145 | 1146 | */ |
1146 | 1147 |
|
1147 | 1148 | var PixelationMaterial = function (_ShaderMaterial) { |
1148 | | - inherits(PixelationMaterial, _ShaderMaterial); |
| 1149 | + inherits(PixelationMaterial, _ShaderMaterial); |
1149 | 1150 |
|
1150 | | - function PixelationMaterial() { |
1151 | | - classCallCheck(this, PixelationMaterial); |
1152 | | - return possibleConstructorReturn(this, (PixelationMaterial.__proto__ || Object.getPrototypeOf(PixelationMaterial)).call(this, { |
| 1151 | + function PixelationMaterial() { |
| 1152 | + classCallCheck(this, PixelationMaterial); |
| 1153 | + return possibleConstructorReturn(this, (PixelationMaterial.__proto__ || Object.getPrototypeOf(PixelationMaterial)).call(this, { |
1153 | 1154 |
|
1154 | | - type: "PixelationMaterial", |
| 1155 | + type: "PixelationMaterial", |
1155 | 1156 |
|
1156 | | - uniforms: { |
| 1157 | + uniforms: { |
1157 | 1158 |
|
1158 | | - tDiffuse: new three.Uniform(null), |
1159 | | - granularity: new three.Uniform(1.0), |
1160 | | - resolution: new three.Uniform(new three.Vector2(1.0, 1.0)) |
| 1159 | + tDiffuse: new three.Uniform(null), |
| 1160 | + granularity: new three.Uniform(1.0), |
| 1161 | + resolution: new three.Uniform(new three.Vector2(1.0, 1.0)), |
| 1162 | + dx: new three.Uniform(1.0), |
| 1163 | + dy: new three.Uniform(1.0) |
1161 | 1164 |
|
1162 | | - }, |
| 1165 | + }, |
1163 | 1166 |
|
1164 | | - fragmentShader: fragment$12, |
1165 | | - vertexShader: vertex$12, |
| 1167 | + fragmentShader: fragment$12, |
| 1168 | + vertexShader: vertex$12, |
1166 | 1169 |
|
1167 | | - depthWrite: false, |
1168 | | - depthTest: false |
| 1170 | + depthWrite: false, |
| 1171 | + depthTest: false |
| 1172 | + |
| 1173 | + })); |
| 1174 | + } |
| 1175 | + |
| 1176 | + /** |
| 1177 | + * The pixel granularity. |
| 1178 | + * |
| 1179 | + * @property granularity |
| 1180 | + * @type Number |
| 1181 | + */ |
| 1182 | + |
| 1183 | + createClass(PixelationMaterial, [{ |
| 1184 | + key: "setResolution", |
1169 | 1185 |
|
1170 | | - })); |
1171 | | - } |
1172 | 1186 |
|
1173 | | - return PixelationMaterial; |
| 1187 | + /** |
| 1188 | + * Sets the resolution. |
| 1189 | + * |
| 1190 | + * @method setResolution |
| 1191 | + * @param {Number} width - The width. |
| 1192 | + * @param {Number} height - The height. |
| 1193 | + */ |
| 1194 | + |
| 1195 | + value: function setResolution(width, height) { |
| 1196 | + |
| 1197 | + this.uniforms.resolution.value.set(width, height); |
| 1198 | + this.granularity = this.granularity; |
| 1199 | + } |
| 1200 | + }, { |
| 1201 | + key: "granularity", |
| 1202 | + get: function get$$1() { |
| 1203 | + return this.uniforms.granularity.value; |
| 1204 | + }, |
| 1205 | + set: function set$$1(x) { |
| 1206 | + |
| 1207 | + var uniforms = this.uniforms; |
| 1208 | + var resolution = uniforms.resolution.value; |
| 1209 | + |
| 1210 | + uniforms.granularity.value = x; |
| 1211 | + uniforms.dx.value = x / resolution.x; |
| 1212 | + uniforms.dy.value = x / resolution.y; |
| 1213 | + } |
| 1214 | + }]); |
| 1215 | + return PixelationMaterial; |
1174 | 1216 | }(three.ShaderMaterial); |
1175 | 1217 |
|
1176 | 1218 | var fragment$13 = "#include <common>\r\n\r\nuniform sampler2D tDiffuse;\r\nuniform vec2 center;\r\nuniform float aspect;\r\nuniform float waveSize;\r\nuniform float radius;\r\nuniform float maxRadius;\r\nuniform float amplitude;\r\n\r\nvarying vec2 vUv;\r\nvarying float vSize;\r\n\r\nvoid main() {\r\n\r\n\tvec2 aspectCorrection = vec2(aspect, 1.0);\r\n\r\n\tvec2 difference = vUv * aspectCorrection - center * aspectCorrection;\r\n\tfloat distance = sqrt(dot(difference, difference)) * vSize;\r\n\r\n\tvec2 displacement = vec2(0.0);\r\n\r\n\tif(distance > radius) {\r\n\r\n\t\tif(distance < radius + waveSize) {\r\n\r\n\t\t\tfloat angle = (distance - radius) * PI2 / waveSize;\r\n\t\t\tfloat cosSin = (1.0 - cos(angle)) * 0.5;\r\n\r\n\t\t\tfloat extent = maxRadius + waveSize;\r\n\t\t\tfloat decay = max(extent - distance * distance, 0.0) / extent;\r\n\r\n\t\t\tdisplacement = ((cosSin * amplitude * difference) / distance) * decay;\r\n\r\n\t\t}\r\n\r\n\t}\r\n\r\n\tgl_FragColor = texture2D(tDiffuse, vUv - displacement);\r\n\r\n}\r\n"; |
|
1431 | 1473 | * Full-screen tone-mapping shader material. |
1432 | 1474 | * |
1433 | 1475 | * Reference: |
1434 | | - * http://www.graphics.cornell.edu/~jaf/publications/sig02_paper.pdf |
| 1476 | + * http://www.cis.rit.edu/people/faculty/ferwerda/publications/sig02_paper.pdf |
1435 | 1477 | * |
1436 | 1478 | * @class ToneMappingMaterial |
1437 | 1479 | * @submodule materials |
|
1567 | 1609 | * |
1568 | 1610 | * @property needsSwap |
1569 | 1611 | * @type Boolean |
1570 | | - * @private |
1571 | 1612 | * @default false |
1572 | 1613 | */ |
1573 | 1614 |
|
|
3341 | 3382 | * {{#crossLink "EffectComposer/setSize:method"}}{{/crossLink}} after changing |
3342 | 3383 | * this value. |
3343 | 3384 | * |
3344 | | - * @property kernelSize |
| 3385 | + * @property resolutionScale |
3345 | 3386 | * @type Number |
3346 | 3387 | * @default 0.5 |
3347 | 3388 | */ |
|
3743 | 3784 | key: "setSize", |
3744 | 3785 | value: function setSize(width, height) { |
3745 | 3786 |
|
3746 | | - this.pixelationMaterial.uniforms.resolution.value.set(width, height); |
| 3787 | + this.pixelationMaterial.setResolution(width, height); |
3747 | 3788 | } |
3748 | 3789 | }, { |
3749 | 3790 | key: "granularity", |
3750 | 3791 | get: function get$$1() { |
3751 | | - return this.pixelationMaterial.uniforms.granularity.value; |
| 3792 | + return this.pixelationMaterial.granularity; |
3752 | 3793 | }, |
3753 | 3794 | set: function set$$1(x) { |
3754 | 3795 |
|
|
3761 | 3802 | x += 1; |
3762 | 3803 | } |
3763 | 3804 |
|
3764 | | - this.pixelationMaterial.uniforms.granularity.value = x; |
| 3805 | + this.pixelationMaterial.granularity = x; |
3765 | 3806 | } |
3766 | 3807 | } |
3767 | 3808 | }]); |
|
4061 | 4102 | /** |
4062 | 4103 | * The speed of the shock wave animation. |
4063 | 4104 | * |
4064 | | - * @property time |
| 4105 | + * @property speed |
4065 | 4106 | * @type Number |
4066 | 4107 | * @default 2.0 |
4067 | 4108 | */ |
|
0 commit comments