# \#compute-shader

**URL:** https://forum.babylonjs.com/tag/compute-shader/344.md

[Latest](https://forum.babylonjs.com/latest.md) · [Categories](https://forum.babylonjs.com/categories.md) · [Tags](https://forum.babylonjs.com/tags.md)

---

## [Compute Shader Bind Two Textures](https://forum.babylonjs.com/t/compute-shader-bind-two-textures/59799)

<div class="topic-metadata">

**Author:** [@rdurnin](https://forum.babylonjs.com/u/rdurnin)\
**Replies:** 3\
**Last updated:** [July 29, 2025, 9:37pm UTC](https://forum.babylonjs.com/t/compute-shader-bind-two-textures/59799 "2025-07-29T21:37:32Z")

</div>

Hello, and I have been working on some compute shader tools and am running into an issue with binding more than one input texture and sampler. The issue arises when I try to setTexture on the instanced shader, and the me…

---

## [How to create a physics aggregate from GPU vertex data?](https://forum.babylonjs.com/t/how-to-create-a-physics-aggregate-from-gpu-vertex-data/58804)

<div class="topic-metadata">

**Author:** [@CrashMaster](https://forum.babylonjs.com/u/CrashMaster)\
**Replies:** 6\
**Last updated:** [June 4, 2025, 12:31pm UTC](https://forum.babylonjs.com/t/how-to-create-a-physics-aggregate-from-gpu-vertex-data/58804 "2025-06-04T12:31:09Z")

</div>

Hey there! So I have this PG where I create a bunch of vertex data with a compute shader: Now I want some physics, so I need the vertex data on the CPU. My first solution is to read from the GPU buffers to create a …

---

## [Shadow bug when vertex data lives only on the GPU](https://forum.babylonjs.com/t/shadow-bug-when-vertex-data-lives-only-on-the-gpu/58725)

<div class="topic-metadata">

**Author:** [@CrashMaster](https://forum.babylonjs.com/u/CrashMaster)\
**Replies:** 6\
**Last updated:** [May 31, 2025, 5:52pm UTC](https://forum.babylonjs.com/t/shadow-bug-when-vertex-data-lives-only-on-the-gpu/58725 "2025-05-31T17:52:09Z")

</div>

Hey there! Following discussions at How to keep buffers on the GPU when using compute shaders for instancing or vertex data generation - #10 by Evgeni\_Popov I found what could be a bug with shadows when generating the v…

---

## [Hair Simulation WebGPU](https://forum.babylonjs.com/t/hair-simulation-webgpu/55663)

<div class="topic-metadata">

**Author:** [@Propolisa](https://forum.babylonjs.com/u/Propolisa)\
**Replies:** 24\
**Last updated:** [May 30, 2025, 3:41am UTC](https://forum.babylonjs.com/t/hair-simulation-webgpu/55663 "2025-05-30T03:41:56Z")

</div>

Hey folks happy new year! For a very WIP underwater first-person-fishing game with a currently very hairless character, I wanted non-rigid hair. But of course it will also be useful for various soft elements like float…

---

## [WebGPU compute shader for audio and graphics (C64 - 8 bit emulation)](https://forum.babylonjs.com/t/webgpu-compute-shader-for-audio-and-graphics-c64-8-bit-emulation/55972)

<div class="topic-metadata">

**Author:** [@inteja](https://forum.babylonjs.com/u/inteja)\
**Replies:** 7\
**Last updated:** [January 16, 2025, 1:09am UTC](https://forum.babylonjs.com/t/webgpu-compute-shader-for-audio-and-graphics-c64-8-bit-emulation/55972 "2025-01-16T01:09:48Z")

</div>

I have an old project of mine I’m aiming to resurrect, to make a 3D emulation of a C64. I initially tried using WebAssembly (AssemblyScript) for the emulation, but ran into roadblocks I can’t even recall now, so I switch…

---

## [How to quickly read data from a compute shader?](https://forum.babylonjs.com/t/how-to-quickly-read-data-from-a-compute-shader/55462)

<div class="topic-metadata">

**Author:** [@Eric.J](https://forum.babylonjs.com/u/Eric.J)\
**Replies:** 7\
**Last updated:** [December 20, 2024, 12:27pm UTC](https://forum.babylonjs.com/t/how-to-quickly-read-data-from-a-compute-shader/55462 "2024-12-20T12:27:31Z")

</div>

I want to read data from a compute shader in the CPU side. I created a StorageBuffer whose length was just one and passed it to the compute shader. It will take about 20 ms to get the data which is too slow. Is there an…

---

## [Dispatching empty compute shader turns entire canvas transparent](https://forum.babylonjs.com/t/dispatching-empty-compute-shader-turns-entire-canvas-transparent/54919)

<div class="topic-metadata">

**Author:** [@Micah\_LaSala](https://forum.babylonjs.com/u/Micah_LaSala)\
**Replies:** 5\
**Last updated:** [November 23, 2024, 2:15am UTC](https://forum.babylonjs.com/t/dispatching-empty-compute-shader-turns-entire-canvas-transparent/54919 "2024-11-23T02:15:02Z")

</div>

https://playground.babylonjs.com/#FZORY6#1 Dispatching the compute shader in the above example turns the canvas completely transparent (only for frames that the shader was dispatched). The compute shader is empty, and d…

---

## [How to accurately sample textures in ComputeShader?](https://forum.babylonjs.com/t/how-to-accurately-sample-textures-in-computeshader/53747)

<div class="topic-metadata">

**Author:** [@Eric.J](https://forum.babylonjs.com/u/Eric.J)\
**Replies:** 3\
**Last updated:** [September 25, 2024, 6:31pm UTC](https://forum.babylonjs.com/t/how-to-accurately-sample-textures-in-computeshader/53747 "2024-09-25T18:31:07Z")

</div>

I want to sample a texture in ComputeShader. But the result is always a little different from the original texture. I tried to use my custom TextureSampler and changed the sampling mode, but still could not get the right…

---

## [How to change the default texture sampler in ComputeShader?](https://forum.babylonjs.com/t/how-to-change-the-default-texture-sampler-in-computeshader/53728)

<div class="topic-metadata">

**Author:** [@Eric.J](https://forum.babylonjs.com/u/Eric.J)\
**Replies:** 2\
**Last updated:** [September 25, 2024, 8:53am UTC](https://forum.babylonjs.com/t/how-to-change-the-default-texture-sampler-in-computeshader/53728 "2024-09-25T08:53:57Z")

</div>

How to change the default texture sampler in ComputeShader? When I changed it, I always got an error message. If I comment out these lines, it runs OK.

---

## [Why wireframe mode does not work when using setVerticesBuffer and setIndexBuffer? (webgpu)](https://forum.babylonjs.com/t/why-wireframe-mode-does-not-work-when-using-setverticesbuffer-and-setindexbuffer-webgpu/52027)

<div class="topic-metadata">

**Author:** [@victor](https://forum.babylonjs.com/u/victor)\
**Replies:** 3\
**Last updated:** [July 14, 2024, 10:09am UTC](https://forum.babylonjs.com/t/why-wireframe-mode-does-not-work-when-using-setverticesbuffer-and-setindexbuffer-webgpu/52027 "2024-07-14T10:09:21Z")

</div>

See the example here: Mesh.setVerticesBuffer webGPU test6 | Babylon.js Playground (babylonjs.com) If you set material.wireframe = true; everything disappears. No mesh is shown. Why? How to fix it?

---

## [WebGPU Real-Time Global Illumination](https://forum.babylonjs.com/t/webgpu-real-time-global-illumination/51680)

<div class="topic-metadata">

**Author:** [@Zuuhr](https://forum.babylonjs.com/u/Zuuhr)\
**Replies:** 6\
**Last updated:** [July 6, 2024, 4:36pm UTC](https://forum.babylonjs.com/t/webgpu-real-time-global-illumination/51680 "2024-07-06T16:36:31Z")

</div>

Hello there! :cat2: I wanted to share with you a project I finished a while ago and recently published. Here is the GitHub repo: GlobalIlumination-BabylonJS It’s a composition of several screen-space shaders that en…

---

## [Flickering effects when dynamically updating mesh data from storage buffers](https://forum.babylonjs.com/t/flickering-effects-when-dynamically-updating-mesh-data-from-storage-buffers/51218)

<div class="topic-metadata">

**Author:** [@karbo123](https://forum.babylonjs.com/u/karbo123)\
**Replies:** 6\
**Last updated:** [June 12, 2024, 6:41am UTC](https://forum.babylonjs.com/t/flickering-effects-when-dynamically-updating-mesh-data-from-storage-buffers/51218 "2024-06-12T06:41:02Z")

</div>

Summary: I observed some sorts of flickering effects when I am dynamically updating mesh data shared from storage buffers using functions like setIndexBuffer, setVerticesBuffer with a compute shader. I think it is a prob…

---

## [Problem Compute Shader output to be float32array type instead of rgba8unorm](https://forum.babylonjs.com/t/problem-compute-shader-output-to-be-float32array-type-instead-of-rgba8unorm/50381)

<div class="topic-metadata">

**Author:** [@JoseAlcaraz](https://forum.babylonjs.com/u/JoseAlcaraz)\
**Replies:** 6\
**Last updated:** [May 10, 2024, 10:28pm UTC](https://forum.babylonjs.com/t/problem-compute-shader-output-to-be-float32array-type-instead-of-rgba8unorm/50381 "2024-05-10T22:28:02Z")

</div>

Hi everyone! I’m new to compute shaders in BabylonJS and want to understand some foundational concepts. I want to develop a compute shader whose output is equal to the input. PG here. You can see the results in the bro…

---

## [Compute Shader Indirect Dispatching](https://forum.babylonjs.com/t/compute-shader-indirect-dispatching/49542)

<div class="topic-metadata">

**Author:** [@stefnotch](https://forum.babylonjs.com/u/stefnotch)\
**Replies:** 6\
**Last updated:** [April 11, 2024, 10:13am UTC](https://forum.babylonjs.com/t/compute-shader-indirect-dispatching/49542 "2024-04-11T10:13:47Z")

</div>

Babylon.js’s compute shader API offers a “dispatch” method. For a project that my team is working on, we would need an indirect dispatch method. That corresponds to Would it be reasonable to add such an API? If yes, …

---

## [Wondering performance / hardware limits on # of compute shaders](https://forum.babylonjs.com/t/wondering-performance-hardware-limits-on-of-compute-shaders/47371)

<div class="topic-metadata">

**Author:** [@slin](https://forum.babylonjs.com/u/slin)\
**Replies:** 1\
**Last updated:** [January 21, 2024, 8:25pm UTC](https://forum.babylonjs.com/t/wondering-performance-hardware-limits-on-of-compute-shaders/47371 "2024-01-21T20:25:08Z")

</div>

Hello, I have several mesh instances managed by 1/2 compute shaders. I am thinking to do a clean up / refactoring so that each mesh type is associated with its own compute shader. Also I need to do it because I was hit …

---

## [Data transfer from compute shader to renderer](https://forum.babylonjs.com/t/data-transfer-from-compute-shader-to-renderer/45576)

<div class="topic-metadata">

**Author:** [@Hanesu](https://forum.babylonjs.com/u/Hanesu)\
**Replies:** 16\
**Last updated:** [December 7, 2023, 4:25pm UTC](https://forum.babylonjs.com/t/data-transfer-from-compute-shader-to-renderer/45576 "2023-12-07T16:25:33Z")

</div>

When I started learning about compute-shaders a few weeks ago, I looked at the Babylon examples in the docs and realized that I should first get a basic idea of WebGPU and WGSL to understand what is going on. Now I have…

---

## [How to keep buffers on the GPU when using compute shaders for instancing or vertex data generation](https://forum.babylonjs.com/t/how-to-keep-buffers-on-the-gpu-when-using-compute-shaders-for-instancing-or-vertex-data-generation/45951)

<div class="topic-metadata">

**Author:** [@CrashMaster](https://forum.babylonjs.com/u/CrashMaster)\
**Replies:** 10\
**Last updated:** [November 27, 2023, 9:38pm UTC](https://forum.babylonjs.com/t/how-to-keep-buffers-on-the-gpu-when-using-compute-shaders-for-instancing-or-vertex-data-generation/45951 "2023-11-27T21:38:09Z")

</div>

Hello everyone, I have been learning the ways of compute shaders recently, and I am now using them to generate an instance buffer like in this PG: The compute shader creates an instance buffer on the GPU, then it get…

---

## [Is there a performance difference between these two methods of buffer swapping?](https://forum.babylonjs.com/t/is-there-a-performance-difference-between-these-two-methods-of-buffer-swapping/45699)

<div class="topic-metadata">

**Author:** [@christian](https://forum.babylonjs.com/u/christian)\
**Replies:** 2\
**Last updated:** [November 15, 2023, 1:41pm UTC](https://forum.babylonjs.com/t/is-there-a-performance-difference-between-these-two-methods-of-buffer-swapping/45699 "2023-11-15T13:41:20Z")

</div>

The example given in the playground found on the Babylon page about compute shaders shows a buffer swap implemented by creating two nearly identical compute shaders, with the only difference being the order of the buffer…

---

## [About entryPoint for compute shader](https://forum.babylonjs.com/t/about-entrypoint-for-compute-shader/43876)

<div class="topic-metadata">

**Author:** [@qq2315137135](https://forum.babylonjs.com/u/qq2315137135)\
**Replies:** 3\
**Last updated:** [September 6, 2023, 11:09am UTC](https://forum.babylonjs.com/t/about-entrypoint-for-compute-shader/43876 "2023-09-06T11:09:16Z")

</div>

I noticed that the entryPoint of the babylonjs compute shader is “main”, and it doesn’t seem to be able to be changed. Look at this site compute.toys. He marks two functions with “@compute”. Then executes these two fun…

---

## [WebGPU - Compute shader experiments](https://forum.babylonjs.com/t/webgpu-compute-shader-experiments/41361)

<div class="topic-metadata">

**Author:** [@jtsorlinis](https://forum.babylonjs.com/u/jtsorlinis)\
**Replies:** 4\
**Last updated:** [July 19, 2023, 12:55am UTC](https://forum.babylonjs.com/t/webgpu-compute-shader-experiments/41361 "2023-07-19T00:55:34Z")

</div>

Been having some fun with compute shaders since WebGPU shipped with Chrome stable and have made a few demos/projects. 2D/3D Boids - WebGPU Boids The slider is exponential so you can get up to 67 million Boids in 2d at …

---

## [Array\<vec3\<f32\>\>](https://forum.babylonjs.com/t/array-vec3-f32/42134)

<div class="topic-metadata">

**Author:** [@mingno6](https://forum.babylonjs.com/u/mingno6)\
**Replies:** 4\
**Last updated:** [July 4, 2023, 1:01pm UTC](https://forum.babylonjs.com/t/array-vec3-f32/42134 "2023-07-04T13:01:22Z")

</div>

var createScene = function () { var scene = new BABYLON.Scene(engine); var camera = new BABYLON.ArcRotateCamera("Camera", Math.PI / 2, Math.PI / 2, 2, BABYLON.Vector3.Zero(), scene); camera.attachControl(canv…

---

## [Compute Shaders Order Execution](https://forum.babylonjs.com/t/compute-shaders-order-execution/41412)

<div class="topic-metadata">

**Author:** [@deadpe5](https://forum.babylonjs.com/u/deadpe5)\
**Replies:** 30\
**Last updated:** [June 28, 2023, 8:33pm UTC](https://forum.babylonjs.com/t/compute-shaders-order-execution/41412 "2023-06-28T20:33:08Z")

</div>

Hello, everyone. Sorry, if this question is silly or was already answered, but is it possible to control compute shaders order execution, to call next compute shader only when previous done his work? I am trying to make …

---

## [DrawWrapper for shadow map?](https://forum.babylonjs.com/t/drawwrapper-for-shadow-map/41468)

<div class="topic-metadata">

**Author:** [@slin](https://forum.babylonjs.com/u/slin)\
**Replies:** 8\
**Last updated:** [June 10, 2023, 10:34pm UTC](https://forum.babylonjs.com/t/drawwrapper-for-shadow-map/41468 "2023-06-10T22:34:14Z")

</div>

Hi @Evgeni\_Popov, This is a follow up issue I am facing from what you helped me (Dynamic size of instance count). I notice each render pass has a draw wrapper. I was able to setup 2 cameras, and sync the instance count …

---

## [Newbie question about @workgroup\_size](https://forum.babylonjs.com/t/newbie-question-about-workgroup-size/41363)

<div class="topic-metadata">

**Author:** [@deadpe5](https://forum.babylonjs.com/u/deadpe5)\
**Replies:** 1\
**Last updated:** [June 5, 2023, 8:16am UTC](https://forum.babylonjs.com/t/newbie-question-about-workgroup-size/41363 "2023-06-05T08:16:05Z")

</div>

Hello everyone. I’m new to webGPU and compute shaders and want to ask how to determine size of workgroup and what these values are used for. Also, do the values of @workgroup\_size correspond the values (x, y, z) I pass t…

---

## [Dynamic size of instance count](https://forum.babylonjs.com/t/dynamic-size-of-instance-count/40839)

<div class="topic-metadata">

**Author:** [@slin](https://forum.babylonjs.com/u/slin)\
**Replies:** 10\
**Last updated:** [May 20, 2023, 2:46pm UTC](https://forum.babylonjs.com/t/dynamic-size-of-instance-count/40839 "2023-05-20T14:46:43Z")

</div>

I have a storage buffer, and I use compute shader to create position of a number of mesh instances. The storage buffer has a fixed size to store positions of mesh instances. But the number of visible instances (\<= fixed…
