How do I intercept and edit PBR material shaders from loaded GLTF asset?
I need to customize my shaders dynamically building upon the base PBR material loaded from a GTLF model.
Will I need to create an effect and call rawVertexSourceCode() and rawFragmentSourceCode() in order to carry out my own preprocessing?
Also intercept is bad terminology. Intercept is probably impossible, unless you change it in the system that generated the export. More of a post load adjustment.
I was able to get the aforementioned shader source with this hack. I imagine there to be a much cleaner, idiomatic Babylonian way of doing this. Now to editing the source and creating a custom shader material and effect.
Hi. You simply can use node material and drive shader through your ‘public’ properties Node Material | Babylon.js Documentation look at Creating PBR materials section. Copy properties from your gltf material and set this properties for your new material in onload callback of your loader
Thanks @kvasss however, I wish to do more than change properties but also add shader functions and conditional logic. The default blocks don’t match my use case. Should I create a custom block by instantiating or extending NodeMaterialBlock? I will dig into the BJS source for how the default block classes are defined. Thanks again.