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

[TRACKER] Automatic mesh LOD issues #57416

Open
11 of 27 tasks
Calinou opened this issue Jan 29, 2022 · 10 comments
Open
11 of 27 tasks

[TRACKER] Automatic mesh LOD issues #57416

Calinou opened this issue Jan 29, 2022 · 10 comments

Comments

@Calinou
Copy link
Member

Calinou commented Jan 29, 2022

This tracker is about issues related to automatic mesh LOD performed at import-time in 4.0. This feature is not present in 3.x.

See also #70533, which is another common optimization used in 3D rendering.

This tracker does not cover issues related to manual (H)LOD performed using visibility ranges.

Bugs

  1. bug confirmed documentation topic:3d topic:import topic:rendering
  2. bug confirmed topic:3d topic:import
  3. bug confirmed topic:3d topic:rendering
  4. bug topic:3d topic:import topic:rendering
  5. bug confirmed topic:3d topic:animation topic:import
  6. bug topic:3d topic:rendering
  7. bug topic:3d topic:import topic:rendering
  8. bug topic:import topic:rendering
  9. bug platform:web topic:3d topic:rendering
  10. documentation topic:3d topic:rendering
  11. bug topic:3d topic:animation topic:import
  12. bug topic:3d topic:import
  13. bug confirmed performance topic:3d topic:rendering
  14. bug topic:3d topic:rendering
  15. bug confirmed crash topic:3d topic:import
  16. bug confirmed topic:3d topic:rendering
  17. bug confirmed regression topic:3d topic:import topic:rendering
  18. bug topic:3d topic:import
  19. bug topic:3d topic:rendering
  20. bug topic:3d topic:rendering
  21. bug topic:3d topic:rendering
  22. bug topic:3d topic:rendering
  23. bug topic:3d topic:import topic:rendering

Enhancements

  1. topic:3d topic:editor topic:rendering
  2. topic:3d topic:core
  3. topic:3d topic:core
  4. confirmed discussion enhancement topic:3d topic:import
@fire

This comment was marked as resolved.

@TokisanGames
Copy link
Contributor

How do we generate lods and enable automatic use on already imported meshes? I have hundreds of assets already, stored in Godot's native resource format and saved in text scenes or as text resource files for git.

@Calinou
Copy link
Member Author

Calinou commented Jul 24, 2022

How do we generate lods and enable automatic use on already imported meshes? I have hundreds of assets already, stored in Godot's native resource format and saved in text scenes or as text resource files for git.

Automatic LOD generation on import is only supported when importing 3D scenes (glTF/Collada/FBX), not when loading pre-made .mesh/.res meshes or importing 3D meshes (OBJ). That said, you can choose to import OBJ as a 3D scene in the Import dock if you need LOD generation and lightmap UV2 unwrap for OBJ.

There's a generate_lods() method on some class I forgot the name of, but it's more limited and doesn't seem to be meant for public use.

@TokisanGames
Copy link
Contributor

Thanks for the answer, but you're not supporting core features on your own native format (arraymesh)? There are tons of projects right around the corner from migrating to gd4 that won't be able to use lod without manually reimporting a ton. Many of them have meshes stored in scene files as arraymeshes without realizing they are disconnected from their import file.

How do I know? Because the engine pushes you into the native format, because I've continually seen people on my team not realizing they are disconnecting resources from files which get saved in scene files, and because I've seen people do it on github issues.

They're all expecting autolod to just work and apparently it is not going to unless they first discover it's not working, troubleshoot it, write up an issue, then manually reimport every asset, then the setting up all of the auxiliary components again: physicsbodies, collision, materials, layers, parameters, etc.

There is an unusable surfacetool.generate_lod(), but it says Deprecated. Unused internally and neglects to preserve normals or UVs. There is an ImporterMesh.generate_lods(), and the class can output an arraymesh, but I see no way to pass in an arraymesh.

@fire
Copy link
Member

fire commented Jul 24, 2022

In the godot architecture, many procedures are ran on the raw scene before the final output. I was developing the gltf export code but it currently has a duplication nodes bug. I don’t have a good solution to rerunning the import process. Maybe marking as escn?

@fire
Copy link
Member

fire commented Jul 24, 2022

For clarity.

  1. Import this glb from https://github.com/KhronosGroup/glTF-Sample-Models/raw/master/2.0/Fox/glTF-Binary/Fox.glb
  2. Make local and save as a scn/tscn
  3. Go to the filesystem and rename to be .escn
  4. It will use the import dialog
  5. Noticed that lods are generated.

ESCN Game Project.zip

@TokisanGames
Copy link
Contributor

Thanks for the suggestion. I took one asset, a single MeshInstance, saved it as a tscn, renamed it to escn, brought it back into a scene and saw the import dialog and brought it in w/ Generate LODs. However, no LODs were generated. Moving the camera back and forth, watching w/ Information and Wireframe turned on in the viewport, the mesh and info did not change.

By the way, I probably have 1000 assets. Manually reimporting them one at a time is a very big ask. It's an unreasonable process considering:

  • LOD generation is already in the engine
  • The process above suggests a way to use LOD Generation on already imported assets is already or mostly implemented, so should continue towards full support
  • The native format (arraymesh) should be treated as a first class citizen for reasons given in my last comment above.

@fire
Copy link
Member

fire commented Jul 26, 2022

I would try to get escn to operate on mesh instances instead of the importer mesh instance. It's a bug.

The other proposals don't have any plumbing in place, so it would be some work

#63498

@TokisanGames
Copy link
Contributor

Thanks I'll follow the issue. If you want to get LOD generation to work on a meshinstance, rather than arraymesh, then workflow-wise, it would be reasonable to right-click the mesh instance and select Generate Lods. Or left-click the MeshInstance, click the Mesh menu, and Generate LODs. That should be the same as saving as escn and reopening, but would save developers a lot of clicks and manual work. Doing it once isn't a big deal, but it adds up if you have to do it hundreds of times.

@fire
Copy link
Member

fire commented Oct 13, 2023

Does anyone know which issue describe lod generation being slow?

Profiles suggest https://share.firefox.dev/3ZY1DSC that:

  1. SurfaceTool::generate_tangents takes 73% of the total runtime

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: No status
Development

No branches or pull requests

5 participants