-
-
Notifications
You must be signed in to change notification settings - Fork 19.6k
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
Respect texture filtering when importing GLTF #59481
Respect texture filtering when importing GLTF #59481
Conversation
69ee064
to
37b31f5
Compare
As a sidenote that perhaps someone more experienced with C++/Godot could help me with: I would liked to have kept the filter mode enum as an enum class, for a little bit of enhanced type safety (as TheTophatDemon originally had it), but when declaring it as I was ultimately able to work around this by just using |
Approved cicd workflows. |
9167f46
to
a8d677a
Compare
Another side-comment: doctool doesn't seem to mind that I've added a new class ( |
a8d677a
to
84115df
Compare
Approved the cicd run. Also note that there is a policy towards squashing prs. There's a pr guide. https://docs.godotengine.org/en/stable/community/contributing/pr_workflow.html |
Can you be more specific about what you would like squashed? Do you want it all compacted down into a single commit? I noted that the guide mentions "we favor commits that bring the codebase from one functional state to another functional state". I tried to make sure that each commit in this PR reflects a functional state (although there is obviously a progression of increasing functionality), but if you'd rather see it mashed into a single commit, I can do that. |
Was busy. I'll review as soon as I can. Yes. Squash into one commit. You can backup if you want to another branch. |
84115df
to
3a2ca49
Compare
Squashed as requested. |
I will be using https://github.com/KhronosGroup/glTF-Sample-Models/tree/master/2.0/TextureSettingsTest to check. Edited wrong one. Reviewing the pr and comparing against some of the test cases. https://www.khronos.org/registry/glTF/specs/2.0/glTF-2.0.html#reference-texture Poked the khronos community why there's no feature test for image modes and filtering. |
I have to admit that I don't think I tested or paid close attention to the wrapping modes when I did this. My usecase was for min/mag filters, so that's what I was looking at. The wrap modes are serialized/deserialized, but at a glance I can't see them actually being applied to the materials anywhere. In fact, as I look at things, I am suddenly filled with uncertainty about whether wrap/mirror is a Material property at all, or instead a property of the underlying Texture. |
I think we should do the filtering modes and punt the wrap mirror modes. |
Okay. Should I remove the logic for serializing/deserializing the wrap modes, or leave it in place, just in case someone gets ambitious in the future and wants to make those modes actually work? |
3a2ca49
to
4ba6d55
Compare
I'll spend some time reviewing today. Can you rebase? |
I think we should not speculatively add the logic for serialize or deserializing code since we have a policy in other area that comment out code should be deleted. This is not the same, but the idea is the code should not be speculative. |
4ba6d55
to
1c626a8
Compare
@fire @LunaticInAHat I'm looking forward to this for 3.x. Is there any way I can help make this possible? |
This appears salvaging. |
This would certainly be an important feature for 3.x |
If remember correctly, this pr is blocked because of the Godot Engine 4 renderer. It's unclear how to store a data model of something that cannot be rendered in GodotEngine.
@clayjohn Can you provide background on these rendering details? |
21e3c11
to
3a53bab
Compare
Thanks for the suggestions on making CI pass, and for the explanation for the delayed review :) As Fire points out, there is a certain amount of impedance-mismatch between the way that GLTF stores texture samplers, versus how the Godot renderer would like to apply them. I believe that this PR fixes the most common usecase, where users just want nearest filtering on their models (with either wrap+wrap or clamp+clamp), however it can't support all the combinations supported by GLTF. A couple examples of things that won't work are:
If I recall correctly, some of those properties used to be per-texture (per-image) in 3.x, so I have assumed that making them global to the material was an intentional choice in 4.x, and that there wouldn't be any interest in changing the material system / renderer to accommodate them. |
I don't know how often normal maps require different flags than albedo maps. In our use case we require:
Is it feasible to implement toggleable parameters in the import tab? |
@LunaticInAHat Looking at the code I notice the mention of mipmaps but not ansiotropic. As far as I can tell the import process applies default properties. Edit: I'm taking look at 4.0 to understand it better and will update my comment if there are no new replies. |
For now I would stick within the limits of what is exposed via StandardMaterial/BaseMaterial. |
3a53bab
to
cdecc93
Compare
Yeah, I don't have any intention of expanding this PR to embrace anything beyond what the standard material classes expose. It is unfortunate that the materials don't support all the various sampler combinations that might be exported from art tools, but I don't think this PR should be blocked by that. As far as anisotropy goes, as far as I can tell, GLTF does not store any information relating to anisotropic filtering (thus it cannot be imported from the GLTF). So, adjusting that will have to be a manual operation performed on the materials in Godot, after import. It's not 100% clear to me why some of the CI builds are failing, at this point. I think I've solved the issue relating to missing documentation in my latest version of the PR, but the error in "Build godot-cpp test extension" is somewhat opaque to me. |
If you're able to help out, I wanted to do image comparison before and after using this list of models. https://github.khronos.org/glTF-Asset-Generator/Output/Positive/Texture_Sampler/ I'm busy until the weekend, hope someone can help. Then, I can approve. |
@LunaticInAHat |
@fire I'm not sure how to use that asset generator but I confirmed it respects closest/nearest sampling on the Windows build. |
I already have a 3.x branch prepared, so once this PR gets merged, I'll open the PR for the 3.x backport. Then it should just be a question of testing, and re-review. The 3.x implementation is somewhat different from the 4.x implementation, due to larger changes in how materials & textures work, so testing results from one branch don't necessarily translate to the other. As far as the image comparison requested by @fire goes, I just want to point out that we expect to fail tests 01 - 04, because they are using wrap modes where S != T. |
@fire Do you want me to import those models into Godot and screenshot the material in the inspector? |
Yeah! and if you wish, can save the project and publish it so I can add it as a pr to godot-tests |
@fire The assets seems to be broken. 😕 |
I think this is a good enough case for a separate bugfix. uhhh i think we have to add a fake gltf root. But you seem confident |
cdecc93
to
62819ca
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code changes look good now. Once the docs are filled in this should be ready to merge!
62819ca
to
f9ff48d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CI is failing due to missing indentation. I have made code suggestions to make CI pass and finish filling out the docs.
f9ff48d
to
c1a6005
Compare
Thanks for sticking with this one! |
This PR updates the GLTF importer, such that imported materials have the correct texture filter modes set (with respect to the sampling specified in the imported file).
This PR builds on work that was started in PR #54044, and forward-ports it to 4.x. The delta between making this work in 4.x vs 3.x is fairly significant, so also have a 3.x branch available for after a fix gets merged to master (that 3.x branch is based on what @TheTophatDemon started, with some small corrections that make it work properly on the GLTF files they were having trouble importing)
Bugsquad edit: This closes #61232.