Using Material Blocks in Fragment Shaders

Hello, and I have found some useful shader code mixed in with the block declarations which I would like to use. It looks like some of the shader block code can be directly included:


Is there a way to similarly include the code found in voronoiNoiseBlock.ts?


I’m not sure I understand your question, if you want to reuse the shader code found in the voronoiNoiseBlock.ts file you can copy/paste it into your own shader?

If you want this code to be made available to your shader using a #include<voronoiNoise> statement, you can assign the code in BABYLON.ShaderStore.IncludesShadersStore["voronoiNoise"].

Thanks, and that was what I meant. Is there a listing of all the includes which are available to glsl?

The directory that is mentioned in the docs contains only an implementation for perlin.


Yes, the directory mentioned in the doc is the right one: Babylon.js/packages/dev/core/src/Shaders/ShadersInclude at master · BabylonJS/Babylon.js · GitHub.

We do not have an implementation of Voronoi here. The code in Shaders/ and ShadersInclude/ is code used internally by Babylon.js and not general code that could be used by users, although they can still use it of course! But we cannot guarantee that we will not change the structure of the files / that we will not change the code in a breakable way (these files are not covered by Babylon’s “no breakable change” policy).

1 Like