Skip to content
Snippets Groups Projects
Unverified Commit 817e6bfe authored by TheJackiMonster's avatar TheJackiMonster
Browse files

Added proper size distribtion on explosion

parent ed21dd0e
No related branches found
No related tags found
1 merge request!106Created initial firework project
......@@ -73,6 +73,7 @@ void main() {
}
vec3 velocity = normalize(direction) * events[event_id].velocity;
float size = events[event_id].size;
if (events[event_id].parent < events.length()) {
const uint spawnId = events[events[event_id].parent].pad0;
......@@ -80,12 +81,15 @@ void main() {
if (spawnId < particles.length()) {
particles[id].position = particles[spawnId].position;
velocity += particles[spawnId].velocity;
size = particles[spawnId].size;
}
}
const float split = pow(1.0f / events[event_id].count, 1.0f / 3.0f);
particles[id].lifetime = events[event_id].lifetime;
particles[id].velocity = velocity;
particles[id].size = events[event_id].size;
particles[id].size = size * split;
particles[id].color = events[event_id].color;
particles[id].mass = events[event_id].mass / events[event_id].count;
......
......@@ -16,6 +16,7 @@ layout( push_constant ) uniform constants{
};
const float g = 9.81;
const float friction = 0.001f;
void main() {
uint id = gl_GlobalInvocationID.x;
......@@ -34,8 +35,10 @@ void main() {
lifetime = 0.0f;
}
const float fading = 1.0f / (1.0f + friction);
position = position + velocity * dt;
velocity = velocity + vec3(0.0f, -g, 0.0f) * dt;
velocity = velocity * fading + vec3(0.0f, -g, 0.0f) * dt;
particles[id].position = position;
particles[id].lifetime = lifetime;
......
......@@ -174,7 +174,7 @@ int main(int argc, const char **argv) {
1.0f,
1.0f,
0.1f,
0.5f,
0.0f
);
......@@ -191,7 +191,7 @@ int main(int argc, const char **argv) {
10.0f,
1.0f,
0.05f,
0.0f,
0.0f
);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment