Blender: Export models with shaders

How to export models in Blender with its material and shaders?

I have this seamless tiling material in Blender but I want to simplify the process so I don’t have to bake the texture but instead just export the material and model from Blender to Babylon.

That way there is no need for the image to be so large and everything is produced by the material.

1 Like

As specified in the Blender to Babylon page: Blender to Babylon.js exporter | Babylon.js Documentation (babylonjs.com), when you export to the .babylon format and there are procedural textures, they’ll be automatically baked:

In general, when exporting a model with procedural textures, it is better to bake them, as most formats don’t offer support for that: export - How can I pack procedural textures into a .gltf file? - Blender Stack Exchange

3 Likes

Hello @_Cri5 just checking in if you had any more questions :slight_smile:

Any idea on the difficulty of leveraging the materialx / usd efforts to transform that xml to json and use it as an nme graph?

I wasn’t aware of those two formats, but after a brief googling, materialx seems simpler to leverage since it’s “just” a material format. There even seems to be a tool for generating GLSL code: MaterialX/ShaderGeneration.md at main · materialx/MaterialX · GitHub, which could be directly used as a Shader Material Putting Shader Code Into Babylon.js | Babylon.js Documentation with the appropriate setup. I think that translating this to NME would be quite a lot more work.

@Deltakosh @Evgeni_Popov @RaananW @sebavan tagging you all to see if anyone has a better idea than me :rofl:

Totally agree it sounds simpler to go down the shaderMaterial road. That said if we support all the nodes they do it should be doable with nme to .

@bghgary might be more aware of the usdz eco system from his involvment with the gltf group.

Threejs js building a shader graph and rewrote the renderer to use nodes , and they are implementing a node editor.

.three.js examples

Some issues on their github
.Issues · mrdoob/three.js · GitHub

Materialx is now a member of the same foundation as usd, opensubdivision, etc. materialx recently added a three integration too. .MaterialX/javascript at main · materialx/MaterialX · GitHub

I think the goal is to use usd because it has support for scene graphs defined with materialx.

Also nvidia is all in on usd. They have a model management platform with a huge ecosystem of connectors that enable interop between apps. They have a ton of stuff available for free if you install the omniverse launcher

A couple years ago, we chatted with (I think it was) Autodesk about MaterialX after presenting about NME at a conference. I think it’s a good idea, but not sure when we can do it or how feasible it is.

1 Like

Hmm, some examples

Procedural brick, complex example
.MaterialX/standard_surface_brick_procedural.mtlx at main · materialx/MaterialX · GitHub

glass surface, simple example
.MaterialX/standard_surface_glass.mtlx at main · materialx/MaterialX · GitHub

I built an rpc system that was intended to submit machine learning models a couple years ago using storm diagrams as the gui. Perhaps i can be of help, idk. I implemented multi outputs , so that bit could be useful.

I will run some materialx files through a json converter and see how it compares. Its kind of hard to use the nme without a snippet file browser or something though

modified pg from the nme docs:

all i did was copy/pasted the raw glass matx definition, the matx defnition converted to json, and the playground’s nodeMaterial.json to compare the formats.

thanks for bringing in the calvary. :horse_racing:

I just wanted to clarify, it seems like materialx is kind of a subspec usd. so all of these tools that have usd exports indirectly have materialx exporters. Although, that’s not a hard rule it seems to generally be the case. AMD’s blender addon that exports usd uses materialx. However, nvidia’s ecosystem seems to be using this .mdl format (which materialx can also convert to, in addition to osl, glsl ).
the main idea i think for babylon is to use the materialx lib to convert its xml into glsl and use it in the nme as custom shader blocks or directly with the engine. the hope is to enable exporting assets created using node graphs from blender / substance / autodesk apps / etc.

this thread was a good read
.Material-X adopted as an official standard by ASF, possibilities for cycles/Eevee? - Cycles Development - Blender Developer Talk

Maybe to sumarize my thoughts:
if using materialx in babylon would allow importing nodes from blender, continue exploring, otherwise its pointless. Is that a reasonable assessment?

update: feb10
this repo came up on my github feed and made me curious why would autodesk fork usd. They are making progress on js bindings in the hdJavascript branch

1 Like