Permalink
Browse files

0.3 candidate

  • Loading branch information...
lmontoute committed Feb 4, 2019
1 parent 9ab1940 commit b13278a4d6ebcef857b67daefce2324d2c491569
Showing with 29,970 additions and 3,656 deletions.
  1. +1 −1 Editor/Blocks/Collision/CollisionAABox.cs
  2. +1 −1 Editor/Blocks/Collision/CollisionCylinder.cs
  3. +1 −1 Editor/Blocks/Collision/CollisionDepth.cs
  4. +1 −1 Editor/Blocks/Collision/CollisionPlane.cs
  5. +1 −1 Editor/Blocks/Collision/CollisionSDF.cs
  6. +1 −1 Editor/Blocks/Collision/CollisionSphere.cs
  7. +85 −95 Editor/Blocks/Solver/CalculateForces.cs
  8. +15 −27 Editor/Blocks/Solver/DensityPressure.cs
  9. +146 −37 Editor/Blocks/Solver/FluvioFXBlock.cs
  10. +358 −18 Editor/Blocks/Solver/InitializeSolver.cs
  11. +5 −2 Editor/Blocks/Solver/IntegrateParticles.cs
  12. +33 −49 Editor/Blocks/Solver/NeighborSearch.cs
  13. +16 −12 Editor/Blocks/Solver/SpacePartitioning.cs
  14. +17 −28 Editor/Blocks/Solver/SurfaceNormal.cs
  15. +5 −8 Editor/Integrators/Integrator.cs
  16. +1 −2 Editor/Integrators/VelocityVerlet.cs
  17. +2 −2 Editor/Integrators/Verlet.cs
  18. +1 −1 Editor/Operators/DensityOverRange.cs
  19. +0 −224 Editor/Operators/FluidToSolverData.cs
  20. +77 −12 Editor/ShaderPostprocessor/ShaderPostprocessor.cs
  21. +28,881 −2,888 Editor/Templates/Fluid Particle System.vfx
  22. +4 −19 Editor/Types/Fluid.cs
  23. +0 −86 Editor/Types/SolverData.cs
  24. +0 −11 Editor/Types/SolverData.cs.meta
  25. +24 −0 Editor/Types/SolverDataParameters.cs
  26. +1 −1 Editor/{Operators/FluidToSolverData.cs.meta → Types/SolverDataParameters.cs.meta}
  27. +83 −4 Editor/Utils/FluvioFXAttribute.cs
  28. +49 −18 Editor/Utils/FluvioFXCollisionUtility.cs
  29. +11 −0 Editor/Utils/FluvioFXSettings.cs
  30. 0 Editor/Utils/{FluvioSettings.cs.meta → FluvioFXSettings.cs.meta}
  31. +0 −5 Editor/Utils/FluvioSettings.cs
  32. +92 −8 Install/FluvioFXInstall.cs
  33. +55 −90 Shaders/FluvioCompute.cginc
  34. +3 −3 package.json
@@ -38,7 +38,7 @@ public override string name
protected override IEnumerable<VFXPropertyWithValue> inputProperties =>
FluvioFXCollisionUtility.GetInputProperties(this, base.inputProperties);
public override IEnumerable<VFXAttributeInfo> attributes =>
FluvioFXCollisionUtility.GetAttributes(base.attributes);
FluvioFXCollisionUtility.GetAttributes(this, base.attributes);

public override string source =>
FluvioFXCollisionUtility.GetCollisionSource(
@@ -38,7 +38,7 @@ public override string name
protected override IEnumerable<VFXPropertyWithValue> inputProperties =>
FluvioFXCollisionUtility.GetInputProperties(this, base.inputProperties);
public override IEnumerable<VFXAttributeInfo> attributes =>
FluvioFXCollisionUtility.GetAttributes(base.attributes);
FluvioFXCollisionUtility.GetAttributes(this, base.attributes);

public override string source =>
FluvioFXCollisionUtility.GetCollisionSource(
@@ -38,7 +38,7 @@ public override string name
protected override IEnumerable<VFXPropertyWithValue> inputProperties =>
FluvioFXCollisionUtility.GetInputProperties(this, base.inputProperties);
public override IEnumerable<VFXAttributeInfo> attributes =>
FluvioFXCollisionUtility.GetAttributes(base.attributes);
FluvioFXCollisionUtility.GetAttributes(this, base.attributes);

public override string source =>
FluvioFXCollisionUtility.GetCollisionSource(
@@ -38,7 +38,7 @@ public override string name
protected override IEnumerable<VFXPropertyWithValue> inputProperties =>
FluvioFXCollisionUtility.GetInputProperties(this, base.inputProperties);
public override IEnumerable<VFXAttributeInfo> attributes =>
FluvioFXCollisionUtility.GetAttributes(base.attributes);
FluvioFXCollisionUtility.GetAttributes(this, base.attributes);

public override string source =>
FluvioFXCollisionUtility.GetCollisionSource(
@@ -38,7 +38,7 @@ public override string name
protected override IEnumerable<VFXPropertyWithValue> inputProperties =>
FluvioFXCollisionUtility.GetInputProperties(this, base.inputProperties);
public override IEnumerable<VFXAttributeInfo> attributes =>
FluvioFXCollisionUtility.GetAttributes(base.attributes);
FluvioFXCollisionUtility.GetAttributes(this, base.attributes);

public override string source =>
FluvioFXCollisionUtility.GetCollisionSource(
@@ -38,7 +38,7 @@ public override string name
protected override IEnumerable<VFXPropertyWithValue> inputProperties =>
FluvioFXCollisionUtility.GetInputProperties(this, base.inputProperties);
public override IEnumerable<VFXAttributeInfo> attributes =>
FluvioFXCollisionUtility.GetAttributes(base.attributes);
FluvioFXCollisionUtility.GetAttributes(this, base.attributes);

public override string source =>
FluvioFXCollisionUtility.GetCollisionSource(
@@ -8,104 +8,104 @@
using UnityEngine.Experimental.VFX;

namespace Thinksquirrel.FluvioFX.Editor.Blocks
{
[VFXInfo(category = "FluvioFX/Solver")]
class CalculateForces : FluvioFXBlock
{
[VFXInfo(category = "FluvioFX/Solver")]
class CalculateForces : FluvioFXBlock
[VFXSetting]
public bool SurfaceTension = true;
[VFXSetting]
public bool Gravity = true;
[VFXSetting]
public bool BuoyancyForce = true;

public override string name
{
get
{
[VFXSetting]
public bool SurfaceTension = true;
[VFXSetting]
public bool Gravity = true;
[VFXSetting]
public bool BuoyancyForce = true;

public override string name
return "Calculate Forces";
}
}
public override IEnumerable<VFXAttributeInfo> attributes
{
get
{
yield return new VFXAttributeInfo(FluvioFXAttribute.NeighborCount, VFXAttributeMode.Read);
yield return new VFXAttributeInfo(VFXAttribute.Position, VFXAttributeMode.Read);
yield return new VFXAttributeInfo(VFXAttribute.Velocity, VFXAttributeMode.Read);
yield return new VFXAttributeInfo(VFXAttribute.Mass, VFXAttributeMode.Read);
yield return new VFXAttributeInfo(FluvioFXAttribute.DensityPressure, VFXAttributeMode.Read);
if (SurfaceTension)
{
get
{
return "Calculate Forces";
}
}
public override IEnumerable<VFXAttributeInfo> attributes
{
get
{
yield return new VFXAttributeInfo(VFXAttribute.Position, VFXAttributeMode.Read);
if (hasLifetime)
{
yield return new VFXAttributeInfo(VFXAttribute.Alive, VFXAttributeMode.Read);
}
yield return new VFXAttributeInfo(VFXAttribute.Velocity, VFXAttributeMode.Read);
yield return new VFXAttributeInfo(VFXAttribute.Mass, VFXAttributeMode.Read);
// yield return new VFXAttributeInfo(FluvioFXAttribute.NeighborCount, VFXAttributeMode.Read);
yield return new VFXAttributeInfo(FluvioFXAttribute.DensityPressure, VFXAttributeMode.Read);
if (SurfaceTension)
{
yield return new VFXAttributeInfo(FluvioFXAttribute.Normal, VFXAttributeMode.Read);
}
yield return new VFXAttributeInfo(FluvioFXAttribute.Force, VFXAttributeMode.ReadWrite);
}
yield return new VFXAttributeInfo(FluvioFXAttribute.Normal, VFXAttributeMode.Read);
}
yield return new VFXAttributeInfo(FluvioFXAttribute.Force, VFXAttributeMode.ReadWrite);
}
}

protected override IEnumerable<string> filteredOutSettings
{
get
{
if (!Gravity)
yield return nameof(BuoyancyForce);
}
}

protected internal override SolverDataParameters solverDataParameters
{
get
{
var solverDataParams =
SolverDataParameters.Fluid_Viscosity |
SolverDataParameters.KernelFactors |
SolverDataParameters.KernelSize;

private IEnumerable<string> defines
if (SurfaceTension)
{
get
{
if (SurfaceTension) yield return "#define FLUVIO_SURFACE_TENSION_ENABLED 1";
if (Gravity)
{
yield return "#define FLUVIO_GRAVITY_ENABLED 1";
if (BuoyancyForce) yield return "#define FLUVIO_BUOYANCY_FORCE_ENABLED 1";
}
}
solverDataParams |= SolverDataParameters.Fluid_SurfaceTension;
}
protected override IEnumerable<string> filteredOutSettings
if (Gravity)
{
get
solverDataParams |= SolverDataParameters.Gravity;

if (BuoyancyForce)
{
if (!Gravity)
yield return nameof(BuoyancyForce);
solverDataParams |=
SolverDataParameters.Fluid_Density |
SolverDataParameters.Fluid_BuoyancyCoefficient;
}
}

public override string source => $@"
{string.Join("\n", defines)}
float3 dist, f, invNeighborDensity;
float scalar;
return solverDataParams;
}
}

#ifdef FLUVIO_INDEX_GRID
uint neighborIndex;
public override string source => $@"{CheckAlive()}
float3 dist, f, invNeighborDensity;
float lenSq, len, len3, diffSq, diff, scalar;
for (uint j = 0; j < neighborCount; ++j)
{{
neighborIndex = GetNeighborIndex(solverData_Tex, solverData_TexSize, index, j);
#else
float distLenSq;
for (uint neighborIndex = 0; neighborIndex < nbMax; ++neighborIndex)
{{
if (index == neighborIndex) continue;
{(hasLifetime ? FluvioFXAttribute.GetLoadAttributeCode(this, VFXAttribute.Alive, "neighborAlive", "neighborIndex") : "")}
{(hasLifetime ? "if (!neighborAlive) continue;" : "")}
#endif

{FluvioFXAttribute.GetLoadAttributeCode(this, VFXAttribute.Position, "neighborPosition", "neighborIndex")}
{FluvioFXAttribute.GetLoadAttributeCode(this, VFXAttribute.Mass, "neighborMass", "neighborIndex")}
{FluvioFXAttribute.GetLoadAttributeCode(this, VFXAttribute.Velocity, "neighborVelocity", "neighborIndex")}
{FluvioFXAttribute.GetLoadAttributeCode(
this,
FluvioFXAttribute.DensityPressure,
"neighborDensityPressure",
"neighborIndex")}
{LoadNeighbor("neighborIndex", "index", "j")}
{Load(VFXAttribute.Position, "neighborPosition", "neighborIndex")}
{Load(VFXAttribute.Mass, "neighborMass", "neighborIndex")}
{Load(VFXAttribute.Velocity, "neighborVelocity", "neighborIndex")}
{Load(FluvioFXAttribute.DensityPressure, "neighborDensityPressure", "neighborIndex")}
dist = position - neighborPosition;
#ifndef FLUVIO_INDEX_GRID
distLenSq = dot(dist, dist);
if (distLenSq >= solverData_KernelSize.y) continue;
#endif
// For kernels
lenSq = dot(dist, dist);
len = sqrt(lenSq);
len3 = len * len * len;
diffSq = solverData_KernelSize.y - lenSq;
diff = solverData_KernelSize.x - len;
// Pressure term
scalar = neighborMass
* (densityPressure.y + neighborDensityPressure.y) / (neighborDensityPressure.x * 2.0f);
f = SpikyCalculateGradient(dist, solverData_KernelFactors.y, solverData_KernelSize.x);
f = SpikyCalculateGradient(dist, diff, len, solverData_KernelFactors.y);
f *= scalar;
force -= f;
@@ -114,41 +114,31 @@ protected override IEnumerable<string> filteredOutSettings
// Viscosity term
scalar = neighborMass
* ViscosityCalculateLaplacian(
dist,
solverData_KernelFactors.z,
solverData_KernelSize.z,
solverData_KernelSize.x)
* ViscosityCalculateLaplacian(diff, solverData_KernelSize.z, solverData_KernelFactors.z)
* invNeighborDensity;
f = neighborVelocity - velocity;
f *= scalar * solverData_Fluid_Viscosity;
force += f;
#ifdef FLUVIO_SURFACE_TENSION_ENABLED
// Surface tension term (external)
{(SurfaceTension ? $@"// Surface tension term (external)
if (normal.w > FLUVIO_PI && normal.w < FLUVIO_TAU)
{{
scalar = neighborMass
* Poly6CalculateLaplacian(dist, solverData_KernelFactors.x, solverData_KernelSize.y)
* Poly6CalculateLaplacian(lenSq, diffSq, solverData_KernelFactors.x)
* solverData_Fluid_SurfaceTension
* 1.0f / neighborDensityPressure.x;

f = normal.xyz * scalar;
force -= f;
}}
#endif
}}" : "")}
}}

#ifdef FLUVIO_GRAVITY_ENABLED
// Gravity term (external)
{(Gravity ? $@"// Gravity term (external)
force += solverData_Gravity * mass;
#ifdef FLUVIO_BUOYANCY_FORCE_ENABLED
// Buoyancy term (external)
force += solverData_Gravity * solverData_Fluid_BuoyancyCoefficient * (densityPressure.x - solverData_Fluid_Density);
#endif
#endif
";
" : "")}
{(Gravity && BuoyancyForce ? $@"// Buoyancy term (external)
force += solverData_Gravity * solverData_Fluid_BuoyancyCoefficient * (densityPressure.x - solverData_Fluid_Density);" : "")}";
}
}
@@ -24,44 +24,32 @@ public override IEnumerable<VFXAttributeInfo> attributes
{
get
{
yield return new VFXAttributeInfo(FluvioFXAttribute.NeighborCount, VFXAttributeMode.Read);
yield return new VFXAttributeInfo(VFXAttribute.Position, VFXAttributeMode.Read);
if (hasLifetime)
{
yield return new VFXAttributeInfo(VFXAttribute.Alive, VFXAttributeMode.Read);
}
yield return new VFXAttributeInfo(VFXAttribute.Mass, VFXAttributeMode.Read);
// yield return new VFXAttributeInfo(FluvioFXAttribute.NeighborCount, VFXAttributeMode.Read);
yield return new VFXAttributeInfo(FluvioFXAttribute.DensityPressure, VFXAttributeMode.Write);
}
}
public override string source => $@"
protected internal override SolverDataParameters solverDataParameters =>
SolverDataParameters.Fluid_Density |
SolverDataParameters.Fluid_MinimumDensity |
SolverDataParameters.Fluid_GasConstant |
SolverDataParameters.KernelFactors |
SolverDataParameters.KernelSize;

public override string source => $@"{CheckAlive()}
float3 dist;
float density = 0;
float pressure;
#ifdef FLUVIO_INDEX_GRID
uint neighborIndex;
float pressure, diffSq;
for (uint j = 0; j < neighborCount; ++j)
{{
neighborIndex = GetNeighborIndex(solverData_Tex, solverData_TexSize, index, j);
#else
float distLenSq;
for (uint neighborIndex = 0; neighborIndex < nbMax; ++neighborIndex)
{{
if (index == neighborIndex) continue;
{(hasLifetime ? FluvioFXAttribute.GetLoadAttributeCode(this, VFXAttribute.Alive, "neighborAlive", "neighborIndex") : "")}
{(hasLifetime ? "if (!neighborAlive) continue;" : "")}
#endif
{FluvioFXAttribute.GetLoadAttributeCode(this, VFXAttribute.Position, "neighborPosition", "neighborIndex")}
{FluvioFXAttribute.GetLoadAttributeCode(this, VFXAttribute.Mass, "neighborMass", "neighborIndex")}
{LoadNeighbor("neighborIndex", "index", "j")}
{Load(VFXAttribute.Position, "neighborPosition", "neighborIndex")}
{Load(VFXAttribute.Mass, "neighborMass", "neighborIndex")}
dist = position - neighborPosition;
#ifndef FLUVIO_INDEX_GRID
distLenSq = dot(dist, dist);
if (distLenSq >= solverData_KernelSize.y) continue;
#endif
density += neighborMass * Poly6Calculate(dist, solverData_KernelFactors.x, solverData_KernelSize.y);
diffSq = solverData_KernelSize.y - dot(dist, dist);
density += neighborMass * Poly6Calculate(diffSq, solverData_KernelFactors.x);
}}
// Write to density/pressure
Oops, something went wrong.

0 comments on commit b13278a

Please sign in to comment.