atteneder / glTFast

Efficient glTF 3D import / export package for Unity
Other
1.21k stars 243 forks source link

Question BIM and GLTF for mobile #175

Closed NeluQi closed 2 years ago

NeluQi commented 3 years ago

Hello everyone. Thanks for the great tool, I hope it will continue to evolve.

I use it with BIM models (Autodesk models, autocad, etc.). Models are loaded in real time. Models are prepared from ifc (ifc to gtlf). The model is split into many GLTF files (I try to make files up to 200 mb, but in some cases there may be one large gltf file> 1 gb) My models can be really large and with a lot of objects (> 6,000,000 objects). Also, objects can be located in large coordinates from zero. Many objects can have similar mesh meshes. (Is there a way to do Geometry Instancing?)

Above I described what I use the tool for. I would like to see the development towards optimization for large models for mobile devices (Mobile shaders/Perhaps special shaders for BIM, working with RAM, etc.) (The most important problem now is a crash due to lack of RAM)

Can you give me advice on how to use and optimize for my tasks (preferably with examples): 1) Lack of RAM with a large model. When I destroy a chunk of the model, the memory is not released. How to properly load and free memory with a large number of files? (In general, if you know optimization methods, please write down) 2) The problem with large coordinates. Geometry starts to display incorrectly 3) Are there any tools for optimizing / compressing GLTF?

Thank you

NeluQi commented 3 years ago

Forgot to add, I'm developing for mobile devices (Unity: android)

NeluQi commented 3 years ago

And what version of Unity would you recommend to use for maximum compatibility?

atteneder commented 3 years ago

Hi @NeluQi ,

Hello everyone. Thanks for the great tool, I hope it will continue to evolve.

Thanks for you interest!

I use it with BIM models (Autodesk models, autocad, etc.). Models are loaded in real time. Models are prepared from ifc (ifc to gtlf). The model is split into many GLTF files (I try to make files up to 200 mb, but in some cases there may be one large gltf file> 1 gb) My models can be really large and with a lot of objects (> 6,000,000 objects). Also, objects can be located in large coordinates from zero.

Sounds like a great challenge :) The largest file I tested so far was a single mesh 2GB (75 mio triangles) file.

Many objects can have similar mesh meshes. (Is there a way to do Geometry Instancing?)

There's an extension called EXT_mesh_gpu_instancing. Support for it was implemented just this week and will be released soon.

Above I described what I use the tool for. I would like to see the development towards optimization for large models for mobile devices (Mobile shaders/Perhaps special shaders for BIM, working with RAM, etc.) (The most important problem now is a crash due to lack of RAM)

There's been demand for providing a memory limit before. But even with that in place your use-case is challenging and this might only replace the crash with a regular out-of-memory error. Optimizing for memory usage is definitely something to keep an eye on. Best way to do it is to profile the memory with the actual data you're loading. Feel free to provide it.

Can you give me advice on how to use and optimize for my tasks (preferably with examples):

1. Lack of RAM with a large model. When I destroy a chunk of the model, the memory is not released. How to properly load and free memory with a large number of files? (In general, if you know optimization methods, please write down)

You can avoid overlapping peak memory usage by loading files sequentially instead of simultaneously (at the cost of loading speed).

An improvement idea that comes to mind is it should be possible to dispose the GltFast (GltfImporter) instance (but not the instantiation) to free up some more memory. I created an issue. Thanks for the input!

2. The problem with large coordinates. Geometry starts to display incorrectly

Which value range are we talking about? We should find out where the required precision is lost (where is the bottleneck). It might be your glTF exporter. If it's Unity's 32-bit float scene transform system then I could ask around. I know projects that require 64-bit float positions so I might ask them how they solved this one. In generel, I think this would require some work beyond glTF(ast)

3. Are there any tools for optimizing / compressing GLTF?

I'd recommend using Draco mesh compression and KTX/basisu format for textures. Draco reduces the transmission size and KTX textures require up to 8x less memory than Jpeg/PNG.

Tools I've used and recommend:

atteneder commented 3 years ago

And what version of Unity would you recommend to use for maximum compatibility?

Currently glTFast should be backwards compatible back to 2019.3. For sure it works on 2019.4 LTS (mainly developing on that version) and tested on 2020.3 LTS and 2021.1 as well.

Regarding render pipelines: BuiltIn, URP and HDRP should all work fine. At some point URP and HDRP will get better support or more features.

NeluQi commented 3 years ago

Thank you so much! You have painted everything in great detail, thank you!

NeluQi commented 3 years ago

I will add about large coordinates. In my projects, the accuracy is very high. As I understand it, Unity works with float. And models are made where double is used (for displaying on a desktop PC, the "Unigine" engine is used). Here is an example of coordinates Vector3 (-20078.8867,264630.313, -176.036148) (They are taken from the Unity, and most likely they are cut off during conversion) image

Below are screenshots of an example of coordinates that may be in my models image

image

Also here: "position": { "x": 1381269.5903851246, "y": 503956.1176144961, "z": 30.483931298636037 }, "viewpoint": { "position": { "x": 1381205.1878217508, "y": 503930.97944847617, "z": 46.113223450692196 }, "rotation": { "x": 0.7429931163787842, "y": 0.47703057527542114, "z": -0.4694710969924927 },

This precision is used in my projects.

Can you tell me what is the best way to achieve the maximum optimal transition of such coordinates in Unity (I already shift the model by 0 coordinates when unloading it to GTLF)

I would be grateful if you ask how they solved the problem with large coordinates

thanks!

NeluQi commented 3 years ago

And one more thing. I am using Unity version 2020.3.8f1 (LTS). I actively use glTFast, I have not noticed any problems.

This is for informational purposes only.

atteneder commented 3 years ago

Yeah, the 32bit float transforms are a Unity limitation....I'll ask around if there are ways around it, but I don't think it's as easy as flipping a switch.

Note: The transform inspector rounds the positions' fraction to 4 digits. It might preserve more precision internally.

NeluQi commented 3 years ago

Is there any progress?

atteneder commented 3 years ago

Is there any progress?

Regarding double precision transforms...unfortunately not. Expect an update on this later this year.

If you absolutely need a solution earlier, you could create a system of your own, that converts transform per-frame to minimize (clip space) precision loss, but that's probably some work.

glTFast then would have to pass on transformation data in double precision as well. I'd be willing to write this patch as soon as we know how this system will work.

atteneder commented 2 years ago

Closing in favor of #290