-
Notifications
You must be signed in to change notification settings - Fork 323
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
Import: Factor texture node creation out into its own function #696
Import: Factor texture node creation out into its own function #696
Conversation
There was a reason, but I currently don't remember why. Will try to find the reason by testing it |
addons/io_scene_gltf2/blender/imp/gltf2_blender_material_utils.py
Outdated
Show resolved
Hide resolved
The code that creates the string of UV Map -> Mapping -> Tex Img nodes is now in one place. Removes many bugs and inconsistencies in the duplicated code, and nice code size reduction too. Also removes all the existing code for storing textureInfo stuff on texture or info objects, or setting the name of UV layers from the mesh classes (the name was always just TEXCOORD_n anyway). IOW, it only needs to look at the textureInfo object to create the needed nodes.
Hello @scurest
OK, I maybe remember why ... Material is created before the mesh. So UV is not existing yet when creating the material. Same way that a same material must be duplicated, dependant if vertex color is used or not, we should have to perform the same for UV (UV data / vertex color is on primitive side, and material is on material side). But this never has been implemented for UV, only for vertex color |
Why does that matter? |
So there's no problem right? |
Right, no problem when using API. |
@julienduroure How is this coming? |
Sorry, very busy weeks ... |
This adds a function
make_texture_block
that makes this string of three nodes given a TextureInfo objectThis should be way more maintainable than having it duplicated all over the place. There were lots of bugs because of inconsistent duplication that this should fix:
the metallic roughness mapping for TEXTURE_FACTOR didn't have the special case for Blender >= 2.81.8fixed in master by d11b687The
texCoord
field onKHR_texture_transform
was also ignored.All the stuff where a texture transform was stored on images was removed (it didn't really make sense anyway; what if the image was used twice with different transforms?). It can just be read from the TextureInfo object.
I also removed the stuff for setting the UV map after a mesh was created because all it did was set the UV map to
TEXCOORD_n
anyway. What was the point of theblender_texcoord
stuff? Did I need to keep it?Doing #687 will be trivial after this since only one place will need to be updated.