Skip to content

Commit 877cbd0

Browse files
committed
Version 2.1.1.
1 parent ed972ac commit 877cbd0

File tree

5 files changed

+154
-65
lines changed

5 files changed

+154
-65
lines changed

build/postprocessing.js

Lines changed: 69 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* postprocessing v2.1.0 build Mar 15 2017
2+
* postprocessing v2.1.1 build Apr 17 2017
33
* https://github.com/vanruesc/postprocessing
44
* Copyright 2017 Raoul van Rüschen, Zlib
55
*/
@@ -10,7 +10,7 @@
1010
(factory((global.POSTPROCESSING = global.POSTPROCESSING || {}),global.THREE));
1111
}(this, (function (exports,three) { 'use strict';
1212

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";
1414

1515
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";
1616

@@ -108,6 +108,7 @@
108108

109109
tPreviousLum: new three.Uniform(null),
110110
tCurrentLum: new three.Uniform(null),
111+
minLuminance: new three.Uniform(0.01),
111112
delta: new three.Uniform(0.0),
112113
tau: new three.Uniform(1.0)
113114

@@ -1106,7 +1107,7 @@
11061107

11071108
tDiffuse: new three.Uniform(null),
11081109
distinction: new three.Uniform(1.0),
1109-
range: new three.Uniform(range)
1110+
range: new three.Uniform(range !== null ? range : new three.Vector2())
11101111

11111112
},
11121113

@@ -1128,7 +1129,7 @@
11281129
return LuminosityMaterial;
11291130
}(three.ShaderMaterial);
11301131

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";
11321133

11331134
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";
11341135

@@ -1145,32 +1146,73 @@
11451146
*/
11461147

11471148
var PixelationMaterial = function (_ShaderMaterial) {
1148-
inherits(PixelationMaterial, _ShaderMaterial);
1149+
inherits(PixelationMaterial, _ShaderMaterial);
11491150

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, {
11531154

1154-
type: "PixelationMaterial",
1155+
type: "PixelationMaterial",
11551156

1156-
uniforms: {
1157+
uniforms: {
11571158

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)
11611164

1162-
},
1165+
},
11631166

1164-
fragmentShader: fragment$12,
1165-
vertexShader: vertex$12,
1167+
fragmentShader: fragment$12,
1168+
vertexShader: vertex$12,
11661169

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",
11691185

1170-
}));
1171-
}
11721186

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;
11741216
}(three.ShaderMaterial);
11751217

11761218
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,7 +1473,7 @@
14311473
* Full-screen tone-mapping shader material.
14321474
*
14331475
* 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
14351477
*
14361478
* @class ToneMappingMaterial
14371479
* @submodule materials
@@ -1567,7 +1609,6 @@
15671609
*
15681610
* @property needsSwap
15691611
* @type Boolean
1570-
* @private
15711612
* @default false
15721613
*/
15731614

@@ -3341,7 +3382,7 @@
33413382
* {{#crossLink "EffectComposer/setSize:method"}}{{/crossLink}} after changing
33423383
* this value.
33433384
*
3344-
* @property kernelSize
3385+
* @property resolutionScale
33453386
* @type Number
33463387
* @default 0.5
33473388
*/
@@ -3743,12 +3784,12 @@
37433784
key: "setSize",
37443785
value: function setSize(width, height) {
37453786

3746-
this.pixelationMaterial.uniforms.resolution.value.set(width, height);
3787+
this.pixelationMaterial.setResolution(width, height);
37473788
}
37483789
}, {
37493790
key: "granularity",
37503791
get: function get$$1() {
3751-
return this.pixelationMaterial.uniforms.granularity.value;
3792+
return this.pixelationMaterial.granularity;
37523793
},
37533794
set: function set$$1(x) {
37543795

@@ -3761,7 +3802,7 @@
37613802
x += 1;
37623803
}
37633804

3764-
this.pixelationMaterial.uniforms.granularity.value = x;
3805+
this.pixelationMaterial.granularity = x;
37653806
}
37663807
}
37673808
}]);
@@ -4061,7 +4102,7 @@
40614102
/**
40624103
* The speed of the shock wave animation.
40634104
*
4064-
* @property time
4105+
* @property speed
40654106
* @type Number
40664107
* @default 2.0
40674108
*/

build/postprocessing.min.js

Lines changed: 6 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "postprocessing",
3-
"version": "2.1.0",
3+
"version": "2.1.1",
44
"description": "A post processing library that provides the means to implement 2D filter effects for three.js.",
55
"homepage": "https://github.com/vanruesc/postprocessing",
66
"main": "build/postprocessing.js",

0 commit comments

Comments
 (0)