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

Support 64bit float in PLY loader #23006

Closed
christianbrugger opened this issue Dec 12, 2021 · 6 comments
Closed

Support 64bit float in PLY loader #23006

christianbrugger opened this issue Dec 12, 2021 · 6 comments
Labels

Comments

@christianbrugger
Copy link

christianbrugger commented Dec 12, 2021

Is your feature request related to a problem? Please describe.

In our projects points are very large and we need 64 bit float precision to properly display them.

When using the PLY loader the files are correctly parse, however at the end the arrays are converted to Float32BufferAttribute.

This makes the data unusable.

Describe the solution you'd like

Make the PLY loader use Float64BufferAttribute in the postProcess function (Source)

Describe alternatives you've considered

Create an option to output the data as 32 bit or 64 bit buffers.

Additional context

I changed locally the attribute and the class works still perfectly.

@Mugen87
Copy link
Collaborator

Mugen87 commented Dec 12, 2021

we need 64 bit float precision to properly display them.

You can't render double precision floating point with WebGL. I'm not sure why there is a Float64BufferAttribute class. The renderer can't process it.

@christianbrugger
Copy link
Author

christianbrugger commented Dec 13, 2021

We are using Potree to render the imported PLY. It uses three.js as a backend and gives us access to the scene object. When I add the imported PLY mesh to that scene it gets properly rendered.

I don't know how they adapted the pipeline to accommodate for that, but it seems to work with the Float64BufferAttribute. If needed I could find out a bit more, or does this make sense to you?

@Mugen87
Copy link
Collaborator

Mugen87 commented Dec 13, 2021

The following live example shows that double precision floating point can't be processed: https://jsfiddle.net/naLj3uzp/1/

I'm not sure what potree does but it surely does not pass a float64array to WebGL.

@mrdoob
Copy link
Owner

mrdoob commented Dec 13, 2021

@m-schuetz any pointers at how we should handle this?

@m-schuetz
Copy link
Contributor

m-schuetz commented Dec 14, 2021

Models with large coordinates are typically handled as follows in Potree:

  • Compute the minimum position
  • Subtract the minimum from all positions. Afterwards, the position buffer can be turned into a Float32Array
  • Use the minimum as the position of the SceneNode, so that the vertices get moved back to where they are supposed to be.

For this to work, the worldView matrix must be computed on javascript side in double precision. The huge coordinates of the world matrix and the reversely huge components of the view matrix will cancel each other out, and the resulting worldView matrix can then be cast to a Float32Array and used in a shader.

I can't remember if I did anything to the PlyLoader to make it work in Potree. Do you have an example available, @christianbrugger ?

Edit:
Instead of computing the minimum position, it's probably cheaper and sufficient to shift by the first vertex of the model, then set it as the SceneNode position.

@Mugen87
Copy link
Collaborator

Mugen87 commented Dec 17, 2021

@christianbrugger Sorry, but this issue needs to be solved on application level e.g. with a custom enhancement for PLYLoader. Loaders in general return vertex position data as FP32 which is sufficient for most use cases. Besides, we can't work with a higher precision on the GPU anyway.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants