procedural-3d-engine/data/hlsl/computenbody/particle_integrate.comp
Ben Clayton cce75f1859 Add shaders re-implemented in HLSL
These were written against the shaders at revision eddd724e7.
There have been changes made since then, which will need to be mirrored.

See `data/hlsl/README.md` for the current status of each sample.
2020-05-21 12:58:13 +01:00

28 lines
No EOL
543 B
Text

// Copyright 2020 Google LLC
struct Particle
{
float4 pos;
float4 vel;
};
// Binding 0 : Position storage buffer
RWStructuredBuffer<Particle> particles : register(u0);
struct UBO
{
float deltaT;
int particleCount;
};
cbuffer ubo : register(b1) { UBO ubo; }
[numthreads(256, 1, 1)]
void main(uint3 GlobalInvocationID : SV_DispatchThreadID)
{
int index = int(GlobalInvocationID.x);
float4 position = particles[index].pos;
float4 velocity = particles[index].vel;
position += ubo.deltaT * velocity;
particles[index].pos = position;
}