|
@@ -1,24 +1,21 @@
|
|
import {
|
|
import {
|
|
RawShaderMaterial,
|
|
RawShaderMaterial,
|
|
UniformsUtils,
|
|
UniformsUtils,
|
|
- NoToneMapping,
|
|
|
|
LinearToneMapping,
|
|
LinearToneMapping,
|
|
ReinhardToneMapping,
|
|
ReinhardToneMapping,
|
|
CineonToneMapping,
|
|
CineonToneMapping,
|
|
- ACESFilmicToneMapping
|
|
|
|
|
|
+ ACESFilmicToneMapping,
|
|
|
|
+ SRGBColorSpace
|
|
} from 'three';
|
|
} from 'three';
|
|
import { Pass, FullScreenQuad } from './Pass.js';
|
|
import { Pass, FullScreenQuad } from './Pass.js';
|
|
import { OutputShader } from '../shaders/OutputShader.js';
|
|
import { OutputShader } from '../shaders/OutputShader.js';
|
|
|
|
|
|
class OutputPass extends Pass {
|
|
class OutputPass extends Pass {
|
|
|
|
|
|
- constructor( toneMapping = NoToneMapping, toneMappingExposure = 1 ) {
|
|
|
|
|
|
+ constructor() {
|
|
|
|
|
|
super();
|
|
super();
|
|
|
|
|
|
- this.toneMapping = toneMapping;
|
|
|
|
- this.toneMappingExposure = toneMappingExposure;
|
|
|
|
-
|
|
|
|
//
|
|
//
|
|
|
|
|
|
const shader = OutputShader;
|
|
const shader = OutputShader;
|
|
@@ -31,19 +28,41 @@ class OutputPass extends Pass {
|
|
fragmentShader: shader.fragmentShader
|
|
fragmentShader: shader.fragmentShader
|
|
} );
|
|
} );
|
|
|
|
|
|
- if ( toneMapping === LinearToneMapping ) this.material.defines.LINEAR_TONE_MAPPING = '';
|
|
|
|
- else if ( toneMapping === ReinhardToneMapping ) this.material.defines.REINHARD_TONE_MAPPING = '';
|
|
|
|
- else if ( toneMapping === CineonToneMapping ) this.material.defines.CINEON_TONE_MAPPING = '';
|
|
|
|
- else if ( toneMapping === ACESFilmicToneMapping ) this.material.defines.ACES_FILMIC_TONE_MAPPING = '';
|
|
|
|
-
|
|
|
|
this.fsQuad = new FullScreenQuad( this.material );
|
|
this.fsQuad = new FullScreenQuad( this.material );
|
|
|
|
|
|
|
|
+ // internal cache
|
|
|
|
+
|
|
|
|
+ this._outputColorSpace = null;
|
|
|
|
+ this._toneMapping = null;
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
render( renderer, writeBuffer, readBuffer/*, deltaTime, maskActive */ ) {
|
|
render( renderer, writeBuffer, readBuffer/*, deltaTime, maskActive */ ) {
|
|
|
|
|
|
this.uniforms[ 'tDiffuse' ].value = readBuffer.texture;
|
|
this.uniforms[ 'tDiffuse' ].value = readBuffer.texture;
|
|
- this.uniforms[ 'toneMappingExposure' ].value = this.toneMappingExposure;
|
|
|
|
|
|
+ this.uniforms[ 'toneMappingExposure' ].value = renderer.toneMappingExposure;
|
|
|
|
+
|
|
|
|
+ // rebuild defines if required
|
|
|
|
+
|
|
|
|
+ if ( this._outputColorSpace !== renderer.outputColorSpace || this._toneMapping !== renderer.toneMapping ) {
|
|
|
|
+
|
|
|
|
+ this._outputColorSpace = renderer.outputColorSpace;
|
|
|
|
+ this._toneMapping = renderer.toneMapping;
|
|
|
|
+
|
|
|
|
+ this.material.defines = {};
|
|
|
|
+
|
|
|
|
+ if ( this._outputColorSpace == SRGBColorSpace ) this.material.defines.SRGB_COLOR_SPACE = '';
|
|
|
|
+
|
|
|
|
+ if ( this._toneMapping === LinearToneMapping ) this.material.defines.LINEAR_TONE_MAPPING = '';
|
|
|
|
+ else if ( this._toneMapping === ReinhardToneMapping ) this.material.defines.REINHARD_TONE_MAPPING = '';
|
|
|
|
+ else if ( this._toneMapping === CineonToneMapping ) this.material.defines.CINEON_TONE_MAPPING = '';
|
|
|
|
+ else if ( this._toneMapping === ACESFilmicToneMapping ) this.material.defines.ACES_FILMIC_TONE_MAPPING = '';
|
|
|
|
+
|
|
|
|
+ this.material.needsUpdate = true;
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //
|
|
|
|
|
|
if ( this.renderToScreen === true ) {
|
|
if ( this.renderToScreen === true ) {
|
|
|
|
|