Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GPUComputationRenderer: update to work correctly with webXR #24554

Merged
merged 3 commits into from
Aug 30, 2022

Conversation

pigloo
Copy link
Contributor

@pigloo pigloo commented Aug 29, 2022

GPUComputationRenderer will act strangely when viewing in WebXR mode when the viewer looks away from the mesh bounding box. In my example particle positons are reset when looking away.

This PR fixes the issue using the same method seen in CubeCamera.js by disabling webXR before rendering to the rendertarget and then re-enabling webXR:

renderer.xr.enabled = false;

Cubecamera.js also disabling tonemapping while rendering to the rendertarget so that functionality has been added here too.

Here is an example using the updated GPUComputationRenderer code: https://codesandbox.io/s/gpgpu-dust-devil-webxr-4zmvc?file=/src/index.js

@Mugen87
Copy link
Collaborator

Mugen87 commented Aug 29, 2022

The section should probably look similar to what Reflector does:

renderer.xr.enabled = false; // Avoid camera modification
renderer.shadowMap.autoUpdate = false; // Avoid re-computing shadows
renderer.outputEncoding = LinearEncoding;
renderer.toneMapping = NoToneMapping;

@pigloo pigloo closed this Aug 29, 2022
@pigloo pigloo reopened this Aug 29, 2022
@pigloo
Copy link
Contributor Author

pigloo commented Aug 29, 2022

The section should probably look similar to what Reflector does:

renderer.xr.enabled = false; // Avoid camera modification
renderer.shadowMap.autoUpdate = false; // Avoid re-computing shadows
renderer.outputEncoding = LinearEncoding;
renderer.toneMapping = NoToneMapping;

Updated with changes from this suggestion and tested in the codesandbox example from the first comment.

@pigloo pigloo changed the title update to work correctly tone mapping and webXR GPUComputationRenderer: update to work correctly with webXR Aug 29, 2022
@mrdoob mrdoob added this to the r144 milestone Aug 30, 2022
@mrdoob mrdoob merged commit aacc489 into mrdoob:dev Aug 30, 2022
@mrdoob
Copy link
Owner

mrdoob commented Aug 30, 2022

Thanks!

@mrdoob
Copy link
Owner

mrdoob commented Aug 30, 2022

@pigloo Would you like to also contribute the example? Maybe as webxr_vr_gpgpu.html?

@pigloo
Copy link
Contributor Author

pigloo commented Aug 30, 2022

Yeah that would be awesome, how should I go about doing that?

@mrdoob
Copy link
Owner

mrdoob commented Aug 30, 2022

Here you go:

  1. Add the files in the examples folder
  2. Update files.json
  3. Run npm run make-screenshot webxr_vr_gpgpu
  4. Create a PR with all the changes

abernier pushed a commit to abernier/three.js that referenced this pull request Sep 16, 2022
…4554)

* update to work correctly tone mapping and webXR

* adding semicolons

* disable shadow and outputEncoding during render
snagy pushed a commit to snagy/three.js-1 that referenced this pull request Sep 21, 2022
…4554)

* update to work correctly tone mapping and webXR

* adding semicolons

* disable shadow and outputEncoding during render
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants