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

Import: Factor texture node creation out into its own function #696

Merged
merged 2 commits into from
Nov 13, 2019
Merged

Import: Factor texture node creation out into its own function #696

merged 2 commits into from
Nov 13, 2019

Conversation

scurest
Copy link
Contributor

@scurest scurest commented Sep 27, 2019

This adds a function make_texture_block that makes this string of three nodes given a TextureInfo object

texture-block

This 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:

  • metallic roughness images weren't checked if they were None, causing an exception if they were missing
  • the metallic roughness mapping for TEXTURE_FACTOR didn't have the special case for Blender >= 2.81.8 fixed in master by d11b687
  • specular/diffuse textures didn't have their label set
  • occlusion nodes didn't have their location set

The texCoord field on KHR_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 the blender_texcoord stuff? Did I need to keep it?

Doing #687 will be trivial after this since only one place will need to be updated.

@julienduroure
Copy link
Collaborator

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 the blender_texcoord stuff? Did I need to keep it?

There was a reason, but I currently don't remember why. Will try to find the reason by testing it

@julienduroure julienduroure added this to the Blender 2.82 milestone Oct 2, 2019
@julienduroure julienduroure added enhancement New feature or request importer This involves or affects the import process labels Oct 2, 2019
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.
@julienduroure
Copy link
Collaborator

Hello @scurest

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 the blender_texcoord stuff? Did I need to keep it?

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

@scurest
Copy link
Contributor Author

scurest commented Oct 29, 2019

Material is created before the mesh. So UV is not existing yet when creating the material.

Why does that matter?

@julienduroure
Copy link
Collaborator

Why does that matter?

In UI, you can't assign an UV if the active object doesn't have this UV. But seems you can do it with API, even if the node is in invalid state until the UV itself is created.
image

@scurest
Copy link
Contributor Author

scurest commented Oct 29, 2019

So there's no problem right?

@julienduroure
Copy link
Collaborator

Right, no problem when using API.
Didn't check when I first dev it, checked only with UI.

@scurest
Copy link
Contributor Author

scurest commented Nov 5, 2019

@julienduroure How is this coming?

@julienduroure
Copy link
Collaborator

Sorry, very busy weeks ...
LGTM at reading it, but I'd like to add some unit tests for all differents cases used for importing textures.

@julienduroure julienduroure merged commit e461f5c into KhronosGroup:master Nov 13, 2019
@scurest scurest deleted the refactor-texture-block branch November 14, 2019 08:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request importer This involves or affects the import process
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants