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.
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();
}