Files
Vulkan-Samples/shaders/synchronization_2/glsl/particle_integrate.comp
T
2025-09-04 10:54:47 +08:00

48 lines
1.1 KiB
Plaintext

#version 450
/* Copyright (c) 2019-2024, Sascha Willems
*
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 the "License";
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
struct Particle
{
vec4 pos;
vec4 vel;
};
// Binding 0 : Position storage buffer
layout(std140, binding = 0) buffer Pos
{
Particle particles[ ];
};
layout (local_size_x_id = 0) in;
layout (binding = 1) uniform UBO
{
float deltaT;
int particleCount;
} ubo;
#define TIME_FACTOR 0.05
void main()
{
int index = int(gl_GlobalInvocationID);
vec4 position = particles[index].pos;
vec4 velocity = particles[index].vel;
position += ubo.deltaT * TIME_FACTOR * velocity;
particles[index].pos = position;
}