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

WebGLPathTracer: Automatically position model to avoid numeric precision problems #678

Open
Drosaca opened this issue Nov 14, 2024 · 5 comments
Labels
enhancement New feature or request
Milestone

Comments

@Drosaca
Copy link

Drosaca commented Nov 14, 2024

Describe the bug
I loaded a 3D model and applied OrbitControls to it. The path tracing work fine when the model is at the origin (0,0,0). However, after repositioning the model far from the origin and moving the camera to the new position, the path tracing is rendered on a low-quality texture, while the default renderer displays the correct texture.

chrome_raUJgxWO8g (1)

Expected behavior
expected this at position ("x": -3761603.743620786, "y": 4105279.00727716, "z": 3870314.8490743843) and not only at (0,0,0)

chrome_HIKeW216JU

Repro Model
can't upload: "We don’t support that file type."
can be downloaded from here:
https://mega.nz/file/faxFkAjI#kYYd7T3MVEgmjj6cC1PhPiqNpT2yaYaOaATuFIlTatc
original source:
https://sketchfab.com/3d-models/starlink-spacex-satellite-0a60f6720c5141c9a1c6d71aac108b31

  • Device: Desktop,
  • OS: Windows,
  • GPU: NVidia
  • Browser: Chrome,
  • Browser Version: [130.0.6723.119]
  • Three.js version: [r169] //using react wrapper @react-three/fiber[^8.17.9]
  • Library version: [^0.0.23] //using react wrapper @react-three/gpu-pathtracer[^0.2.0]
@AntonPalmqvist
Copy link
Contributor

Try increasing the textureSize parameter: https://github.com/gkjohnson/three-gpu-pathtracer?tab=readme-ov-file#texturesize

@gkjohnson
Copy link
Owner

When submitting an issue please follow the template and submit the information that's requested - you haven't provided enough information to say exactly what the issue is.

My guess is that this is related to floating point precision at large numbers away from zero (though you haven't said how far). This is something that's not currently handled internally so assuming that's what the issue is you'll have to adjust the model position and camera to be near zero.

@Drosaca
Copy link
Author

Drosaca commented Nov 14, 2024

When submitting an issue please follow the template and submit the information that's requested - you haven't provided enough information to say exactly what the issue is.

My guess is that this is related to floating point precision at large numbers away from zero (though you haven't said how far). This is something that's not currently handled internally so assuming that's what the issue is you'll have to adjust the model position and camera to be near zero.

Ok I updated the issue, the far away value is "x": -3761603.743620786, "y": 4105279.00727716, "z": 3870314.8490743843. it looks like a low poly version of my object when it's far but only with the path traced version.

@Drosaca
Copy link
Author

Drosaca commented Nov 15, 2024

Try increasing the textureSize parameter: https://github.com/gkjohnson/three-gpu-pathtracer?tab=readme-ov-file#texturesize

I tried with 4096 but it doesn't change anything :(

@gkjohnson
Copy link
Owner

Ok I updated the issue, the far away value is "x": -3761603.743620786, "y": 4105279.00727716, "z": 3870314.8490743843. it looks like a low poly version of my object when it's far but only with the path traced version.

Yes these numbers are very large and will likely cause numeric precision issues when rendering. I recommend moving the camera and model closer to the origin to address the issue. This could probably be fixed automatically by the renderer but it would need to be implemented.

I tried with 4096 but it doesn't change anything :(

Yeah this won't help in this case, unfortunately, since it's a numeric problem.

@gkjohnson gkjohnson added the enhancement New feature or request label Nov 17, 2024
@gkjohnson gkjohnson added this to the v0.0.24 milestone Nov 17, 2024
@gkjohnson gkjohnson changed the title Path tracing renders on Low quality texture WebGLPathTracer: Automatically position model to avoid numeric precision problems Nov 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants