# How to read and log the output from a compute shader?

**URL:** https://discourse.threejs.org/t/how-to-read-and-log-the-output-from-a-compute-shader/72519
**Category:** Questions
**Tags:** shaders, webgpu
**Created:** [October 7, 2024, 7:19pm UTC](https://discourse.threejs.org/t/how-to-read-and-log-the-output-from-a-compute-shader/72519 "2024-10-07T19:19:35Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![DrDoom](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/drdoom/32/24632_2.png) [@DrDoom](https://discourse.threejs.org/u/DrDoom)
#### Post date: [October 7, 2024, 7:19pm UTC](https://discourse.threejs.org/t/how-to-read-and-log-the-output-from-a-compute-shader/72519/1 "2024-10-07T19:19:35Z")

</div>

Does anyone know how I can read and console.log the results from a compute shader? There are examples on the web for how to do this with raw WebGPU but doing this in Threejs isn’t documented yet. I tried calling the .readOnly() method but that does nothing to the proxy object.

---

<div class="post-metadata">

### Author: ![DrDoom](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/drdoom/32/24632_2.png) [@DrDoom](https://discourse.threejs.org/u/DrDoom)
#### Post date: [October 7, 2024, 7:37pm UTC](https://discourse.threejs.org/t/how-to-read-and-log-the-output-from-a-compute-shader/72519/2 "2024-10-07T19:37:36Z")

</div>

@sunag given you’re the go to on three’s webgpu api, how can I get this done?

---

<div class="post-metadata">

### Author: ![sunag](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/sunag/32/29472_2.png) [@sunag](https://discourse.threejs.org/u/sunag)
#### Post date: [October 8, 2024, 12:34am UTC](https://discourse.threejs.org/t/how-to-read-and-log-the-output-from-a-compute-shader/72519/3 "2024-10-08T00:34:51Z")

</div>

The data should be stored in a `StorageBufferAttribute` or `StorageInstancedBufferAttribute` in compute process, after computed try access using `await renderer.getArrayBufferAsync( buffer )`.

> <https://github.com/mrdoob/three.js/blob/37d6f280a5cd642e801469bb048f52300d31258e/examples/webgpu_compute_audio.html#L54C56-L54C75>

---

<div class="post-metadata">

### Author: ![DrDoom](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/drdoom/32/24632_2.png) [@DrDoom](https://discourse.threejs.org/u/DrDoom)
#### Post date: [October 8, 2024, 4:38am UTC](https://discourse.threejs.org/t/how-to-read-and-log-the-output-from-a-compute-shader/72519/4 "2024-10-08T04:38:04Z")

</div>

Yes this is it!
