Magic in source shader code


How do these two magic “include” work? Their inputs(I just guess) are kind of like macro, but I have no idea how they work.

It simply includes the content of the file referenced between <...> (found in Shaders/ShadersInclude/) applying some global replacing on the content:


=> it replaces all occurrences of a by b, all occurrences of c by d, etc on the content of file.


That’s very smart :star_struck: Where can I learn more about this? Any reference will be helpful.

There’s no documentation about this as it is some implementation detail. You can learn more by reading the Babylon.js source code :slight_smile:

Its here: Babylon.js/shaderProcessor.ts at master · BabylonJS/Babylon.js · GitHub

1 Like

That’s what I am looking for! :laughing: