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

[#111] increase numerical stability

parent 6bae5745
No related branches found
No related tags found
1 merge request!95Resolve "Wassersimulation mit Interaktion"
...@@ -36,7 +36,7 @@ layout( push_constant ) uniform constants{ ...@@ -36,7 +36,7 @@ layout( push_constant ) uniform constants{
float poly6(float r) float poly6(float r)
{ {
return (315.f/(64.f*PI*pow(h, 9)) * pow((pow(h,2)-pow(r,2)), 3)) * int(0<=r && r<=h); return (315.f * pow((pow(h,2)-pow(r,2)), 3)/(64.f*PI*pow(h, 9))) * int(0<=r && r<=h);
} }
float densitySum = 0.f; float densitySum = 0.f;
...@@ -57,8 +57,8 @@ void main() { ...@@ -57,8 +57,8 @@ void main() {
densitySum += mass * poly6(dist); densitySum += mass * poly6(dist);
} }
} }
outParticle[id].density = max(densitySum, 0.001f); outParticle[id].density = max(densitySum,0.0000001f);
outParticle[id].pressure = max((densitySum - offset), 0) * gasConstant; outParticle[id].pressure = max((densitySum - offset), 0.0000001f) * gasConstant;
outParticle[id].position = inParticle[id].position; outParticle[id].position = inParticle[id].position;
outParticle[id].velocity = inParticle[id].velocity; outParticle[id].velocity = inParticle[id].velocity;
outParticle[id].force = inParticle[id].force; outParticle[id].force = inParticle[id].force;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment