# Custom Material Cant bind float Arrays?

**URL:** <https://forum.babylonjs.com/t/custom-material-cant-bind-float-arrays/43523>\
**Category:** Questions\
**Created:** [August 24, 2023, 1:37am UTC](https://forum.babylonjs.com/t/custom-material-cant-bind-float-arrays/43523 "2023-08-24T01:37:14Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Pryme8](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/pryme8/32/7212_2.png) [@Pryme8](https://forum.babylonjs.com/u/Pryme8)\
**Post date:** [August 24, 2023, 1:37am UTC](https://forum.babylonjs.com/t/custom-material-cant-bind-float-arrays/43523/1 "2023-08-24T01:37:14Z")

</div>

> **[Babylon.js Playground](https://playground.babylonjs.com/#YCY2IL%231814)**
>
> Babylon.js playground is a live editor for Babylon.js WebGL 3D scenes

I have tried a ton of ways to get this float array to bind correct.  
Is there something I am doing wrong?

After figuring out that the array is not binding in the initial setting, I tried on the effect and it started giving me a weird error.

---

<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:** [August 24, 2023, 7:56am UTC](https://forum.babylonjs.com/t/custom-material-cant-bind-float-arrays/43523/2 "2023-08-24T07:56:56Z")

</div>

The effect is not necessarily ready when `onEffectCreatedObservable` is called. You should poll for `effect.isReady()` to be `true` before calling `setFloatArray`.

But as this uniform won’t be part of an ubo, you’d have to bind the value every time the material is used, so it’s better to use the `onBindObservable` event for this :

> **[Babylon.js Playground](https://playground.babylonjs.com/#YCY2IL%231816)**
>
> Babylon.js playground is a live editor for Babylon.js WebGL 3D scenes

---

<div class="post-metadata">

**Author:** ![Pryme8](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/pryme8/32/7212_2.png) [@Pryme8](https://forum.babylonjs.com/u/Pryme8)\
**Post date:** [August 24, 2023, 4:19pm UTC](https://forum.babylonjs.com/t/custom-material-cant-bind-float-arrays/43523/3 "2023-08-24T16:19:33Z")

</div>

If this value never changes would it be better to just hardcode it into the shader?

> **[Babylon.js Playground](https://playground.babylonjs.com/#YCY2IL%231817)**
>
> Babylon.js playground is a live editor for Babylon.js WebGL 3D scenes

---

<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:** [August 24, 2023, 4:59pm UTC](https://forum.babylonjs.com/t/custom-material-cant-bind-float-arrays/43523/4 "2023-08-24T16:59:09Z")

</div>

Yes, if the values won’t ever change, it’s better not to use a uniform to pass the values but hardcode them in the shader.
