Closed zhudongwork closed 4 years ago
Possible duplicate of #15393
What browser/platform are you seeing this in? (WebXR and #15393 should be Chrome on Android only)
可能重复#15393
Is there some solution for this problem? This seems to be a little different from #15393 .
What browser/platform are you seeing this in? (WebXR and #15393 should be Chrome on Android only)
Chrome and Firefox
I misread before. The render target is getting stereoscopic rendering because VR is enabled, which synthesizes the stereo camera. Try disabling and re-enabling VR when rendering the buffer scene:
function render() {
renderer.setAnimationLoop( render );
renderer.vr.enabled = false;
renderer.render(bufferScene,camera,bufferTexture,true);
renderer.vr.enabled = true;
renderer.render( mainScene, camera );
}
I misread before. The render target is getting stereoscopic rendering because VR is enabled, which synthesizes the stereo camera. Try disabling and re-enabling VR when rendering the buffer scene:
function render() { renderer.setAnimationLoop( render ); renderer.vr.enabled = false; renderer.render(bufferScene,camera,bufferTexture,true); renderer.vr.enabled = true; renderer.render( mainScene, camera ); }
I tried it according to your suggestion and my problem was solved. But when I used this solution for my other problem, it didn't work. I am using three.js to achieve volume rendering, using the methods LEBARBA provides. The first scene is rendered into a texture using WebGLRenderTarget, and the world coordinate position is stored in the RGB channel of the texture. In contrast, RenderTargetTexture is the uniforms of ShaderMaterial. The specific description and code is here.
@zhudongwork
I tried it according to your suggestion and my problem was solved. But when I used this solution for my other problem, it didn't work.
Can you create a jsfiddle we can use to fix that other problem?
@zhudongwork
I tried it according to your suggestion and my problem was solved. But when I used this solution for my other problem, it didn't work.
Can you create a jsfiddle we can use to fix that other problem?
Thank you very much, my code is on the CodePen.
I misread before. The render target is getting stereoscopic rendering because VR is enabled, which synthesizes the stereo camera. Try disabling and re-enabling VR when rendering the buffer scene:
function render() { renderer.setAnimationLoop( render ); renderer.vr.enabled = false; renderer.render(bufferScene,camera,bufferTexture,true); renderer.vr.enabled = true; renderer.render( mainScene, camera ); }
I was initially thinking about whether WebGLRenderTarget caused this problem, so I tried to modify my code to make it a one-step ray casting, and I didn't need to use WebGLRenderTarget. However, when I entered the VR mode again, I still encountered the same problem. The distance between the scenes of the left and right eyes was wrong, and the image moved along with the head. So, I was wondering if this problem was caused by THREE.ShaderMaterial using a custom vertexShader and fragmentShader in the VR mode of THREE.js.My code is on the CodePen.
Is it a problem with the projectionMatrix and modelViewMatrix in the vertexShader when the value is passed in VR mode?
@zhudongwork any chance you can update your CodePen to use the latest version of the library?
Closing. The usage of WebGLRenderTarget
and WebXR is explained here: https://github.com/mrdoob/three.js/issues/18746#issuecomment-591441598.
@zhudongwork Feel free to reopen the issue if you can reproduce the problem with the latest API.
Description of the problem
I am trying to render a scene into another scene using WebGLRenderTarget in VR mode. I created two scenes -
mainScene
andbufferScene
. I draw a red cube inbufferScene
, then render thebufferScene
to the texturebufferTexture
using WebGLRenderTarget .bufferTexture
as the texture ofmainScene
. When I enter VR mode and turn the head to observe the entire scene,mainScene
is fine, but the cube inbufferScene
is rendered by split screen, and it will follow my head movement. Generally speaking, in the vr scene, the object should not follow the head movement. What caused this situation? I have put the code in codeopen.Three.js version
Browser
OS
Hardware Requirements (graphics card, VR Device, ...)