# Magic in source shader code

**URL:** <https://forum.babylonjs.com/t/magic-in-source-shader-code/27935>\
**Category:** Questions\
**Tags:** material\
**Created:** [February 24, 2022, 12:45pm UTC](https://forum.babylonjs.com/t/magic-in-source-shader-code/27935 "2022-02-24T12:45:49Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Zion\_Huang](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/zion_huang/32/16569_2.png) [@Zion\_Huang](https://forum.babylonjs.com/u/Zion_Huang)\
**Post date:** [February 24, 2022, 12:45pm UTC](https://forum.babylonjs.com/t/magic-in-source-shader-code/27935/1 "2022-02-24T12:45:49Z")

</div>

```auto
#include<samplerVertexDeclaration>(_DEFINENAME_,ALBEDO,_VARYINGNAME_,Albedo)
...
#include<samplerVertexImplementation>(_DEFINENAME_,ALBEDO,_VARYINGNAME_,Albedo,_MATRIXNAME_,albedo,_INFONAME_,AlbedoInfos.x)

```

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.

---

<div class="post-metadata">

**Author:** ![Evgeni\_Popov](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/evgeni_popov/32/4432_2.png) [@Evgeni\_Popov](https://forum.babylonjs.com/u/Evgeni_Popov)\
**Post date:** [February 24, 2022, 3:30pm UTC](https://forum.babylonjs.com/t/magic-in-source-shader-code/27935/2 "2022-02-24T15:30:57Z")

</div>

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

```auto
#include<file>(a,b,c,d,e,f,...)

```

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

---

<div class="post-metadata">

**Author:** ![Zion\_Huang](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/zion_huang/32/16569_2.png) [@Zion\_Huang](https://forum.babylonjs.com/u/Zion_Huang)\
**Post date:** [February 25, 2022, 3:01am UTC](https://forum.babylonjs.com/t/magic-in-source-shader-code/27935/3 "2022-02-25T03:01:29Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Evgeni\_Popov](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/evgeni_popov/32/4432_2.png) [@Evgeni\_Popov](https://forum.babylonjs.com/u/Evgeni_Popov)\
**Post date:** [February 25, 2022, 9:59am UTC](https://forum.babylonjs.com/t/magic-in-source-shader-code/27935/4 "2022-02-25T09:59:16Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Kesshi](https://avatars.discourse-cdn.com/v4/letter/k/b782af/32.png) [@Kesshi](https://forum.babylonjs.com/u/Kesshi)\
**Post date:** [February 25, 2022, 10:17am UTC](https://forum.babylonjs.com/t/magic-in-source-shader-code/27935/5 "2022-02-25T10:17:02Z")

</div>

Its here: [Babylon.js/shaderProcessor.ts at master · BabylonJS/Babylon.js · GitHub](https://github.com/BabylonJS/Babylon.js/blob/master/src/Engines/Processors/shaderProcessor.ts#L363)

---

<div class="post-metadata">

**Author:** ![Zion\_Huang](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/zion_huang/32/16569_2.png) [@Zion\_Huang](https://forum.babylonjs.com/u/Zion_Huang)\
**Post date:** [February 25, 2022, 11:11am UTC](https://forum.babylonjs.com/t/magic-in-source-shader-code/27935/6 "2022-02-25T11:11:38Z")

</div>

That’s what I am looking for! 😆
