When i use post-process, background img is covered

how should i solve this problem?

Can you provide more details? Nobody will be able to help you with what you have given so far.

1 Like

im sorryโ€ฆ

I have something to solve before the original question( title )โ€ฆ

I want to use post-processing.

I have found several problems.

If I addpass the smaa to the composer, there is an error that the nodepass that was originally done with addpass is not displayed on the screen.
Likewise, if I addpass smaa first, smaa is not displayed on the screen.

	<style>
		body {
			margin: 0px;
			background-color: #000;
			overflow: hidden;
			font-family:Monospace;
			font-size:13px;
			margin: 0px;
			text-align:center;
			overflow: hidden;
		}
		#info {
			color: #fff;
			position: absolute;
			top: 10px;
			width: 100%;
			text-align: center;
			display:block;
		}
	</style>
</head>
<body>
	<script src="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
	
	
	
	<script src="js/build/three.js"></script>
	<script src="js/controls/OrbitControls.js"></script>
	<script src="js/libs/dat.gui.min.js"></script>

	<script src="js/postprocessing/EffectComposer.js"></script>
		
	<script src="js/shaders/CopyShader.js"></script>
<script src="js/shaders/SMAAShader.js"></script>		
<script src="js/postprocessing/SMAAPass.js"></script>

	<script src="js/postprocessing/RenderPass.js"></script>

	<script src="js/postprocessing/ShaderPass.js"></script>

	<!-- NodeLibrary -->
	<script src="js/nodes/GLNode.js"></script>
	<script src="js/nodes/RawNode.js"></script>
	<script src="js/nodes/TempNode.js"></script>
	<script src="js/nodes/InputNode.js"></script>
	<script src="js/nodes/ConstNode.js"></script>
	<script src="js/nodes/FunctionNode.js"></script>
	

	
	<script src="js/nodes/NodeBuilder.js"></script>
	<script src="js/nodes/NodeLib.js"></script>
	<script src="js/nodes/NodeMaterial.js"></script>

	<!-- Accessors -->
	<script src="js/nodes/accessors/PositionNode.js"></script>
	<script src="js/nodes/accessors/UVNode.js"></script>

	<!-- Inputs -->
	<script src="js/nodes/inputs/FloatNode.js"></script>
	<script src="js/nodes/inputs/ColorNode.js"></script>

	<script src="js/nodes/inputs/TextureNode.js"></script>

	<script src="js/nodes/inputs/ScreenNode.js"></script>

	<!-- Math -->


	<!-- Utils -->

	<script src="js/nodes/utils/ColorAdjustmentNode.js"></script>


	<!-- Post-Processing -->
	<script src="js/nodes/postprocessing/NodePass.js"></script>

	<script>
	
		var camera, controls, scene, renderer;
		var object;
		
		var composer;
		var nodepass;	
		var smaapass;	
		
		var clock = new THREE.Clock();
		var gui;
		var param = {};	
		
				
		init();
		animate();
		
		function clearGui() {
			if ( gui ) gui.destroy();
			gui = new dat.GUI();
		}
		
		
		function addGui( name, value, callback, isColor, min, max ) {
		
			var node;	
			
			param[ name ] = value;	
			
			if ( isColor ) {												
				node = gui.addColor( param, name ).onChange( function() {	
					callback( param[ name ] );								
				} );
			} else if ( typeof value == 'object' ) {						
				node = gui.add( param, name, value ).onChange( function() {	
					callback( param[ name ] );								
				} );
			} else {
				node = gui.add( param, name, min, max ).onChange( function() {	
					callback( param[ name ] );									
				} );
			}
			return node;	//
		}
		
		clearGui();	// 

	
		var screen = new THREE.ScreenNode();
		var hue = new THREE.FloatNode();
		var sataturation = new THREE.FloatNode( 1 );
		var vibrance = new THREE.FloatNode();
		var brightness = new THREE.FloatNode( 0 );
		var contrast = new THREE.FloatNode( 1 );
		var hueNode = new THREE.ColorAdjustmentNode( screen, hue, THREE.ColorAdjustmentNode.HUE );
		var satNode = new THREE.ColorAdjustmentNode( hueNode, sataturation, THREE.ColorAdjustmentNode.SATURATION );
		var vibranceNode = new THREE.ColorAdjustmentNode( satNode, vibrance, THREE.ColorAdjustmentNode.VIBRANCE );
		var brightnessNode = new THREE.ColorAdjustmentNode( vibranceNode, brightness, THREE.ColorAdjustmentNode.BRIGHTNESS );
		var contrastNode = new THREE.ColorAdjustmentNode( brightnessNode, contrast, THREE.ColorAdjustmentNode.CONTRAST );
		
		nodepass.value = contrastNode;
		
	// GUI
		addGui( 'saturation', sataturation.number, function( val ) {
			sataturation.number = val;
		}, false, 0, 2 );
		
		addGui( 'vibrance', vibrance.number, function( val ) {
			vibrance.number = val;
		}, false, - 1, 1 ).step(0.1);	
		
		addGui( 'contrast', contrast.number, function( val ) {
			contrast.number = val;
		}, false, 0, 2 );
	
		nodepass.build();

		
		function init() {
		
			renderer = new THREE.WebGLRenderer();						
			renderer.setPixelRatio( window.devicePixelRatio );			
			renderer.setSize( window.innerWidth, window.innerHeight );	 
			document.body.appendChild( renderer.domElement );			
			//
			camera = new THREE.PerspectiveCamera( 45, window.innerWidth / window.innerHeight, 1, 10000 );	
			camera.position.z = 150;																	
			scene = new THREE.Scene();																	
			controls = new THREE.OrbitControls( camera, renderer.domElement );
				var loader = new THREE.JSONLoader();
				loader.load( 'js/object/big_3d_1000.js', function( geometry ) {
					geometry.computeVertexNormals();
					var texture = THREE.ImageUtils.loadTexture( 'textures/big_map_1000.jpg' );
					var material = new THREE.MeshStandardMaterial( {
						map : texture
					});
					  
					texture.anisotropy = renderer.getMaxAnisotropy();
					 
					mesh = new THREE.Mesh( geometry, material );	
					scene.add( mesh );

				});

			
			scene.add( new THREE.AmbientLight( 0xffffff,2 ) );			
			composer = new THREE.EffectComposer( renderer );			
			composer.addPass( new THREE.RenderPass( scene, camera ) );	
		
			nodepass = new THREE.NodePass();
			nodepass.renderToScreen = true;
			composer.addPass( nodepass );
			
			smaapass = new THREE.SMAAPass( window.innerWidth, window.innerHeight );
			smaapass.renderToScreen = true;
			composer.addPass( smaapass );
			//

			window.addEventListener( 'resize', onWindowResize, false );
		}
		
		function onWindowResize() {
			camera.aspect = window.innerWidth / window.innerHeight;
			camera.updateProjectionMatrix();
			renderer.setSize( window.innerWidth, window.innerHeight );
			composer.setSize( window.innerWidth, window.innerHeight );
			
			//smaa
			var pixelRatio = renderer.getPixelRatio();
			var newWidth = Math.floor(  window.innerWidth / pixelRatio ) || 1;
			var newHeight = Math.floor(  window.innerHeight / pixelRatio ) || 1;
			composer.setSize( newWidth, newHeight );
		}
		
		function animate() {
			requestAnimationFrame( animate );
			var delta = clock.getDelta();
			nodepass.node.updateFrame( delta );
			composer.render();
		}
		
		
		
	</script>

</body>

I found the answer.

" nodepass.renderToScreen = false;//true; "

The problem was solved when I wrote this way.


But the problem with the title still remains.

The screen except for the 3D object becomes black and it is shown that alpha is canceled.

So I can not apply background-img to the body.

I want to solve this part.

Glad you solved your post-processing issue. But in future please stick to one question per post and include all relevant details from the start.

To show the background image under the rendered canvas, set alpha to true in the renderer:

var renderer = new THREE.WebGLRenderer( { alpha: true } );

You can leave the clear color at the default value.

renderer.setClearColor( 0x000000, 0 ); // default

im sorryโ€ฆ

English was a little hard for meโ€ฆ

I will do exact way in the future


thank you for your answer

I used to write according to your answers

but i could not resolve the problem

Is there any other wayโ€ฆ?

Thanks in advance for your answer.

Can you give an example that just shows the background image being covered, without the post-processing? The code you provided does not have a background image at allโ€ฆ

hereโ€™s a none post-processing screen and source

always thanks for your help

		body {
			margin: 0px;
			background-color: #fff;
			overflow: hidden;
			font-family:Monospace;
			font-size:13px;
			margin: 0px;
			text-align:center;
			overflow: hidden;
			background-image:url(http://sevensprings.dothome.co.kr/img/3.jpg);
		}
		#info {
			color: #fff;
			position: absolute;
			top: 10px;
			width: 100%;
			text-align: center;
			display:block;
		}



	
	
	<script src="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
	<script src="js/build/three.js"></script>
	<script src="js/controls/OrbitControls.js"></script>
	<script src="js/libs/dat.gui.min.js"></script>

	<script src="js/postprocessing/EffectComposer.js"></script>
		
	<script src="js/shaders/CopyShader.js"></script>
	
	<!-- SMAA -->
	<script src="js/shaders/SMAAShader.js"></script>		
	<script src="js/postprocessing/SMAAPass.js"></script>

	<script src="js/postprocessing/RenderPass.js"></script>
	
	<!-- <script src="js/postprocessing/MaskPass.js"></script> -->

	<script src="js/postprocessing/ShaderPass.js"></script>

	<!-- NodeLibrary -->
	<script src="js/nodes/GLNode.js"></script>
	<script src="js/nodes/RawNode.js"></script>
	<script src="js/nodes/TempNode.js"></script>
	<script src="js/nodes/InputNode.js"></script>
	<script src="js/nodes/ConstNode.js"></script>
	<script src="js/nodes/FunctionNode.js"></script>
	

	
	<script src="js/nodes/NodeBuilder.js"></script>
	<script src="js/nodes/NodeLib.js"></script>
	<script src="js/nodes/NodeMaterial.js"></script>

	<!-- Accessors -->
	<script src="js/nodes/accessors/PositionNode.js"></script>
	<script src="js/nodes/accessors/UVNode.js"></script>

	<!-- Inputs -->
	<script src="js/nodes/inputs/FloatNode.js"></script>
	<script src="js/nodes/inputs/ColorNode.js"></script>

	<script src="js/nodes/inputs/TextureNode.js"></script>

	<script src="js/nodes/inputs/ScreenNode.js"></script>

	<!-- Math -->


	<!-- Utils -->

	<script src="js/nodes/utils/ColorAdjustmentNode.js"></script>


	<!-- Post-Processing -->
	<script src="js/nodes/postprocessing/NodePass.js"></script>

	<script>
	
		var camera, controls, scene, renderer;
		var object;
	//	var textureLoader = new THREE.TextureLoader();
		
		var composer;
		var nodepass;	//์ž„์˜ ๋ณ€์ˆ˜ nodepass
		var SMAA_effect;	//์ž„์˜ ๋ณ€์ˆ˜ SMAA_effect - ์•ˆํ‹ฐ์•จ๋ฆฌ์–ด์‹ฑ
		
		var clock = new THREE.Clock();
		var gui;
		var param = {};	//์ž„์˜ ๊ฐ์ฒด param
		
				
		init();
		animate();
		// clearGUi() ํ•จ์ˆ˜
		function clearGui() {
			if ( gui ) gui.destroy();
			gui = new dat.GUI();
		}
		
		// addGui() ํ•จ์ˆ˜	 ์ด๋ฆ„,	๊ฐ’,		์ฝœ๋ฐฑํ•จ์ˆ˜,	???????, ์ตœ์†Œ, ์ตœ๋Œ€๊ฐ’
		function addGui( name, value, callback, isColor, min, max ) {
		
			var node;	//์ž„์˜ ๋ณ€์ˆ˜ node ์„ ์–ธ ( 3์ข…๋ฅ˜์˜ gui ์ถ”๊ฐ€ ํ•จ์ˆ˜๊ฐ€ ๋œ๋‹ค. )
			
			param[ name ] = value;	// ๋งค๊ฐœ๋ณ€์ˆ˜๋กœ ๋ฐ›์€ name์„ ์ž„์˜๊ฐ์ฒด param์˜ ์†์„ฑ์œผ๋กœ ์ง€์ • ํ›„ ๋งค๊ฐœ๋ณ€์ˆ˜ value ๊ฐ’์„ ํ• ๋‹น
			
			if ( isColor ) {												// isColor๊ฐ€ true์ผ ๋•Œ( ์กด์žฌํ•  ๋•Œ )
				node = gui.addColor( param, name ).onChange( function() {	// ๊ฐ์ฒด param์˜ ๋‚ด๋ถ€ ์†์„ฑ name ๊ฐ’์„ ํ‘œ์‹œํ•  gui.addColor ํ•จ์ˆ˜ ์‹คํ–‰
					callback( param[ name ] );								// onChange ์‹œ ( param[ name ] )์„ ๋งค๊ฐœ๋ณ€์ˆ˜๋กœ ๋“ค์–ด์˜ค๋Š” ์ฝœ๋ฐฑํ•จ์ˆ˜ ์‹คํ–‰
				} );
			} else if ( typeof value == 'object' ) {						// ๋งค๊ฐœ๋ณ€์ˆ˜ value๊ฐ€ [ ๊ฐ์ฒด ]์ผ ๋–„
				node = gui.add( param, name, value ).onChange( function() {	// ๊ฐ์ฒด param์˜ ๋‚ด๋ถ€ ์†์„ฑ name ๊ฐ’์„ ์…€๋ ‰ํŠธ๋ฐ•์Šค๋กœ ํ‘œ์‹œํ•  gui.add ํ•จ์ˆ˜ ์‹คํ–‰
					callback( param[ name ] );								// onChange - ์ฝœ๋ฐฑํ•จ์ˆ˜
				} );
			} else {
				node = gui.add( param, name, min, max ).onChange( function() {	// ๊ทธ์™ธ ๊ฒฝ์šฐ ๊ฐ์ฒด, ์†์„ฑ, ์ตœ์†Œ, ์ตœ๋Œ€๊ฐ’์„ ๋งค๊ฐœ๋ณ€์ˆ˜๋กœ gui.add ํ•จ์ˆ˜ ์‹คํ–‰
					callback( param[ name ] );									// onChange - ์ฝœ๋ฐฑํ•จ์ˆ˜
				} );
			}
			return node;	// ํ•จ์ˆ˜ ์‹คํ–‰
		}
		
		clearGui();	// ์‚ญ์ œ

	// ํ•ด๋‹น postprocess๋ฅผ ์œ„ํ•œ ๋ณ€์ˆ˜๋“ค
		var screen = new THREE.ScreenNode();
		var hue = new THREE.FloatNode();
		var sataturation = new THREE.FloatNode( 1 );
		var vibrance = new THREE.FloatNode();
		var brightness = new THREE.FloatNode( 0 );
		var contrast = new THREE.FloatNode( 1 );
		var hueNode = new THREE.ColorAdjustmentNode( screen, hue, THREE.ColorAdjustmentNode.HUE );
		var satNode = new THREE.ColorAdjustmentNode( hueNode, sataturation, THREE.ColorAdjustmentNode.SATURATION );
		var vibranceNode = new THREE.ColorAdjustmentNode( satNode, vibrance, THREE.ColorAdjustmentNode.VIBRANCE );
		var brightnessNode = new THREE.ColorAdjustmentNode( vibranceNode, brightness, THREE.ColorAdjustmentNode.BRIGHTNESS );
		var contrastNode = new THREE.ColorAdjustmentNode( brightnessNode, contrast, THREE.ColorAdjustmentNode.CONTRAST );
		
		nodepass.value = contrastNode;
		
	// GUI
		addGui( 'saturation', sataturation.number, function( val ) {
			sataturation.number = val;
		}, false, 0, 2 );
		
		addGui( 'vibrance', vibrance.number, function( val ) {
			vibrance.number = val;
		}, false, - 1, 1 ).step(0.1);	// step ์†Œ์ˆ˜๋‹จ์œ„ ์ ์šฉ
		
		addGui( 'contrast', contrast.number, function( val ) {
			contrast.number = val;
		}, false, 0, 2 );
	
		nodepass.build();

		
		function init() {
		
			renderer = new THREE.WebGLRenderer({alpha: true, antialias: true});						//
			renderer.setPixelRatio( window.devicePixelRatio );			// 
			renderer.setSize( window.innerWidth, window.innerHeight );	// 
		//	renderer.setClearColor( 0xffffff, 1 )
			document.body.appendChild( renderer.domElement );			// dom์— ์ถ”๊ฐ€
			//
			camera = new THREE.PerspectiveCamera( 45, window.innerWidth / window.innerHeight, 1, 10000 );	// ์นด๋ฉ”๋ผ
			camera.position.z = 400;																	//
			scene = new THREE.Scene();																		// object
			controls = new THREE.OrbitControls( camera, renderer.domElement );
				var loader = new THREE.JSONLoader();
				loader.load( /*'js/object/big_3d_1000.js'*/'js/object/300.js', function( geometry ) {
					geometry.computeVertexNormals();
					var texture = THREE.ImageUtils.loadTexture( 'textures/jung_512.jpg' );
					var material = new THREE.MeshStandardMaterial( {
						map : texture
					});
					  
					texture.anisotropy = renderer.getMaxAnisotropy();
					 
					mesh = new THREE.Mesh( geometry, material );	
					scene.add( mesh );

				});

			
			scene.add( new THREE.AmbientLight( 0xffffff,2 ) );			// AmbientLight
			composer = new THREE.EffectComposer( renderer );			// composer
			composer.addPass( new THREE.RenderPass( scene, camera ) );	//
				
			nodepass = new THREE.NodePass();
			nodepass.renderToScreen = false;//false;//true;
			composer.addPass( nodepass );
			
			SMAA_effect = new THREE.SMAAPass( window.innerWidth, window.innerHeight );
			SMAA_effect.renderToScreen = true;
			composer.addPass( SMAA_effect );
			//
			
			window.addEventListener( 'resize', onWindowResize, false );
		}
		
		function onWindowResize() {
			camera.aspect = window.innerWidth / window.innerHeight;
			camera.updateProjectionMatrix();
			renderer.setSize( window.innerWidth, window.innerHeight );
			composer.setSize( window.innerWidth, window.innerHeight );
			
			//smaa
			var pixelRatio = renderer.getPixelRatio();
			var newWidth = Math.floor(  window.innerWidth / pixelRatio ) || 1;
			var newHeight = Math.floor(  window.innerHeight / pixelRatio ) || 1;
			composer.setSize( newWidth, newHeight );
		}
		
		function animate() {
			requestAnimationFrame( animate );
			var delta = clock.getDelta();
			nodepass.node.updateFrame( delta );
			renderer.render(scene,camera)
		//	composer.render();
			
		}