Not sure if this is a bug or just my naivety.
I upgraded from r97 to r102 today and my EffectComposer would clear prior render pass data.
I saw in the Migration notes that the renderer needs to be cleared before hand. Reverted back based on the xxdiff lines between new-old RenderPass.js files, and got my render passes comping correctly again. (So my fix in RenderPass.js IS working… but…) Am I doing something wrong?
What it looks like visually–
I’m rendering the main scene first then rendering the custom ShaderMaterial pass overtop the given main scene render–
How I’m setting up my composer-
mainMenuShader=new THREE.ShaderMaterial({
uniforms:{
"tDiffuse":{type:"t",value:0,texture:null},
"flicker":{type:"f",value:0},
"time":{type:"f",value:0},
"cropTop":{type:"f",value:.3},
"cropBottom":{type:"f",value:.5},
},
vertexShader:document.getElementById("anchoredObjectVert").textContent,
fragmentShader:document.getElementById("tempMainMenuFrag").textContent
});
mapTempMenuComposer = new THREE.EffectComposer(mapEngine);
mainMenuPass=new THREE.RenderPass(mapScene,mapCam);
mainMenuShaderPass=new THREE.ShaderPass(mainMenuShader);
mapTempMenuComposer.addPass(mainMenuPass);
mapTempMenuComposer.addPass(mainMenuShaderPass);
mainMenuShaderPass.renderToScreen=true;
Fragment shader-
<script type="x-shader/x-fragment" id="tempMainMenuFrag">
uniform sampler2D tDiffuse;
uniform float flicker;
uniform float time;
uniform float cropTop;
uniform float cropBottom;
varying vec2 vUv;
void main(){
vec4 Cd=vec4(0.158,0.11,0.0,1.0);
vec4 offset=vec4(flicker*0.009,flicker*0.005,0.0,1.0);
if(vUv.y<cropTop && vUv.y>cropBottom){
Cd=texture2D(tDiffuse, vUv);
}else{
float timer=time/1000.0;
float noise=((vUv.y+ sin(vUv.x*90000.0+vUv.y*26012.0)*.006*(.7+flicker*.5)+cos(vUv.x*40234.0+vUv.y*10000.0)*.006*(.7+flicker*.5))*1.2-.25);
if(vUv.y>=cropTop){
Cd*=(cropTop)/(noise*1.4);
}else if(vUv.y<=cropBottom){
Cd*=noise/cropBottom;
}
Cd*=sin(vUv.x*3.141592);
Cd+=offset;
}
gl_FragColor=Cd;
}
</script>
Checking the output of the tDiffuse alone reveals a black screen–
From threejs\examples\js\postprocessing\RenderPass.js
r101 - Line 51-
renderer.setRenderTarget( this.renderToScreen ? null : readBuffer );
if ( this.clear ) renderer.clear();
renderer.render( this.scene, this.camera );
From threejs\examples\js\postprocessing\RenderPass.js
r97 - Line 51-
renderer.render( this.scene, this.camera, this.renderToScreen ? null : readBuffer, this.clear );
I changed the 3 lines back to the original line and it’s rendering just fine again. But does that mean I’m setting my composer’s shader passes wrong?
Any help would be appreciated!! Thanks in advance!