# Passing mat4 array to shader uniform

**URL:** https://discourse.processing.org/t/passing-mat4-array-to-shader-uniform/1177
**Category:** Coding Questions
**Created:** [June 22, 2018, 9:46pm UTC](https://discourse.processing.org/t/passing-mat4-array-to-shader-uniform/1177 "2018-06-22T21:46:25Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![kosowski](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kosowski/32/550_2.png) [@kosowski](https://discourse.processing.org/u/kosowski)
#### Post date: [June 22, 2018, 9:46pm UTC](https://discourse.processing.org/t/passing-mat4-array-to-shader-uniform/1177/1 "2018-06-22T21:46:25Z")

</div>

Hi all!

I want to pass an array of mat4 transformation matrices to a uniform in a PShader object, defined like this:

```

uniform mat4 jointTransforms[MAX_JOINTS];

```

I cannot see this option neither in the reference nor in the PShader source. While at looking at it i tried to convert the trnasform to a FloatBuffer and pass it like this:

```

int matGlobalParam = pgl.getUniformLocation(shader.glProgram, "jointTransforms");		
FloatBuffer floatBuffer = entity.getJointTransformsFB(); //convert matrices to floatbuffer method
floatBuffer.position(0);
pgl.uniformMatrix4fv(matGlobalParam , entity.jointCount , false, floatBuffer);

```

But it doeant look like its working. How should it bedone? Thanks!

---

<div class="post-metadata">

### Author: ![kosowski](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kosowski/32/550_2.png) [@kosowski](https://discourse.processing.org/u/kosowski)
#### Post date: [June 23, 2018, 4:46pm UTC](https://discourse.processing.org/t/passing-mat4-array-to-shader-uniform/1177/2 "2018-06-23T16:46:51Z")

</div>

Found that the code works if I add shader.bind() after beginPGL() and shader.unbind() before the endPGL() ¯\_(ツ)\_/¯
