# Thin instances, node material and custom attribute

**URL:** <https://forum.babylonjs.com/t/thin-instances-node-material-and-custom-attribute/11110>\
**Category:** Demos and projects\
**Created:** [May 24, 2020, 8:12pm UTC](https://forum.babylonjs.com/t/thin-instances-node-material-and-custom-attribute/11110 "2020-05-24T20:12:11Z")\
**Posts on this page:** 5\
**Page:** 1

<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 24, 2020, 8:12pm UTC](https://forum.babylonjs.com/t/thin-instances-node-material-and-custom-attribute/11110/1 "2020-05-24T20:12:11Z")

</div>

Here’s a little PG that demonstrates using a custom attribute with instances (this is more a proof of concept than anything else):

[https://playground.babylonjs.com/#ZTTZJ3#1](https://playground.babylonjs.com/#ZTTZJ3#1)

Instances are using the new thin instance support ([Use Thin Instances - Babylon.js Documentation](https://doc.babylonjs.com/how_to/how_to_use_thininstances)) and the custom attribute is used to vary the metallic and roughness properties of the sphere.

A node material is used as the basis material, and a custom `NodeMaterialBlock` class is created to handle the custom attribute and inject the metallic/roughness values in the workflow. Doing this way instead of creating a `PBRCustomMaterial`, for eg, is more future proof as no custom shader code is written, only a custom `NodeMaterialBlock` which is guaranteed to work in future versions.

I think writing such custom `NodeMaterialBlock` classes could be made easier with some helpers, however. Maybe something that could/will happen in the future!

[EDIT]  
Edited to fix the PBR node material after the changes of the design that occurred lately  
[/EDIT]

---

<div class="post-metadata">

**Author:** ![gbz](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/gbz/32/23780_2.png) [@gbz](https://forum.babylonjs.com/u/gbz)\
**Post date:** [May 24, 2020, 10:50pm UTC](https://forum.babylonjs.com/t/thin-instances-node-material-and-custom-attribute/11110/2 "2020-05-24T22:50:09Z")

</div>

Awesome 😃 had no idea these features existed!

---

<div class="post-metadata">

**Author:** ![ochendricks](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/ochendricks/32/24151_2.png) [@ochendricks](https://forum.babylonjs.com/u/ochendricks)\
**Post date:** [May 6, 2022, 9:08am UTC](https://forum.babylonjs.com/t/thin-instances-node-material-and-custom-attribute/11110/3 "2022-05-06T09:08:42Z")

</div>

Hi @Evgeni_Popov ! Is there any other example playground where feeding a material with thinInstance buffer information to get a custom Material working procedurally throughout all the instances?  
This one #ZTTZJ3#1 refers to another playground and I can’t seem to get any further clues on that.  
Thanks!

---

<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 6, 2022, 10:00am UTC](https://forum.babylonjs.com/t/thin-instances-node-material-and-custom-attribute/11110/4 "2022-05-06T10:00:45Z")

</div>

Welcome aboard!

No, I don’t think there are others PGs that are extending `NodeMaterialBlock`.

However, since 5.0 you can now create custom blocks in the NME that should facilitate reuse.

See [Node Material Editor Custom Blocks | Babylon.js Documentation](https://doc.babylonjs.com/toolsAndResources/tools/nme/customBlocks)

---

<div class="post-metadata">

**Author:** ![ochendricks](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/ochendricks/32/24151_2.png) [@ochendricks](https://forum.babylonjs.com/u/ochendricks)\
**Post date:** [May 6, 2022, 12:51pm UTC](https://forum.babylonjs.com/t/thin-instances-node-material-and-custom-attribute/11110/5 "2022-05-06T12:51:12Z")

</div>

Thanks @Evgeni_Popov for the quick response 🙂
