Quantcast
Channel: Questions in topic: "compute shader"
Viewing all articles
Browse latest Browse all 287

Append and consume same compute buffer

$
0
0
Hi, I would like to know if it is possible to consume and append the same compute buffer. I have made a simple particle system with compute shaders, and I would like to implement a particle emmiter. For this, I have a first compute shader wich append my buffer of particle : #pragma kernel CSMain struct Particle { float3 position; float3 direction; float3 color; float time; }; AppendStructuredBuffer ParticleBuffer : register(u0); uint NumParticles; [numthreads(8,1,1)] // Create 8 particle each time void CSMain (uint3 id : SV_DispatchThreadID) { Particle p; p.color = float3(1.0, 0.0, 0.0); p.position = float3(0.0, 0.0, 0.0); // Will be random p.direction = float3(0.0, 1.0, 0.0); // Will be a random normalized vector p.time = 0.0; ParticleBuffer.Append(p); // Add the particle to the buffer } Then, in an other compute shader I consume the previous buffer, update the particle, and push it back into the buffer. Is it possible to bind the same buffer twice like this ? ConsumeStructuredBuffer ParticleBufferAppend : register( u0 ); AppendStructuredBuffer ParticleBufferConsume : register( u1 ); For now, the particle are well created, but it seems like there are not updated. Thanks for your help.

Viewing all articles
Browse latest Browse all 287

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>