Skip to content
Snippets Groups Projects
Verified Commit 40f5932d authored by Josch Morgenstern's avatar Josch Morgenstern
Browse files

[#111] add params in push constant to updateData shader

parent 426782d5
No related branches found
No related tags found
1 merge request!95Resolve "Wassersimulation mit Interaktion"
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
#extension GL_ARB_separate_shader_objects : enable #extension GL_ARB_separate_shader_objects : enable
#extension GL_GOOGLE_include_directive : enable #extension GL_GOOGLE_include_directive : enable
#include "particle_params.inc"
layout(local_size_x = 256) in; layout(local_size_x = 256) in;
struct Particle struct Particle
...@@ -28,11 +26,20 @@ layout(std430, binding = 1) writeonly buffer buffer_outParticle ...@@ -28,11 +26,20 @@ layout(std430, binding = 1) writeonly buffer buffer_outParticle
}; };
layout( push_constant ) uniform constants{ layout( push_constant ) uniform constants{
float deltaTime; float h;
float mass;
float gasConstant;
float offset;
float gravity;
float viscosity;
float ABSORBTION;
float dt;
vec3 gravityDir;
float particleCount; float particleCount;
}; };
void main() { void main() {
uint id = gl_GlobalInvocationID.x; uint id = gl_GlobalInvocationID.x;
if(id >= int(particleCount)) if(id >= int(particleCount))
...@@ -42,48 +49,61 @@ void main() { ...@@ -42,48 +49,61 @@ void main() {
vec3 accel = inParticle[id].force / inParticle[id].density; vec3 accel = inParticle[id].force / inParticle[id].density;
vec3 vel_new = inParticle[id].velocity + (dt * accel); vec3 vel_new = inParticle[id].velocity + (dt * accel);
vec3 out_force = inParticle[id].force;
float out_density = inParticle[id].density;
float out_pressure = inParticle[id].pressure;
if (length(vel_new) > 100.f)
{
vel_new = normalize(vel_new)*50;
out_density = 0.01f;
out_pressure = 0.01f;
out_force = gravity * vec3(-gravityDir.x,gravityDir.y,gravityDir.z);
}
vec3 pos_new = inParticle[id].position + (dt * vel_new); vec3 pos_new = inParticle[id].position + (dt * vel_new);
// Überprüfe Randbedingungen x // Überprüfe Randbedingungen x
if (inParticle[id].position.x < -1.0) if (inParticle[id].position.x < -1.0)
{ {
vel_new.x *= -ABSORBTION; vel_new = reflect(vel_new.xyz, vec3(1.f,0.f,0.f)) * ABSORBTION;
pos_new.x = -1.0; pos_new.x = -1.0 + 0.01f;
} }
else if (inParticle[id].position.x > 1.0) else if (inParticle[id].position.x > 1.0)
{ {
vel_new.x *= -ABSORBTION; vel_new = reflect(vel_new,vec3(1.f,0.f,0.f)) * ABSORBTION;
pos_new.x = 1.0; pos_new.x = 1.0 - 0.01f;
} }
// Überprüfe Randbedingungen y // Überprüfe Randbedingungen y
if (inParticle[id].position.y < -1.0) if (inParticle[id].position.y < -1.0)
{ {
vel_new.y *= -ABSORBTION; vel_new = reflect(vel_new,vec3(0.f,1.f,0.f)) * ABSORBTION;
pos_new.y = -1.0; pos_new.y = -1.0 + 0.01f;
} }
else if (inParticle[id].position.y > 1.0) else if (inParticle[id].position.y > 1.0)
{ {
vel_new.y *= -ABSORBTION; vel_new = reflect(vel_new,vec3(0.f,1.f,0.f)) * ABSORBTION;
pos_new.y = 1.0; pos_new.y = 1.0 - 0.01f;
} }
// Überprüfe Randbedingungen z // Überprüfe Randbedingungen z
if (inParticle[id].position.z < -1.0 ) if (inParticle[id].position.z < -1.0 )
{ {
vel_new.z *= -ABSORBTION; vel_new = reflect(vel_new,vec3(0.f,0.f,1.f)) * ABSORBTION;
pos_new.z = -1.0; pos_new.z = -1.0 + 0.01f;
} }
else if (inParticle[id].position.z > 1.0 ) else if (inParticle[id].position.z > 1.0 )
{ {
vel_new.z *= -ABSORBTION; vel_new = reflect(vel_new,vec3(0.f,0.f,1.f)) * ABSORBTION;
pos_new.z = 1.0; pos_new.z = 1.0 - 0.01f;
} }
outParticle[id].force = inParticle[id].force; outParticle[id].force = out_force;
outParticle[id].density = inParticle[id].density; outParticle[id].density = out_density;
outParticle[id].pressure = inParticle[id].pressure; outParticle[id].pressure = out_pressure;
outParticle[id].position = pos_new; outParticle[id].position = pos_new;
outParticle[id].velocity = vel_new; outParticle[id].velocity = vel_new;
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment