# NodeMaterial Self Lighting

**URL:** <https://forum.babylonjs.com/t/nodematerial-self-lighting/6101>\
**Category:** Questions\
**Created:** [October 4, 2019, 12:51am UTC](https://forum.babylonjs.com/t/nodematerial-self-lighting/6101 "2019-10-04T00:51:42Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![Notruilin](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/notruilin/32/4593_2.png) [@Notruilin](https://forum.babylonjs.com/u/Notruilin)\
**Post date:** [October 4, 2019, 12:51am UTC](https://forum.babylonjs.com/t/nodematerial-self-lighting/6101/1 "2019-10-04T00:51:42Z")

</div>

Hi there,  
I’m wondering if I can make NodeMaterial self-lighting?  
Something like this…

 ![image](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/2X/1/15881dec19de389287c3168196097059a0610f8b.png)  
Thanks!

---

<div class="post-metadata">

**Author:** ![Notruilin](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/notruilin/32/4593_2.png) [@Notruilin](https://forum.babylonjs.com/u/Notruilin)\
**Post date:** [October 4, 2019, 12:45pm UTC](https://forum.babylonjs.com/t/nodematerial-self-lighting/6101/3 "2019-10-04T12:45:29Z")

</div>

Hi, if i understand correctly, the glow layer requires to set emissive texture. I don’t know how to set it for NodeMaterial 🤔

---

<div class="post-metadata">

**Author:** ![Deltakosh](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/deltakosh/32/26635_2.png) [@Deltakosh](https://forum.babylonjs.com/u/Deltakosh)\
**Post date:** [October 4, 2019, 3:50pm UTC](https://forum.babylonjs.com/t/nodematerial-self-lighting/6101/4 "2019-10-04T15:50:33Z")

</div>

Invoking @sebavan

---

<div class="post-metadata">

**Author:** ![sebavan](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/sebavan/32/57_2.png) [@sebavan](https://forum.babylonjs.com/u/sebavan)\
**Post date:** [October 6, 2019, 11:19am UTC](https://forum.babylonjs.com/t/nodematerial-self-lighting/6101/5 "2019-10-06T11:19:08Z")

</div>

It needs a property called emissiveTexture or emissiveColor but the easiest is to supply through the custom callbacks as explained in the doc (on my phone can not remember the callback name).

The main limitation is that vertex displacements would not be supported.

---

<div class="post-metadata">

**Author:** ![Notruilin](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/notruilin/32/4593_2.png) [@Notruilin](https://forum.babylonjs.com/u/Notruilin)\
**Post date:** [October 6, 2019, 11:01pm UTC](https://forum.babylonjs.com/t/nodematerial-self-lighting/6101/6 "2019-10-06T23:01:18Z")

</div>

Hey, thank you for replying. Could you be more specific? 🤔 I can’t find relative documents 🤕

---

<div class="post-metadata">

**Author:** ![Notruilin](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/notruilin/32/4593_2.png) [@Notruilin](https://forum.babylonjs.com/u/Notruilin)\
**Post date:** [October 7, 2019, 12:04am UTC](https://forum.babylonjs.com/t/nodematerial-self-lighting/6101/7 "2019-10-07T00:04:48Z")

</div>

More specifically, I’m trying to make my NodeMaterial glowing like this…😓 Is that possible?🤨  
[https://www.babylonjs-playground.com/#MCJYB5#13](https://www.babylonjs-playground.com/#MCJYB5#13)

 ![image](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/2X/7/705da30e757af3341859f4beaa9e44a1a658a1c9.jpeg)

---

<div class="post-metadata">

**Author:** ![sebavan](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/sebavan/32/57_2.png) [@sebavan](https://forum.babylonjs.com/u/sebavan)\
**Post date:** [October 7, 2019, 6:07am UTC](https://forum.babylonjs.com/t/nodematerial-self-lighting/6101/8 "2019-10-07T06:07:36Z")

</div>

Here is the related part of the doc [Make Mesh Glow - Babylon.js Documentation](https://doc.babylonjs.com/how_to/glow_layer#controlling-glow-color-per-mesh)

---

<div class="post-metadata">

**Author:** ![sebavan](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/sebavan/32/57_2.png) [@sebavan](https://forum.babylonjs.com/u/sebavan)\
**Post date:** [October 7, 2019, 6:10am UTC](https://forum.babylonjs.com/t/nodematerial-self-lighting/6101/9 "2019-10-07T06:10:09Z")

</div>

The main issue is you would need a custom shader shader to render the glow as well which is not supported so far.

---

<div class="post-metadata">

**Author:** ![Notruilin](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/notruilin/32/4593_2.png) [@Notruilin](https://forum.babylonjs.com/u/Notruilin)\
**Post date:** [October 7, 2019, 6:29am UTC](https://forum.babylonjs.com/t/nodematerial-self-lighting/6101/10 "2019-10-07T06:29:37Z")

</div>

🤔 I’ll try an alternative way. Thank you!

---

<div class="post-metadata">

**Author:** ![sebavan](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/sebavan/32/57_2.png) [@sebavan](https://forum.babylonjs.com/u/sebavan)\
**Post date:** [October 7, 2019, 6:31am UTC](https://forum.babylonjs.com/t/nodematerial-self-lighting/6101/11 "2019-10-07T06:31:04Z")

</div>

I ll take a look in the evening how hard it would be to replace the generation shader by a custom one .

---

<div class="post-metadata">

**Author:** ![Notruilin](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/notruilin/32/4593_2.png) [@Notruilin](https://forum.babylonjs.com/u/Notruilin)\
**Post date:** [October 7, 2019, 6:40am UTC](https://forum.babylonjs.com/t/nodematerial-self-lighting/6101/12 "2019-10-07T06:40:42Z")

</div>

😄 Thank you so much

---

<div class="post-metadata">

**Author:** ![sebavan](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/sebavan/32/57_2.png) [@sebavan](https://forum.babylonjs.com/u/sebavan)\
**Post date:** [October 8, 2019, 11:24pm UTC](https://forum.babylonjs.com/t/nodematerial-self-lighting/6101/13 "2019-10-08T23:24:19Z")

</div>

I am still looking into it I hope to have a solution by Friday but it is way more complex that I thought at first 🙂

---

<div class="post-metadata">

**Author:** ![Notruilin](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/notruilin/32/4593_2.png) [@Notruilin](https://forum.babylonjs.com/u/Notruilin)\
**Post date:** [October 10, 2019, 3:43am UTC](https://forum.babylonjs.com/t/nodematerial-self-lighting/6101/14 "2019-10-10T03:43:39Z")

</div>

Thank you so so much 🤣 Take your time

---

<div class="post-metadata">

**Author:** ![sebavan](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/sebavan/32/57_2.png) [@sebavan](https://forum.babylonjs.com/u/sebavan)\
**Post date:** [October 14, 2019, 6:42pm UTC](https://forum.babylonjs.com/t/nodematerial-self-lighting/6101/15 "2019-10-14T18:42:12Z")

</div>

Sorry for the delay, it is incoming:

 ![image](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/2X/2/2b7834b2a157384c0093bef7f7367f99ad8b7e5e.jpeg)

Should be in by tomorrow 😉

---

<div class="post-metadata">

**Author:** ![sebavan](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/sebavan/32/57_2.png) [@sebavan](https://forum.babylonjs.com/u/sebavan)\
**Post date:** [October 14, 2019, 6:48pm UTC](https://forum.babylonjs.com/t/nodematerial-self-lighting/6101/16 "2019-10-14T18:48:04Z")

</div>

PR is up: [Supports custom glow materials. by sebavan · Pull Request #6974 · BabylonJS/Babylon.js · GitHub](https://github.com/BabylonJS/Babylon.js/pull/6974)

The only change you ll need in your code is :

const gl = new BABYLON.GlowLayer(“gl”, scene);  
gl.referenceMeshToUseItsOwnMaterial(mesh);

to ensure the mesh uses its own material to generate the glow.

---

<div class="post-metadata">

**Author:** ![Notruilin](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/notruilin/32/4593_2.png) [@Notruilin](https://forum.babylonjs.com/u/Notruilin)\
**Post date:** [October 14, 2019, 10:41pm UTC](https://forum.babylonjs.com/t/nodematerial-self-lighting/6101/17 "2019-10-14T22:41:12Z")

</div>

Wow! Fantastic! Thank you so much! 😆  
[https://www.babylonjs-playground.com/#MCJYB5#15](https://www.babylonjs-playground.com/#MCJYB5#15)
