Hello guys,
Actually trying to implement SSR ( https://codesandbox.io/p/sandbox/8pbw1f ) on my project.
To be clear I use two camera to renderTarget, at the end i retrieve the two textures from the renderTargets, pass them to a shader on a place, and do some cool transition between scenes like that.
// here my render targets
const renderTarget0 = useFBO(
viewport.width * (isTouchDevice() ? touchDeviceDPR : noneTouchDeviceDPR),
viewport.height * (isTouchDevice() ? touchDeviceDPR : noneTouchDeviceDPR),
{
stencilBuffer: false,
alpha: true,
samples: 2,
},
);
const renderTarget1 = useFBO(
viewport.width * (isTouchDevice() ? touchDeviceDPR : noneTouchDeviceDPR),
viewport.height * (isTouchDevice() ? touchDeviceDPR : noneTouchDeviceDPR),
{
stencilBuffer: false,
alpha: false,
samples: 2,
},
);
useFrame(({ gl, scene, camera }, delta) => {
gl.autoClear = true;
if (renderScene0.current.render) {
// here i hide/show what I need for this "scene"
gl.setRenderTarget(renderTarget0);
gl.render(scene, firstCameraRef.current);
}
if (renderScene1.current.render) {
// here i hide/show what I need for this "scene"
gl.setRenderTarget(renderTarget1);
gl.render(scene, secondCameraRef.current);
}
finalDisplayRef.current.visible = true;
gl.setRenderTarget(null);
gl.autoClear = false;
});
return(
<>
// Here my plane with my two texture passed to a my "final screen" facing my main camera, an <OrthoCamera... />
<mesh
position={[0, 0, 0]}
scale={[viewport.width, viewport.height, 1]}
ref={finalDisplayRef}
>
<planeGeometry />
<GradientFbmMaterial
color={"white"}
uTex0={renderTarget0.texture}
uTex1={renderTarget1.texture}
uResolution={
new THREE.Vector2(
viewport.width *
(isTouchDevice() ? touchDeviceDPR : noneTouchDeviceDPR),
viewport.height *
(isTouchDevice() ? touchDeviceDPR : noneTouchDeviceDPR),
)
}
/>
</mesh>
// Here test to use the SSR - test with and without renderPriority > 0 - nothing works
<EffectComposer disableNormalPass renderPriority={1}>
<SSR {...props} />
</EffectComposer>
</>
)
That’s what I got actually:
I guess I am doing something wrong … but what ?
Thanks!