# The data between JS and webgpu doesn't match well

**URL:** <https://forum.babylonjs.com/t/the-data-between-js-and-webgpu-doesnt-match-well/50069>\
**Category:** Bugs\
**Created:** [April 27, 2024, 2:42pm UTC](https://forum.babylonjs.com/t/the-data-between-js-and-webgpu-doesnt-match-well/50069 "2024-04-27T14:42:24Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nabla-GIT](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/nabla-git/32/39109_2.png) [@Nabla-GIT](https://forum.babylonjs.com/u/Nabla-GIT)\
**Post date:** [April 27, 2024, 2:42pm UTC](https://forum.babylonjs.com/t/the-data-between-js-and-webgpu-doesnt-match-well/50069/1 "2024-04-27T14:42:24Z")

</div>

Hi：

**I’m using WEBGPU, and want to input array1 to a compute shader, as code 83 below：**

 ![image](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/9/2/92bd0c84abc1bc4f2d5dda6a5654d58b83dc57c4.png)

**According to my expectations，buffer1.numbers[0] at code 148 should be equal to 1,and ground should turns to red(matching the last number in array1)：**

 ![image](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/9/2/9221960c81b5f0b710c4cb5a2bb94669afbb0f33.png)

**however, the ground shows black(not red)，which means buffer1.numbers[0] is not equal to1（not correspond to array1）**

**what should I do to correspond the elements of array1 and struct Triangle{…}**  
**what should I do to correspond the elements of array1 and struct Triangle{…}**  
**what should I do to correspond the elements of array1 and struct Triangle{…}**

the playground project: [Compute shader error | Babylon.js Playground (babylonjs.com)](https://playground.babylonjs.com/#4EQ8ZT)

---

<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:** [April 27, 2024, 3:50pm UTC](https://forum.babylonjs.com/t/the-data-between-js-and-webgpu-doesnt-match-well/50069/2 "2024-04-27T15:50:06Z")

</div>

`buffer1.numbers[0]` is 0 in the PG, not 1, because there are some alignment constraints or the `Triangle` struct that adds a dummy float after `size`. So, you should have seven 0 and not six before the color value.

Also, as you create the texture with the default type, you end up using UNSIGNED\_BYTE, so you should put 255 for the color value, not 1:

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

---

<div class="post-metadata">

**Author:** ![Nabla-GIT](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/nabla-git/32/39109_2.png) [@Nabla-GIT](https://forum.babylonjs.com/u/Nabla-GIT)\
**Post date:** [April 27, 2024, 5:57pm UTC](https://forum.babylonjs.com/t/the-data-between-js-and-webgpu-doesnt-match-well/50069/3 "2024-04-27T17:57:35Z")

</div>

Thanks for your prompt reply.❤

in new PG,

I consider that the vec3 size2 in the struct Triangle correspond to 5th-7th number in array1.

why not the 4th-6th number being filled to vec3 size2? (why the 4th number is ignored？ )

tell me more the details please～

new PG:[https://playground.babylonjs.com/#4EQ8ZT#3](https://playground.babylonjs.com/#4EQ8ZT#3)

---

<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:** [April 27, 2024, 11:09pm UTC](https://forum.babylonjs.com/t/the-data-between-js-and-webgpu-doesnt-match-well/50069/4 "2024-04-27T23:09:46Z")

</div>

Here is a doc detailing the padding [[WGSL] Proposal: Default Struct Layout · Issue #1393 · gpuweb/gpuweb · GitHub](https://github.com/gpuweb/gpuweb/issues/1393)
