Sfoglia il codice sorgente

remove CompositeShader, it is equivalent to CopyShader. (#8926)

Ben Houston (Clara.io) 9 anni fa
parent
commit
a5c253cbb9

+ 16 - 26
examples/js/postprocessing/ManualMSAARenderPass.js

@@ -10,7 +10,7 @@
 *
 */
 
-THREE.ManualMSAARenderPass = function ( scene, camera, params ) {
+THREE.ManualMSAARenderPass = function ( scene, camera ) {
 
 	THREE.Pass.call( this );
 
@@ -19,35 +19,25 @@ THREE.ManualMSAARenderPass = function ( scene, camera, params ) {
 
 	this.sampleLevel = 4; // specified as n, where the number of samples is 2^n, so sampleLevel = 4, is 2^4 samples, 16.
 
-	this.params = params || { minFilter: THREE.NearestFilter, magFilter: THREE.NearestFilter, format: THREE.RGBAFormat };
-	this.params.minFilter = THREE.NearestFilter;
-	this.params.maxFilter = THREE.NearestFilter;
+	if ( THREE.CopyShader === undefined ) console.error( "THREE.ManualMSAARenderPass relies on THREE.CopyShader" );
 
-	if ( THREE.CompositeShader === undefined ) {
+	var copyShader = THREE.CopyShader;
+	this.copyUniforms = THREE.UniformsUtils.clone( copyShader.uniforms );
 
-		console.error( "THREE.ManualMSAARenderPass relies on THREE.CompositeShader" );
-
-	}
-
-	var compositeShader = THREE.CompositeShader;
-	this.compositeUniforms = THREE.UniformsUtils.clone( compositeShader.uniforms );
-
-	this.materialComposite = new THREE.ShaderMaterial(	{
-
-		uniforms: this.compositeUniforms,
-		vertexShader: compositeShader.vertexShader,
-		fragmentShader: compositeShader.fragmentShader,
+	this.copyMaterial = new THREE.ShaderMaterial(	{
+		uniforms: this.copyUniforms,
+		vertexShader: copyShader.vertexShader,
+		fragmentShader: copyShader.fragmentShader,
 		premultipliedAlpha: true,
 		transparent: true,
 		blending: THREE.AdditiveBlending,
 		depthTest: false,
 		depthWrite: false
-
 	} );
 
 	this.camera2 = new THREE.OrthographicCamera( - 1, 1, 1, - 1, 0, 1 );
 	this.scene2	= new THREE.Scene();
-	this.quad2 = new THREE.Mesh( new THREE.PlaneGeometry( 2, 2 ), this.materialComposite );
+	this.quad2 = new THREE.Mesh( new THREE.PlaneGeometry( 2, 2 ), this.copyMaterial );
 	this.scene2.add( this.quad2 );
 
 };
@@ -75,20 +65,20 @@ Object.assign( THREE.ManualMSAARenderPass.prototype, {
 
 	render: function ( renderer, writeBuffer, readBuffer, delta, maskActive ) {
 
-		var camera = ( this.camera || this.scene.camera );
-		var jitterOffsets = THREE.ManualMSAARenderPass.JitterVectors[ Math.max( 0, Math.min( this.sampleLevel, 5 ) ) ];
-
 		if ( ! this.sampleRenderTarget ) {
 
-			this.sampleRenderTarget = new THREE.WebGLRenderTarget( readBuffer.width, readBuffer.height, this.params );
+			this.sampleRenderTarget = new THREE.WebGLRenderTarget( readBuffer.width, readBuffer.height,
+				{ minFilter: THREE.LinearFilter, magFilter: THREE.LinearFilter, format: THREE.RGBAFormat } );
 
 		}
 
+		var jitterOffsets = THREE.ManualMSAARenderPass.JitterVectors[ Math.max( 0, Math.min( this.sampleLevel, 5 ) ) ];
+
 		var autoClear = renderer.autoClear;
 		renderer.autoClear = false;
 
-		this.compositeUniforms[ "scale" ].value = 1.0 / jitterOffsets.length;
-		this.compositeUniforms[ "tForeground" ].value = this.sampleRenderTarget.texture;
+		this.copyUniforms[ "opacity" ].value = 1.0 / jitterOffsets.length;
+		this.copyUniforms[ "tDiffuse" ].value = this.sampleRenderTarget.texture;
 
 		// render the scene multiple times, each slightly jitter offset from the last and accumulate the results.
 		for ( var i = 0; i < jitterOffsets.length; i ++ ) {
@@ -101,7 +91,7 @@ Object.assign( THREE.ManualMSAARenderPass.prototype, {
 					readBuffer.width, readBuffer.height );
 			}
 
-			renderer.render( this.scene, camera, this.sampleRenderTarget, true );
+			renderer.render( this.scene, this.camera, this.sampleRenderTarget, true );
 			renderer.render( this.scene2, this.camera2, writeBuffer, (i === 0) );
 
 		}

+ 6 - 8
examples/js/postprocessing/TAARenderPass.js

@@ -73,8 +73,8 @@ Object.assign( THREE.TAARenderPass.prototype, {
 
 		if( this.accumulateIndex >= 0 && this.accumulateIndex < jitterOffsets.length ) {
 
-			this.compositeUniforms[ "scale" ].value = sampleWeight;
-			this.compositeUniforms[ "tForeground" ].value = writeBuffer.texture;
+			this.copyUniforms[ "opacity" ].value = sampleWeight;
+			this.copyUniforms[ "tDiffuse" ].value = writeBuffer.texture;
 
 			// render the scene multiple times, each slightly jitter offset from the last and accumulate the results.
 			var numSamplesPerFrame = Math.pow( 2, this.sampleLevel );
@@ -90,7 +90,6 @@ Object.assign( THREE.TAARenderPass.prototype, {
 				}
 
 				renderer.render( this.scene, this.camera, writeBuffer, true );
-
 				renderer.render( this.scene2, this.camera2, this.sampleRenderTarget, ( this.accumulateIndex === 0 ) );
 
 				this.accumulateIndex ++;
@@ -105,14 +104,13 @@ Object.assign( THREE.TAARenderPass.prototype, {
 		var accumulationWeight = this.accumulateIndex * sampleWeight;
 
 		if( accumulationWeight > 0 ) {
-			this.compositeUniforms[ "scale" ].value = 1.0;
-			this.compositeUniforms[ "tForeground" ].value = this.sampleRenderTarget.texture;
+			this.copyUniforms[ "opacity" ].value = 1.0;
+			this.copyUniforms[ "tDiffuse" ].value = this.sampleRenderTarget.texture;
 			renderer.render( this.scene2, this.camera2, writeBuffer, true );
 		}
-
 		if( accumulationWeight < 1.0 ) {
-			this.compositeUniforms[ "scale" ].value = 1.0 - accumulationWeight;
-			this.compositeUniforms[ "tForeground" ].value = this.holdRenderTarget.texture;
+			this.copyUniforms[ "opacity" ].value = 1.0 - accumulationWeight;
+			this.copyUniforms[ "tDiffuse" ].value = this.holdRenderTarget.texture;
 			renderer.render( this.scene2, this.camera2, writeBuffer, ( accumulationWeight === 0 ) );
 		}
 

+ 0 - 48
examples/js/shaders/CompositeShader.js

@@ -1,48 +0,0 @@
-/**
- * @author bhouston / http://clara.io/
- *
- * Multi-Sample Anti-aliasing shader - for blending together sample buffers
- */
-
-THREE.CompositeShader = {
-
-	shaderID: "composite",
-
-	uniforms: {
-
-		"tForeground": { type: "t", value: null },
-		"scale": { type: "f", value: 1.0 }
-
-	},
-
-	vertexShader: [
-
-		"varying vec2 vUv;",
-
-		"void main() {",
-
-			"vUv = uv;",
-			"gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );",
-
-		"}"
-
-	].join( '\n' ),
-
-	fragmentShader: [
-
-		"varying vec2 vUv;",
-
-		"uniform sampler2D tForeground;",
-		"uniform float scale;",
-
-		"void main() {",
-
-			"vec4 foreground = texture2D( tForeground, vUv );",
-
-			"gl_FragColor = foreground * scale;",
-
-		"}"
-
-	].join( '\n' )
-
-};

+ 0 - 1
examples/webgl_postprocessing_msaa.html

@@ -40,7 +40,6 @@
 		<script src="js/libs/dat.gui.min.js"></script>
 
 		<script src="js/shaders/CopyShader.js"></script>
-		<script src="js/shaders/CompositeShader.js"></script>
 
 		<script src="js/postprocessing/EffectComposer.js"></script>
 		<script src="js/postprocessing/ManualMSAARenderPass.js"></script>

+ 0 - 1
examples/webgl_postprocessing_taa.html

@@ -41,7 +41,6 @@
 		<script src="js/libs/dat.gui.min.js"></script>
 
 		<script src="js/shaders/CopyShader.js"></script>
-		<script src="js/shaders/CompositeShader.js"></script>
 
 		<script src="js/postprocessing/EffectComposer.js"></script>
 		<script src="js/postprocessing/ManualMSAARenderPass.js"></script>