|
@@ -49,7 +49,7 @@ THREE.AdaptiveToneMappingPass = function ( adaptive, resolution ) {
|
|
|
|
|
|
this.adaptLuminanceShader = {
|
|
this.adaptLuminanceShader = {
|
|
defines: {
|
|
defines: {
|
|
- "MIP_LEVEL_1X1" : ( Math.log( this.resolution ) / Math.log( 2.0 ) ).toFixed( 1 )
|
|
|
|
|
|
+ "MIP_LEVEL_1X1": ( Math.log( this.resolution ) / Math.log( 2.0 ) ).toFixed( 1 )
|
|
},
|
|
},
|
|
uniforms: {
|
|
uniforms: {
|
|
"lastLum": { value: null },
|
|
"lastLum": { value: null },
|
|
@@ -63,8 +63,8 @@ THREE.AdaptiveToneMappingPass = function ( adaptive, resolution ) {
|
|
|
|
|
|
"void main() {",
|
|
"void main() {",
|
|
|
|
|
|
- "vUv = uv;",
|
|
|
|
- "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );",
|
|
|
|
|
|
+ " vUv = uv;",
|
|
|
|
+ " gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );",
|
|
|
|
|
|
"}"
|
|
"}"
|
|
].join( '\n' ),
|
|
].join( '\n' ),
|
|
@@ -79,20 +79,20 @@ THREE.AdaptiveToneMappingPass = function ( adaptive, resolution ) {
|
|
|
|
|
|
"void main() {",
|
|
"void main() {",
|
|
|
|
|
|
- "vec4 lastLum = texture2D( lastLum, vUv, MIP_LEVEL_1X1 );",
|
|
|
|
- "vec4 currentLum = texture2D( currentLum, vUv, MIP_LEVEL_1X1 );",
|
|
|
|
|
|
+ " vec4 lastLum = texture2D( lastLum, vUv, MIP_LEVEL_1X1 );",
|
|
|
|
+ " vec4 currentLum = texture2D( currentLum, vUv, MIP_LEVEL_1X1 );",
|
|
|
|
|
|
- "float fLastLum = max( minLuminance, lastLum.r );",
|
|
|
|
- "float fCurrentLum = max( minLuminance, currentLum.r );",
|
|
|
|
|
|
+ " float fLastLum = max( minLuminance, lastLum.r );",
|
|
|
|
+ " float fCurrentLum = max( minLuminance, currentLum.r );",
|
|
|
|
|
|
- //The adaption seems to work better in extreme lighting differences
|
|
|
|
- //if the input luminance is squared.
|
|
|
|
- "fCurrentLum *= fCurrentLum;",
|
|
|
|
|
|
+ //The adaption seems to work better in extreme lighting differences
|
|
|
|
+ //if the input luminance is squared.
|
|
|
|
+ " fCurrentLum *= fCurrentLum;",
|
|
|
|
|
|
- // Adapt the luminance using Pattanaik's technique
|
|
|
|
- "float fAdaptedLum = fLastLum + (fCurrentLum - fLastLum) * (1.0 - exp(-delta * tau));",
|
|
|
|
- // "fAdaptedLum = sqrt(fAdaptedLum);",
|
|
|
|
- "gl_FragColor.r = fAdaptedLum;",
|
|
|
|
|
|
+ // Adapt the luminance using Pattanaik's technique
|
|
|
|
+ " float fAdaptedLum = fLastLum + (fCurrentLum - fLastLum) * (1.0 - exp(-delta * tau));",
|
|
|
|
+ // "fAdaptedLum = sqrt(fAdaptedLum);",
|
|
|
|
+ " gl_FragColor.r = fAdaptedLum;",
|
|
"}"
|
|
"}"
|
|
].join( '\n' )
|
|
].join( '\n' )
|
|
};
|
|
};
|
|
@@ -118,7 +118,7 @@ THREE.AdaptiveToneMappingPass = function ( adaptive, resolution ) {
|
|
} );
|
|
} );
|
|
|
|
|
|
this.camera = new THREE.OrthographicCamera( - 1, 1, 1, - 1, 0, 1 );
|
|
this.camera = new THREE.OrthographicCamera( - 1, 1, 1, - 1, 0, 1 );
|
|
- this.scene = new THREE.Scene();
|
|
|
|
|
|
+ this.scene = new THREE.Scene();
|
|
|
|
|
|
this.quad = new THREE.Mesh( new THREE.PlaneBufferGeometry( 2, 2 ), null );
|
|
this.quad = new THREE.Mesh( new THREE.PlaneBufferGeometry( 2, 2 ), null );
|
|
this.quad.frustumCulled = false; // Avoid getting clipped
|
|
this.quad.frustumCulled = false; // Avoid getting clipped
|
|
@@ -188,7 +188,7 @@ THREE.AdaptiveToneMappingPass.prototype = Object.assign( Object.create( THREE.Pa
|
|
|
|
|
|
},
|
|
},
|
|
|
|
|
|
- reset: function( renderer ) {
|
|
|
|
|
|
+ reset: function ( renderer ) {
|
|
|
|
|
|
// render targets
|
|
// render targets
|
|
if ( this.luminanceRT ) {
|
|
if ( this.luminanceRT ) {
|
|
@@ -240,7 +240,7 @@ THREE.AdaptiveToneMappingPass.prototype = Object.assign( Object.create( THREE.Pa
|
|
|
|
|
|
},
|
|
},
|
|
|
|
|
|
- setAdaptive: function( adaptive ) {
|
|
|
|
|
|
+ setAdaptive: function ( adaptive ) {
|
|
|
|
|
|
if ( adaptive ) {
|
|
if ( adaptive ) {
|
|
|
|
|
|
@@ -259,7 +259,7 @@ THREE.AdaptiveToneMappingPass.prototype = Object.assign( Object.create( THREE.Pa
|
|
|
|
|
|
},
|
|
},
|
|
|
|
|
|
- setAdaptionRate: function( rate ) {
|
|
|
|
|
|
+ setAdaptionRate: function ( rate ) {
|
|
|
|
|
|
if ( rate ) {
|
|
if ( rate ) {
|
|
|
|
|
|
@@ -269,7 +269,7 @@ THREE.AdaptiveToneMappingPass.prototype = Object.assign( Object.create( THREE.Pa
|
|
|
|
|
|
},
|
|
},
|
|
|
|
|
|
- setMinLuminance: function( minLum ) {
|
|
|
|
|
|
+ setMinLuminance: function ( minLum ) {
|
|
|
|
|
|
if ( minLum ) {
|
|
if ( minLum ) {
|
|
|
|
|
|
@@ -280,7 +280,7 @@ THREE.AdaptiveToneMappingPass.prototype = Object.assign( Object.create( THREE.Pa
|
|
|
|
|
|
},
|
|
},
|
|
|
|
|
|
- setMaxLuminance: function( maxLum ) {
|
|
|
|
|
|
+ setMaxLuminance: function ( maxLum ) {
|
|
|
|
|
|
if ( maxLum ) {
|
|
if ( maxLum ) {
|
|
|
|
|
|
@@ -290,7 +290,7 @@ THREE.AdaptiveToneMappingPass.prototype = Object.assign( Object.create( THREE.Pa
|
|
|
|
|
|
},
|
|
},
|
|
|
|
|
|
- setAverageLuminance: function( avgLum ) {
|
|
|
|
|
|
+ setAverageLuminance: function ( avgLum ) {
|
|
|
|
|
|
if ( avgLum ) {
|
|
if ( avgLum ) {
|
|
|
|
|
|
@@ -300,7 +300,7 @@ THREE.AdaptiveToneMappingPass.prototype = Object.assign( Object.create( THREE.Pa
|
|
|
|
|
|
},
|
|
},
|
|
|
|
|
|
- setMiddleGrey: function( middleGrey ) {
|
|
|
|
|
|
+ setMiddleGrey: function ( middleGrey ) {
|
|
|
|
|
|
if ( middleGrey ) {
|
|
if ( middleGrey ) {
|
|
|
|
|
|
@@ -310,7 +310,7 @@ THREE.AdaptiveToneMappingPass.prototype = Object.assign( Object.create( THREE.Pa
|
|
|
|
|
|
},
|
|
},
|
|
|
|
|
|
- dispose: function() {
|
|
|
|
|
|
+ dispose: function () {
|
|
|
|
|
|
if ( this.luminanceRT ) {
|
|
if ( this.luminanceRT ) {
|
|
|
|
|