How can I get the raw vertex and fragment shader source of a PBR material loaded with a GLTF model?

How can I get the raw vertex and fragment shader source of a PBR material loaded with a GLTF model?

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.

No need for a hack, simply remove the leading underscore char, there’s a getter for vertexSourceCode and fragmentSourceCode (as well as rawVertexSourceCode / rawFragmentSourceCode which are the sources before any processing have been performed on them).

Note that you can use CustomMaterial to create a custom material based on the standard material, and PBRCustomMaterial for a material based on the PBR material. And ShaderMaterial for a truly custom material.

1 Like

Thanks @Evgeni_Popov, I am going to play around with PBRCustomMaterial first. Have a safe and rewarding day!