Using shaders exported from Node Material Editor

Hi there, I’ve built my first custom shaders, using Node Material Editor, but I’m having trouble integrating them into a playground.

If I use the generate code button, and just use that as a material, it seems to work, but if I just export the shaders, I see errors in the console, and nothing renders. - I exported both code, and shaders from this NME to generate: - Shaders playground, does not render

Babylon.js Playground - Generated code playground, renders fine

Am I using the ShaderMaterial wrongly?


Adding @Evgeni_Popov

The exported shader code is not really meant to be used directly because it would need a lot of wrapping to be functional. See #include directives in shader code output from Node Material Editor for eg.

What you should do is either exporting the js code, as you did in your PG or use the NodeMaterial.ParseXXX functions:

Thank you! That thread was really helpful.

The reason I wanted to use shaders was to have a way to select a slice of a texture, per instance of a mesh.

CustomMaterial saved my day here! Here’s my example:

You can also inject a new attribute in a node material by using the same technic than described here: Thin instances, node material and custom attribute