Learning more about Babylon material plugins

I was recently exposed to the material plugins feature that came with Babylon 5.0, and have read through the documentation here Material Plugins | Babylon.js Documentation

When attempting to add invalid shader code, the entire shader GLSL source is outputted to the browser console, so I’ve been able to get a hold of it that way and have a look at it. I’ve got a couple of questions;

  • is there a better way to get the shader code for a Material?

  • is there any specific documentation on the process by which this shader code is generated, and how existing Babylon shaders work internally? or will this just require having a look through the Babylon documentation and the source code to piece it all together?

AFAIK, there is no other way to see, quickly, the code generated. Maybe I’m wrong. ping @sebavan

is there any specific documentation on the process by which this shader code is generated

Do you have something specific in mind?

You can use Spector.js to see the generated code (this is usually how I do it).

MaterialPlugins is an extremely advanced way of customizing materials requiring some knowledge about the framework in any mid/complex scenarios.

The code will definitely be the best way to check what is happening in this case.

2 Likes

You can also use material.onCompiled to log the shader code after it’s compiled like on line 28.

3 Likes