Combine Shader with StandardMaterial

I have written my own little test Shader with the help of the community here (https://playground.babylonjs.com/#3ME1I1#1). Now I would like to combine this shader with the StandardMaterial.
I did look into MultiMaterial, but I don’t think that this is what I want.

How would I go about combining my own shader with the StandardMaterial?

1 Like

Hi. Maybe you can try customMaterial.
Here is one example:
https://playground.babylonjs.com/#AFRP1L#4
So it’ll contain all the data from a standard material plus the shader you added.Cheers!

Hi, thx for your answer.

I want to pass a variable from the Vertex Shader to the Fragment Shader. Do you know how to achieve this with customMaterial. I was expecting something like: mat.addVarying but couldn’t find such a function.

Furthermore, is it possible to surround this code with a #ifdef DISCARD to enable and disable the shader on demand?

I’m afraid this is not possible. Your best hope is to use the NodeMaterial here