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

Export: All available materials #1080

Closed
wants to merge 5 commits into from

Conversation

StidOfficial
Copy link

@StidOfficial StidOfficial commented May 29, 2020

Allow in export settings to export all available materials via bpy.data.materials into GLTF for use it in diffrents variants of mesh materials. #231

@CLAassistant
Copy link

CLAassistant commented May 29, 2020

CLA assistant check
All committers have signed the CLA.

@scurest
Copy link
Contributor

scurest commented May 30, 2020

Also there's a material named "Dots Stroke" in every .blend by default (it's for the grease pencil) that gets exported, which is probably not expected since it doesn't show up in the material select dropdown. Should we check for it somehow in the for material in bpy.data.materials loop and skip it?

edit: could maybe check material.is_grease_pencil.

@StidOfficial
Copy link
Author

StidOfficial commented May 30, 2020

@scurest This commit probably resolv your 2 questions about if export_settings['gltf_all_materials']: and the "Dots Stroke" ?

edit: For this situation material.is_grease_pencil is always False

@scurest
Copy link
Contributor

scurest commented May 30, 2020

Yeah it does!

The rest is just IMO:

The new design, where it exports any material assigned to any slot of any object in an exported scene, seems a bit weird to me. The idea of using unused material slots does seem cool (since it would let you control what materials get exported). Seems more consistent to me to only look for unused slots on meshes that actually get exported though (under an option like Geometry > Unused Materials maybe).

blender_object = _blender_object.proxy if _blender_object.proxy else _blender_object
for slot in blender_object.material_slots:
# Check if this slot as assigned material
if slot.material is None:
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@scurest For than i understand, you thing to change if slot.material is None: to if slot.material is None or slot.material == blender_object.active_material: ?

For exclude active_material in __gather_materials array for better performance ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Er, no. I was thinking instead of looking in any material slot in any object in an exported scene, only looking in any material slot in an object that gets exported.

Is that what the lastest "Check if this object is exclude from view layer" check is supposed to do?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You think is better to use bpy.data.objects directly ?
But i need blender_scene with gltf2_blender_gather_nodes.gather_node, i can use users_scene with Object but it's probably weird code because users_scene is tuple.

"Check if this object is exclude from view layer" is because if you uncheck collection, all objects associated with this collection are not exported and is not necessary to exported materials assigned to these objects

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was thinking something like this.

Copy link
Author

@StidOfficial StidOfficial May 30, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, your code is more efficient.
But probably change setting name like "Variants materials" for KHR_materials_variants ?

@julienduroure julienduroure added enhancement New feature or request exporter This involves or affects the export process Material labels Aug 10, 2020
@donmccurdy
Copy link
Contributor

Let's merge #1206 first — once that's in, it provides a dropdown that seems like a better place to put this option. Also, I'm not sure "All materials" is the right name for this option. I would expect an option with that name to include unused materials. Perhaps "Linked materials"?

@julienduroure
Copy link
Collaborator

@donmccurdy Linked materials is not a good name. "Linked" (in blender) means that material come from another .blend file
You can have some unused local materials (using Fake User system)

@donmccurdy
Copy link
Contributor

Ok — If this were added to the dropdown from #1206, then perhaps:

  • Applied (default) Export all materials applied to vertices on included objects
  • Slots Export all materials included in a material slot for an included object
  • ...

Or, any other ideas? @StidOfficial would an option to export all materials (whether used in a slot or not) also work for your use case?

@StidOfficial StidOfficial changed the title Export: All avalaible materials Export: All available materials Sep 27, 2020
@StidOfficial
Copy link
Author

StidOfficial commented Sep 27, 2020

If Slots option was included Applied + Slots, yes it's good idea with dropdown menu.
I don't see another ideas.

@takahirox
Copy link

Hi, I'm interested in this feature because KHR_materials_variants export support can be based on this feature.

#1206 has been merged and Applied + Slots options to the dropdown sounds good to me. Can this PR get in if the options are moved to the dropdown menu?

@StidOfficial Would you mind if updating the PR for it? If you are busy, I would help.

@StidOfficial
Copy link
Author

You can, i am not currently working on for this moment.

@takahirox
Copy link

Thanks, I would like to do. I'm not really sure the right way to take over a PR but I think I locally merge this PR, add some change, and make a new PR.

@takahirox
Copy link

FYI. Regarding KHR_materials_variants extension support, I started to work on an external KHR_materials_variants extension addon.

@julienduroure
Copy link
Collaborator

I think we can now close this ticket, as material variants extension is now part of this addon (in Blender 3.3)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request exporter This involves or affects the export process Material
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants