67 if (r2 >= h2 || r2 <= 0.f)
return 0.f;
69 return 315.f / (64.f * 3.14159265358979f * std::pow(
h, 9.f)) *
q *
q *
q;
79 float r2 = glm::dot(
dx,
dx);
80 if (r2 >=
h *
h || r2 <= 1e-12f)
return glm::vec3(0.f);
81 float r = std::sqrt(r2);
83 float k = -45.f / (3.14159265358979f * std::pow(
h, 6.f));
84 return dx * (k *
q *
q /
r);
94 if (
r >=
h ||
r <= 1e-9f)
return 0.f;
95 return 45.f / (3.14159265358979f * std::pow(
h, 6.f)) * (1.f -
r /
h);
105 if (
r >=
h ||
r <= 1e-9f)
return 0.f;
106 const float q =
h -
r;
107 return 32.f / (3.14159265358979f * std::pow(
h, 9.f)) *
q *
q *
q *
r *
r *
r;
114 float s = glm::length(
v);
115 if (
s > maxSpeed &&
s > 1e-9f)
return v * (maxSpeed /
s);
std::array< double, 10 > q
GLSL compute kernels for the GPU surface-flow solver.
float fluidPoly6(float r2, float h)
Poly6 kernel value W(r2, h).
float fluidViscLaplacian(float r, float h)
Viscosity Laplacian kernel value.
float fluidCohesionKernel(float r, float h)
Akinci-style cohesion kernel C(r) for droplet surface tension.
glm::vec3 fluidClampSpeed(const glm::vec3 &v, float maxSpeed)
Clamp a vector's magnitude to maxSpeed.
glm::vec3 fluidSpikyGrad(const glm::vec3 &dx, float h)
Spiky gradient of the kernel w.r.t. particle i position.
Tuning knobs of one fluid simulation.
float damping
Linear air damping applied each substep.
float restDensity
Rest density; normalized to 1.
float supportRadius
SPH support radius h (kernel cutoff), typically 4x particleRadius.
float particleRadius
Resting particle radius in world units.
float adhesion
Fluid-surface adhesion strength (contact angle / sticking).
int pbfIterations
PBF density-constraint relaxation passes per substep.
float cohesion
Fluid-fluid cohesion strength (droplet formation).
int iterations
Solver substeps per call to step(dt).
float viscosity
XSPH viscosity strength (0 = inviscid).
float maxVelocity
Velocity clamp after integration.
float yieldStress
Bingham yield stress: below this shear rate particles "freeze".
glm::vec3 gravity
Gravity vector in world units / s^2.
One simulated particle (CPU reference layout).