Skip to content

Commit

Permalink
viscosity force fix
Browse files Browse the repository at this point in the history
Add viscosity to velocities once, not at every iteration.
  • Loading branch information
stndbye authored Dec 3, 2023
1 parent 2e2dd4f commit 8591e6b
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions Assets/Scripts/Sim 3D/Compute/FluidSim3D.compute
Original file line number Diff line number Diff line change
Expand Up @@ -265,9 +265,8 @@ void CalculateViscosity (uint3 id : SV_DispatchThreadID)
float3 neighbourVelocity = Velocities[neighbourIndex];
viscosityForce += (neighbourVelocity - velocity) * SmoothingKernelPoly6(dst, smoothingRadius);
}

Velocities[id.x] += viscosityForce * viscosityStrength * deltaTime;
}
Velocities[id.x] += viscosityForce * viscosityStrength * deltaTime;
}

[numthreads(NumThreads, 1, 1)]
Expand All @@ -277,4 +276,4 @@ void UpdatePositions(uint3 id : SV_DispatchThreadID)

Positions[id.x] += Velocities[id.x] * deltaTime;
ResolveCollisions(id.x);
}
}

0 comments on commit 8591e6b

Please sign in to comment.