-
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
Exporting Alternate Materials #231
Comments
Also interested in this. Also I'm pretty sure the old exporter used to export the alternate materials. |
Is what you're describing here basically that the exporter would include all materials available in the scene when exporting to glTF, even if some of those materials aren't used by any mesh? So they'd be unattached, but engines could access them and use them as needed? Note that there wouldn't be any sense of exactly which mesh the materials are alternates for. It's just a bag of materials, and the engine can use mesh and material name (and custom code) to assign them properly. If that's all OK, this seems like a reasonable thing to have available as an option, but probably disabled by default. I think the same logic could apply to textures — users might create a lightmap or other texture that glTF doesn't support, and just want to bundle it, so their runtime can do something with it. A more formal proposal for alternate materials has been made on the glTF repository, but I'm not sure whether that fits well into this Blender exporter, or whether it's near enough completion to implement. |
I can't talk for @robert-nash, but that would work perfectly for me, as long as the names are kept like for other materials it's easy to reassign them. |
Yeah, I think this is very interesting and can be very useful |
I am interresting by this feature for select materials avalaible in GLTF with ThreeJS. It's very bloken with only active materials |
With this First implementation of KHR_materials_variants :
|
I'm not sure if we should export Importing glTF variants to slots seems harmless though. |
Yes is based on materials slots (attached to the mesh). |
Hi, I'm interested in letting Blender support glTF Based on @StidOfficial's work I'm working on the trial of the glTF A problem with this approach (or even other approaches) may be how variant names and grouping should be, like mapping ("variantName0" - MaterialA for MeshA and MaterialB for MeshB, "variantName1" - MaterialC for MeshA and MaterialD for for MeshB). Does Blender have a core feature representing such grouping? Update: I found that the slots can be ordered and the same material can be assigned to multiple slots. So slots also can be used as variant group, like slot0 for variant group0, slot1 for variant group1... (although user still needs to somehow provide variant names). I'm not sure if it's a good design but it doesn't require the extension specific UI/properties so much. |
Do you know if it is possible to assign a different name to a material slot from an assigned material? I thought material slot name can be used for variant name and variant material combination. But MaterialSlot.name seems read-only. And updating |
@takahirox I'm interested in a solution here too, but I don't know if exporting material slots in this way is workable. The material slots are already needed for meshes that have more than one material applied. During glTF export, the glTF meshes contain multiple primitives, one per material. I suppose there could be an export configuration switch, to enable KHR_material_variants using material slots, but that would come at the expense of the ability to assign multiple materials to a single mesh. Each mesh in the file would need to contain a single material, with the slots used to offer variants. But this is well outside the normal usage pattern for Blender, so it might not be intuitive for people who are accustomed to the normal use of those slots. I'm not actually sure what the right solution is here. Blender doesn't really have a matching concept of material variants. |
Hi @emackey, thanks for the comment. Yeah, I studied Blender and started to think that the Material slots approach may not be intuitive especially to the existing blender users, too. But I couldn't come up with better ideas so far. And I know there are users who want to import/export glTF file including Some options for export in my mind so far are
Regarding import, importing it into Material slots may be harmless as Don mentioned. |
Personally I'd go with option 3. We have a similar situation in the Hubs Blender Exporter where we allow you to specify alternate materials for a given "kit piece". We have an additional UI which allows you to pick the alternate materials for a given node: I know that something like this wouldn't ship with Blender and probably couldn't be included in Is it possible that this extension, and others that would be better off with additional UI, be covered by a companion addon that includes support for additional extensions? In this way we can point advanced users of glTF to a "glTF-Blender-IO-extras" addon which can start to push the possibilities of the Blender glTF exporter forward? Both in UX and capabilities. |
@robertlong That's a good idea, I think a separate KHR_materials_variants add-on working as a companion to this one could be really effective. I'm less sure about a generic "glTF-Blender-IO-extras" addon, it sounds like that could become unfocused and suffer feature-creep. So I think an addon targeted to the specific extension would be better. I'm not sure who would write it or fund its development, though. |
I'm willing to do it. |
@takahirox Awesome! If you haven't already, take a look at the example glTF extension addon in this repo, for some idea how a 3rd-party addon can extend glTF export. The Mozilla Hubs addon (linked above) is also doing this I believe. |
Thanks for the advices. Finally the prototype started to work... As I commented #1009 (comment), I need the abilities to add extensions to the root glTF object (and access the entire glTF object). I added a workaround hack to my addon so far but I would be pleased if you or other members commented on that thread. And question, does |
@takahirox Are you on the Hubs team too? Sorry about sending you a link to your own project's source... Take a look at what Julian just submitted: #1347 And I don't think there's any import support... @jjcasmar Any ideas about hooking into the importer? |
I haven't thought anything about hooking the importer nor I haven't found any interest for it, since I can save my scenes directly in blend format. If the idea is to be able to share between different 3D software, like having a scene in Maya, export to gltf2 and import into blender, I think there are more suitable format. @takahirox what is not working about adding root gltf objects? iirc, I have developed an addon which adds a tag system to gltf, creating tags in the root object and referencing them on the addons. |
I think we can now close this ticket, as material variants extension is now part of this addon (in Blender 3.3) |
Hello, As noted here, takahirox/glTF-Blender-IO-materials-variants#20 this addon is no more really useful, as the glTF-Blender-IO addon is now fully compatible with Material Variant since Blender 3.2 You should have a look on documentation for more info : https://docs.blender.org/manual/en/latest/addons/import_export/scene_gltf2.html#gltf-variants |
Thank so much ! you save a lot off my time ! |
Hey bro ! Currently I have 2 materials attached to 2 separate objects, is there a way to create 2 more of those materials and share 1 variant? If not, I think I will combine 2 objects and 2 materials and assign to each area. Do you find it feasible? |
I know that this is quite a broad workflow issue which is not necessarily specific to this addon but I wonder if the addon might be able to facilitate this.
I am exporting a model from Blender to Babylon.JS as outlined
[here](https://blender.stackexchange.com/questions/128741/exporting-alternate-materials-to-gltf)
and I want to be able to have alternative materials for a mesh such that the user can choose between different materials. At the minute it seems to be only possible to export materials which are assigned to a material and then only from the first material slot.I wonder if there is anyway that this addon could export materials which aren't assigned to a mesh in Blender?
The text was updated successfully, but these errors were encountered: