Added slang shaders for compute nbody sample
This commit is contained in:
parent
00378d9760
commit
9ff0f35f24
3 changed files with 164 additions and 0 deletions
31
shaders/slang/computenbody/particle_integrate.slang
Normal file
31
shaders/slang/computenbody/particle_integrate.slang
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
/* Copyright (c) 2025, Sascha Willems
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
struct Particle
|
||||
{
|
||||
float4 pos;
|
||||
float4 vel;
|
||||
};
|
||||
// Binding 0 : Position storage buffer
|
||||
RWStructuredBuffer<Particle> particles;
|
||||
|
||||
struct UBO
|
||||
{
|
||||
float deltaT;
|
||||
int particleCount;
|
||||
};
|
||||
ConstantBuffer<UBO> ubo;
|
||||
|
||||
[shader("compute")]
|
||||
[numthreads(256, 1, 1)]
|
||||
void computeMain(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;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue