godotengine / godot-proposals

Godot Improvement Proposals (GIPs)
MIT License
1.11k stars 69 forks source link

Unify Tangent Space Generation Across Godot 3d Pipeline #8601

Closed fire closed 8 months ago

fire commented 9 months ago

Describe the project you are working on

This proposal is relevant to all Godot projects that involve 3D asset loading and exporting, especially those with a significant number of imported models. The unification of tangent space generation will broadly impact the engine's efficiency and user experience.

Describe the problem or limitation you are having in your project

Reported by Reduz. Tangent space generation (including the generation of normals and tangents) is redundantly implemented in many Godot asset loaders. This redundancy is causing loaders to be slower and more complex than necessary, affecting projects depending on which loader is used.

Describe the feature / enhancement and how it helps to overcome the problem or limitation

The enhancement unifies the tangent space generation across all asset loaders in Godot. By moving the generation of normals and tangent spaces to a common code, we can reduce avoid error, complexity and improve the speed of the individual asset loaders.

Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams

  1. Modify each asset loader to load arrays as-is, without performing tangent space optimization.

  2. Move tangent space generation in the scene loader, which processes the raw data from asset loaders. Edited: Could be via the surface tool for exposure to the game developers.

If this enhancement will not be used often, can it be worked around with a few lines of script?

This is an enhancement that cannot be replicated with a script workaround due to its integration with the asset loading pipeline. It's a change that will benefit projects using 3D assets.

Is there a reason why this should be core and not an add-on in the asset library?

This enhancement addresses a core functionality of the Godot engine - the loading and processing of 3D assets. Its implementation will improve the efficiency of the engine's asset loading pipeline, making it a core enhancement rather than an optional add-on.

### Tasks
- [ ] Switch the obj importer to use SurfaceTool::generate_tangents(). Migrate the code from the MikkSpace patch that is stuck.
fire commented 8 months ago

Discussed with Reduz how the interface should be to add tangent generation to ImporterMesh, without touching CSG, SurfaceTool, etc.

fire commented 8 months ago

Superseded by https://github.com/godotengine/godot-proposals/issues/8696