Implemented model material/texture import and reuse on model/scene load#667
Implemented model material/texture import and reuse on model/scene load#667Gopmyc wants to merge 23 commits intoOverload-Technologies:mainfrom
Conversation
adriengivry
left a comment
There was a problem hiding this comment.
Thanks for submitting this PR!
I can see a few major issues with this work:
-
Assimp is being used directly in
OvEditor. Implementation details related to model loading should remain hidden from the application behind theIModelParserinterface. Additional model data (i.e., material and texture information) should be fully handled by theAssimpParser. -
Project file pollution. This PR assumes that the user wants to place automatically generated materials and textures in
Materials/{model_name}/andModels/{model_name}/, respectively. -
Imported materials and models collision. In some cases, if the user has multiple models with the same name in different folders, only the first imported model will properly generate materials and textures.
Ultimately, my vision for this feature is to offer something similar to what Unity does. I see models (FBX, OBJ, etc.) as “folders” that can be expanded to reveal all their embedded assets, including materials and potentially textures, if any.
These embedded assets would be non-modifiable, as they would be generated when the model is loaded. They could then be dragged and dropped anywhere a material or texture is required. Paths for embedded assets could look like:
path/to/model.fbx:embedded_material.ovmat
path/to/model.fbx:embedded_texture.jpeg
In the model asset properties, we could add a toggle (above the model parsing flags) to determine whether embedded materials and textures should be generated.
This would also require updating the PropagateFileRename implementation to properly handle embedded assets.
Once this is fully implemented, I believe the “Generate materials” option in the model contextual menu could be safely removed.
The final step would be to add support for externally linked textures. Some models reference textures using relative paths, and it would be beneficial to support these as well. Generated materials should be able to reference linked textures correctly.
Given the scope of this work, I understand if it’s not manageable for you at the moment. We’ve postponed this effort for many years because it’s fairly complex and has a lot of dependencies.
|
Challenge accepted |
|
Yep, this is a pretty massive change. Totally agree about breaking it down.
|
Great question. By “loading materials virtually through the parser”, I mean:
Then, “assigning them at runtime” means |
# Conflicts: # Sources/OvEditor/src/OvEditor/Core/EditorActions.cpp
There was a problem hiding this comment.
I didn't look too deep into the implementation that much yet, but I tested it locally, and here is my feedback:
Issues/bugs:
GENERATE_EMBEDDED_ASSETSdoesn't seem to work. Even when I set it to false the materials are still being loaded.- Embedded textures don't seem to work (e.g. with this ShaderBall.fbx, loading it into Blender or Unity, you'll see a grid pattern on the ball, but you won't in Overload)
- Reloading linked (external) textures doesn't apply changes, but reloading the model after modifying a linked texture does work. This means that linked textures are actually duplicated in GPU memory (loaded twice). You can reproduce that issue with Sponza FBX with linked textures. If you import all the assets into a project, and load the FBX, and then modify a texture and reload it (right click on the texture > reload), you'll notice that the texture isn't updated on the model. To reload it you would have to reload the model instead.
- Parallax mapping seem to be enabled even when no height map is used. This can be reproduced by loading Sponza FBX with linked textures and looking at textures from close, from an angle.
- We should also keep the "Generate Materials" for now, as it's still useful to change the appearance of a model. I know I mentioned we should remove it at some point, but I think it still serves a valid purpose for now.
Notes:
- Linked textures seem to work (e.g. Sponza FBX with linked textures, loading the FBX will properly find the textures using the relative path. Since you mentioned this, I thought this was gonna be in another PR, but I'm ok with external textures being supported in this PR as well:
Once that part is solid, we can move forward with separate PRs for embedded asset handling, optional generation, rename propagation, and support for external textures.
Overall this seem feature complete (once it will be fully fixed). I like the scope of the PR, which I would summarize as:
- Added support to load materials embedded into a model
- Added support to load textures embedded into a model and automatically attaching them to the correct embedded materials
- Added support to attach externally linked textures to embedded materials
Thanks for the detailed review, this was very helpful. I addressed each issue you listed:
I also re-validated with ShaderBall/Sponza-style cases, and the PR scope is now aligned with your summary:
|
adriengivry
left a comment
There was a problem hiding this comment.
Thanks for updating the PR! It looks really good, and seem to work in most cases!
One issue I found is with externally linked textures (e.g. Sponza FBX with linked textures) external textures are now properly being used (yay! 🎉) but parallax mapping still look like it's enabled even though no height map is provided.
Thanks for the feedback ! I just pushed a fix for this point, and it now seems corrected on my side : I adjusted the material extraction/runtime binding logic to avoid treating height/bump data as parallax input in this scenario.
|



Description
This PR implements automatic material/texture import and reuse for models, both when adding a model to the scene and when loading a
.ovscene.Main changes:
Assets/Materials/<ModelName>/Assets/Textures/<ModelName>/.ovscene).IMeshusage).Related Issue(s)
Fixes #303
Review Guidance
.fbx, etc.) into the scene:.ovscenecontaining models:Screenshots/GIFs
Checklist
I have commented my code, particularly in hard-to-understand areasI have updated the documentation accordingly