Dynamic textures (WebGLRenderTarget) stops updating when switching to VR

Hi,

I have a VR scene that uses textures that are dynamically created through WebGLRenderTarget. Everything works OK when working in normal mode, but when I switch to VR, the dynamic texture update does not seem to work anymore.

If I use renderer.autoClear = false when rendering into my dynamic texture, then VR scene uses the latest version of the texture (the last one that was updated in non-VR mode), but further updates are not applied.

If I use renderer.autoClear = true then dynamic texture turns black when switching to VR mode.

It almost looks like the texture is still being updates, but there is something wrong with temp scene/camera that I am using for rendering into dynamic texture.

Here is a minimum VS fiddle that demonstrates the problem:

The main scene contains a a cube, which uses a dynamic texture. On each frame, I update the texture with render of another rotating cube, that should be displayed on each face of the first cube.

I have also noticed that in non-VR mode oldTarget==null, while after switching to VR mode, oldTarget becomes non-null.

I was able to reproduce the problem with:

  • Oculus Quest 3
  • Immersive Web Emulator Chrome plugin

Any hints on a how to solve this problem?

Note that my real use case is more complex: I am using a dynamic texture as a cache atlas, when I store many different temporary textures that are dynamically created and then used on a main scene. Update rate is low - few new textures every few seconds.

Is this a similar problem? Would the solution there work for you?

1 Like

Thanks. Setting “renderer.xr.enabled = false” and restoring it seems to solve the issue (at least in emulator, I’ll test it with real VR device tomorrow)

Do you know if it has any performance consequences?

Thanks @PavelBoytchev. Turning temporary setting renderer.xr.enabled to falsewhile rendering into dynamic texture solved the problem - tested both in emulator and on actual device.

I’ve updated the fiddle to deonstrate the solution (set fixTheProblem to true)

1 Like