# \#include directives in shader code output from Node Material Editor

**URL:** https://forum.babylonjs.com/t/include-directives-in-shader-code-output-from-node-material-editor/10730
**Category:** Questions
**Created:** [May 11, 2020, 8:33am UTC](https://forum.babylonjs.com/t/include-directives-in-shader-code-output-from-node-material-editor/10730 "2020-05-11T08:33:14Z")
**Posts on this page:** 1
**Showing post:** 2

<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: [May 11, 2020, 10:50am UTC](https://forum.babylonjs.com/t/include-directives-in-shader-code-output-from-node-material-editor/10730/2 "2020-05-11T10:50:13Z")

</div>

The shader code generated by the NME can’t be used “as is”, you must at the very least bind the uniform and sampler variables with the right values.

In your example, `u_world`, `u_viewProjection`, `u_Diffusecolor`, etc must be bound with a value, else they are empty by default. Even the standard matrices must be, because, for eg, `u_world` is not the standard name used by Babylon, it is `world` instead. All those things (and much others) are done for you by the `NodeMaterial` class so you don’t have to worry about it.

Even then, it won’t still work because the `ShaderMaterial` class is a thin wrapper around raw shader code, and notably it does not deal with lights, even when adding the light declarations in the shader code like `#include< __decl__ lightFragment>[0..maxSimultaneousLights]` and `#include<lightFragment>[0..maxSimultaneousLights]`. That’s because you still have to call some javascript code behind the scene to make those includes work.

As an exercise 🙂, I updated your PG to make it work with the NME generated shader code. You can compare this PG with the previous one to see what have changed.

[https://playground.babylonjs.com/#KR5FLI#6](https://playground.babylonjs.com/#KR5FLI#6)

The biggest change is that I had to override the `BABYLON.ShaderMaterial.prototype.isReady` method to make it handle lights. Note that my changes are not very clean, but it works (the `ShaderMaterial` class would need more reworking to handle lights cleanly).

As said, it was an exercise, the shader code generated by the NME is not really meant to be included in a `ShaderMaterial` afterwards… If what you are after is to be able to reuse a NME material in another one, I think some people are working to make this happen inside the NME itself (@Deltakosh will know more about this).

Regarding your other questions:

- `#include<lightFragmentDeclaration>[0..maxSimultaneousLights]` means to inject `maxSimultaneousLights` times the content of the `lightFragmentDeclaration.fx` file, the first time replacing `{X}` by 0, then by 1, etc (look inside `lightFragmentDeclaration.fx`, you will see some `{X}` all over the places). `maxSimultaneousLights` is passed by the javascript code when creating the effect.
- .fx extension is just the extension used in Babylon for files holding glsl code, but it has no meaning by itself (except maybe for some gulp processing that expects that glsl code are inside .fx files?)

---

_[View the full topic](https://forum.babylonjs.com/t/include-directives-in-shader-code-output-from-node-material-editor/10730)._
