Permalink
Browse files

πŸš€

  • Loading branch information...
lmontoute committed Jan 7, 2019
0 parents commit 44aad844e27ed377bb0f3e8f10e7d51407e08ddf
Showing with 11,892 additions and 0 deletions.
  1. +34 βˆ’0 .gitignore
  2. +7 βˆ’0 .vscode/settings.json
  3. BIN Documentation/images/logo.png
  4. +3 βˆ’0 Documentation/index.md
  5. +44 βˆ’0 README.md
  6. +7 βˆ’0 README.md.meta
  7. +8 βˆ’0 com.thinksquirrel.fluviofx/Editor.meta
  8. +8 βˆ’0 com.thinksquirrel.fluviofx/Editor/Blocks.meta
  9. +94 βˆ’0 com.thinksquirrel.fluviofx/Editor/Blocks/CalculateForces.cs
  10. +11 βˆ’0 com.thinksquirrel.fluviofx/Editor/Blocks/CalculateForces.cs.meta
  11. +41 βˆ’0 com.thinksquirrel.fluviofx/Editor/Blocks/ClearData.cs
  12. +11 βˆ’0 com.thinksquirrel.fluviofx/Editor/Blocks/ClearData.cs.meta
  13. +81 βˆ’0 com.thinksquirrel.fluviofx/Editor/Blocks/DensityPressure.cs
  14. +11 βˆ’0 com.thinksquirrel.fluviofx/Editor/Blocks/DensityPressure.cs.meta
  15. +58 βˆ’0 com.thinksquirrel.fluviofx/Editor/Blocks/ExternalForces.cs
  16. +11 βˆ’0 com.thinksquirrel.fluviofx/Editor/Blocks/ExternalForces.cs.meta
  17. +51 βˆ’0 com.thinksquirrel.fluviofx/Editor/Blocks/FluvioFXBlock.cs
  18. +11 βˆ’0 com.thinksquirrel.fluviofx/Editor/Blocks/FluvioFXBlock.cs.meta
  19. +46 βˆ’0 com.thinksquirrel.fluviofx/Editor/Blocks/IndexGrid.cs
  20. +11 βˆ’0 com.thinksquirrel.fluviofx/Editor/Blocks/IndexGrid.cs.meta
  21. +66 βˆ’0 com.thinksquirrel.fluviofx/Editor/Blocks/IntegrateParticles.cs
  22. +11 βˆ’0 com.thinksquirrel.fluviofx/Editor/Blocks/IntegrateParticles.cs.meta
  23. +98 βˆ’0 com.thinksquirrel.fluviofx/Editor/Blocks/NeighborSearch.cs
  24. +11 βˆ’0 com.thinksquirrel.fluviofx/Editor/Blocks/NeighborSearch.cs.meta
  25. +77 βˆ’0 com.thinksquirrel.fluviofx/Editor/Blocks/SurfaceNormal.cs
  26. +11 βˆ’0 com.thinksquirrel.fluviofx/Editor/Blocks/SurfaceNormal.cs.meta
  27. +8 βˆ’0 com.thinksquirrel.fluviofx/Editor/Kernels.meta
  28. +17 βˆ’0 com.thinksquirrel.fluviofx/Editor/Kernels/Poly6Kernel.cs
  29. +11 βˆ’0 com.thinksquirrel.fluviofx/Editor/Kernels/Poly6Kernel.cs.meta
  30. +39 βˆ’0 com.thinksquirrel.fluviofx/Editor/Kernels/SmoothingKernel.cs
  31. +11 βˆ’0 com.thinksquirrel.fluviofx/Editor/Kernels/SmoothingKernel.cs.meta
  32. +17 βˆ’0 com.thinksquirrel.fluviofx/Editor/Kernels/SpikyKernel.cs
  33. +11 βˆ’0 com.thinksquirrel.fluviofx/Editor/Kernels/SpikyKernel.cs.meta
  34. +16 βˆ’0 com.thinksquirrel.fluviofx/Editor/Kernels/ViscosityKernel.cs
  35. +11 βˆ’0 com.thinksquirrel.fluviofx/Editor/Kernels/ViscosityKernel.cs.meta
  36. +8 βˆ’0 com.thinksquirrel.fluviofx/Editor/MenuItems.meta
  37. +39 βˆ’0 com.thinksquirrel.fluviofx/Editor/MenuItems/FluvioFXMenuItems.cs
  38. +11 βˆ’0 com.thinksquirrel.fluviofx/Editor/MenuItems/FluvioFXMenuItems.cs.meta
  39. +8 βˆ’0 com.thinksquirrel.fluviofx/Editor/Operators.meta
  40. +232 βˆ’0 com.thinksquirrel.fluviofx/Editor/Operators/SolverParameters.cs
  41. +11 βˆ’0 com.thinksquirrel.fluviofx/Editor/Operators/SolverParameters.cs.meta
  42. +8 βˆ’0 com.thinksquirrel.fluviofx/Editor/ShaderPostprocessor.meta
  43. +59 βˆ’0 com.thinksquirrel.fluviofx/Editor/ShaderPostprocessor/ShaderPostprocessor.cs
  44. +11 βˆ’0 com.thinksquirrel.fluviofx/Editor/ShaderPostprocessor/ShaderPostprocessor.cs.meta
  45. +8 βˆ’0 com.thinksquirrel.fluviofx/Editor/Templates.meta
  46. +9,024 βˆ’0 com.thinksquirrel.fluviofx/Editor/Templates/Fluid Particle System.vfx
  47. +7 βˆ’0 com.thinksquirrel.fluviofx/Editor/Templates/Fluid Particle System.vfx.meta
  48. +18 βˆ’0 com.thinksquirrel.fluviofx/Editor/Thinksquirrel.FluvioFX.Editor.asmdef
  49. +7 βˆ’0 com.thinksquirrel.fluviofx/Editor/Thinksquirrel.FluvioFX.Editor.asmdef.meta
  50. +8 βˆ’0 com.thinksquirrel.fluviofx/Editor/Utils.meta
  51. +28 βˆ’0 com.thinksquirrel.fluviofx/Editor/Utils/FluvioFXAttribute.cs
  52. +11 βˆ’0 com.thinksquirrel.fluviofx/Editor/Utils/FluvioFXAttribute.cs.meta
  53. +45 βˆ’0 com.thinksquirrel.fluviofx/Editor/Utils/PackageInfo.cs
  54. +11 βˆ’0 com.thinksquirrel.fluviofx/Editor/Utils/PackageInfo.cs.meta
  55. +422 βˆ’0 com.thinksquirrel.fluviofx/Editor/Utils/ReflectionHelpers.cs
  56. +11 βˆ’0 com.thinksquirrel.fluviofx/Editor/Utils/ReflectionHelpers.cs.meta
  57. +8 βˆ’0 com.thinksquirrel.fluviofx/Install.meta
  58. +244 βˆ’0 com.thinksquirrel.fluviofx/Install/FluvioFXInstall.cs
  59. +11 βˆ’0 com.thinksquirrel.fluviofx/Install/FluvioFXInstall.cs.meta
  60. +422 βˆ’0 com.thinksquirrel.fluviofx/Install/ReflectionHelpers.cs
  61. +11 βˆ’0 com.thinksquirrel.fluviofx/Install/ReflectionHelpers.cs.meta
  62. +14 βˆ’0 com.thinksquirrel.fluviofx/Install/Thinksquirrel.FluvioFX.Install.asmdef
  63. +7 βˆ’0 com.thinksquirrel.fluviofx/Install/Thinksquirrel.FluvioFX.Install.asmdef.meta
  64. +9 βˆ’0 com.thinksquirrel.fluviofx/LICENSE.md
  65. +7 βˆ’0 com.thinksquirrel.fluviofx/LICENSE.md.meta
  66. +8 βˆ’0 com.thinksquirrel.fluviofx/Shaders.meta
  67. +129 βˆ’0 com.thinksquirrel.fluviofx/Shaders/FluvioCompute.cginc
  68. +9 βˆ’0 com.thinksquirrel.fluviofx/Shaders/FluvioCompute.cginc.meta
  69. +14 βˆ’0 com.thinksquirrel.fluviofx/Thinksquirrel.FluvioFX.Runtime.asmdef
  70. +7 βˆ’0 com.thinksquirrel.fluviofx/Thinksquirrel.FluvioFX.Runtime.asmdef.meta
  71. +35 βˆ’0 com.thinksquirrel.fluviofx/package.json
  72. +7 βˆ’0 com.thinksquirrel.fluviofx/package.json.meta
@@ -0,0 +1,34 @@
[Ll]ibrary/
[Tt]emp/
[Oo]bj/
[Bb]uild/
[Bb]uilds/
[Ll]ogs/
[Aa]ssets/AssetStoreTools*

# Visual Studio cache directory
.vs/

# Autogenerated VS/MD/Consulo solution and project files
ExportedObj/
.consulo/
*.csproj
*.unityproj
*.sln
*.suo
*.tmp
*.user
*.userprefs
*.pidb
*.booproj
*.svd
*.pdb
*.opendb
*.VC.db

# Unity3D generated meta files
*.pidb.meta
*.pdb.meta

# Unity3D generated file on crash reports
sysinfo.txt
@@ -0,0 +1,7 @@
{
"csharpfixformat.style.braces.allowInlines": false,
"csharpfixformat.style.newline.atEnd": true,
"csharpfixformat.style.newline.elseCatch": true,
"csharpfixformat.style.spaces.beforeParenthesis": false,
"csharpfixformat.style.braces.onSameLine": false
}
Binary file not shown.
@@ -0,0 +1,3 @@
# FluvioFX documentation

Coming soon!
@@ -0,0 +1,44 @@
# FluvioFX

![FluvioFX logo](./Documentation/images/logo.png)

## 🚧 Active development

FluvioFX is currently in early active development. While we will try to maintain backwards compatibility, until 1.0 certain features may be added or removed at any time. Use in larger production projects with care.

### Additional performance considerations

Unity's Visual Effect Graph has a key limitation preventing the implementation of a broadphase step in the physics simulation. This has a severe impact on performance about ~1000 particles (depending on the system). We expect to fix this as soon as we get or figure out a possible resolution. (See #1 for details)

## Installation

To install this project, add the following line to `dependencies` in your `manifest.json` (in the **Packages** subfolder of your Unity project):

```json
"com.thinksquirrel.fluviofx": "https://github.com/thinksquirrel/fluviofx.git"
```

Currently, FluvioFX requires a small patch that must be added to the Visual Effect Graph before usage. This is needed in order to access some internal classes. Once installed, a dialog will pop up to take you through this process. A **FLUVIOFX** compilation file will then be automatically added to the current (and any future) build platforms.

**If you have any compiler errors after installing/updating packages**, try the following:

1. Run _Tools > FluvioFX > Install/Reinstall..._
2. If the above menu is missing or any files are still broken, try to uninstall and reinstall both FluvioFX and the Visual Effect Graph

This workaround will be removed once the VFX Graph's API has been finalized. See [FluvioFXInstall.cs](./com.thinksquirrel.fluviofx/Install/FluvioFXInstall.cs) for the full implementation.

## Getting started

To create a new fluid VFX asset, navigate to _Assets > Create > Visual Effects > FluvioFX Graph_

## Documentation

~~See full documentaion [here](./Documentation/index.md).~~ Documentation is coming soon!

## Examples

Coming soon!

## License

[MIT](./com.thinksquirrel.fluviofx/LICENSE.md)

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
@@ -0,0 +1,94 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using UnityEditor.VFX;
using UnityEngine;
using UnityEngine.Experimental.VFX;

namespace Thinksquirrel.FluvioFX.Editor.Blocks
{
[VFXInfo(category = "FluvioFX")]
class CalculateForces : FluvioFXBlock
{
public override string name
{
get
{
return "Calculate Forces";
}
}
public override IEnumerable<VFXAttributeInfo> attributes
{
get
{
yield return new VFXAttributeInfo(VFXAttribute.Alive, VFXAttributeMode.Read);
yield return new VFXAttributeInfo(VFXAttribute.Position, VFXAttributeMode.Read);
yield return new VFXAttributeInfo(VFXAttribute.Velocity, VFXAttributeMode.Read);
// yield return new VFXAttributeInfo(FluvioFXAttribute.NeighborCount, VFXAttributeMode.Read);
yield return new VFXAttributeInfo(FluvioFXAttribute.DensityPressure, VFXAttributeMode.Read);
yield return new VFXAttributeInfo(FluvioFXAttribute.Force, VFXAttributeMode.ReadWrite);
}
}
#pragma warning disable 649
public class InputProperties
{
[Tooltip("Controls the mass of each fluid particle.")]
public float ParticleMass = 7.625f;
[Tooltip("Controls the artificial viscosity force of the fluid.")]
public float Viscosity = 2.0f;
public Vector4 KernelSize = Vector4.one;
public Vector4 KernelFactors = Vector4.one;
public Texture2D FluvioSolverData;
public Vector2 FluvioSolverDataSize;
}
#pragma warning restore 649
public override string source => $@"
float3 dist, density, f;
float scalar;
#ifdef FLUVIO_INDEX_GRID
uint neighborIndex;
for (uint j = 0; j < neighborCount; ++j)
{{
neighborIndex = GetNeighborIndex(FluvioSolverData, FluvioSolverDataSize, index, j);
#else
float distLenSq;
for (uint neighborIndex = 0; neighborIndex < nbMax; ++neighborIndex)
{{
if (index == neighborIndex) continue;
{FluvioFXAttribute.GetLoadAttributeCode(this, VFXAttribute.Alive, "neighborAlive", "neighborIndex")}
if (!neighborAlive) continue;
#endif
{FluvioFXAttribute.GetLoadAttributeCode(this, VFXAttribute.Position, "neighborPosition", "neighborIndex")}
{FluvioFXAttribute.GetLoadAttributeCode(this, VFXAttribute.Velocity, "neighborVelocity", "neighborIndex")}
{FluvioFXAttribute.GetLoadAttributeCode(this, FluvioFXAttribute.DensityPressure, "neighborDensityPressure", "neighborIndex")}
dist = position - neighborPosition;
#ifndef FLUVIO_INDEX_GRID
distLenSq = dot(dist, dist);
if (distLenSq >= KernelSize.y) continue;
#endif
density = neighborDensityPressure.x;
// Pressure term
scalar = ParticleMass * (densityPressure.z + neighborDensityPressure.z) / (max(density, FLUVIO_EPSILON) * 2.0f);
f = SpikyCalculateGradient(dist, KernelFactors.y, KernelSize.x);
f *= scalar;
force -= f;
// Viscosity term
scalar = ParticleMass
* ViscosityCalculateLaplacian(dist, KernelFactors.z, KernelSize.z, KernelSize.x)
* (1.0f / max(density, FLUVIO_EPSILON));
f = (neighborVelocity - velocity) / KernelSize.w;
f *= scalar * Viscosity;
force += f;
}}";
}
}

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
@@ -0,0 +1,41 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Thinksquirrel.FluvioFX.Editor;
using UnityEditor.VFX;
using UnityEngine;

namespace Thinksquirrel.FluvioFX.Editor.Blocks
{
[VFXInfo(category = "FluvioFX")]
class ClearData : FluvioFXBlock
{
public override string name
{
get
{
return "Clear Data";
}
}
public override IEnumerable<VFXAttributeInfo> attributes
{
get
{
yield return new VFXAttributeInfo(FluvioFXAttribute.Force, VFXAttributeMode.Write);
// yield return new VFXAttributeInfo(FluvioFXAttribute.GridIndex, VFXAttributeMode.Write);
// yield return new VFXAttributeInfo(FluvioFXAttribute.NeighborCount, VFXAttributeMode.Write);
}
}
public override string source => @"
// Clear forces
force = 0;
#ifdef FLUVIO_INDEX_GRID
// Clear grid index
gridIndex = 0;
// Clear neighbor count
neighborCount = 0;
#endif";
}
}

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
@@ -0,0 +1,81 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using UnityEditor.VFX;
using UnityEngine;
using UnityEngine.Experimental.VFX;

namespace Thinksquirrel.FluvioFX.Editor.Blocks
{
[VFXInfo(category = "FluvioFX")]
class DensityPressure : FluvioFXBlock
{
public override string name
{
get
{
return "Density/Pressure";
}
}
public override IEnumerable<VFXAttributeInfo> attributes
{
get
{
yield return new VFXAttributeInfo(VFXAttribute.Alive, VFXAttributeMode.Read);
yield return new VFXAttributeInfo(VFXAttribute.Position, VFXAttributeMode.Read);
// yield return new VFXAttributeInfo(FluvioFXAttribute.NeighborCount, VFXAttributeMode.Read);
yield return new VFXAttributeInfo(FluvioFXAttribute.DensityPressure, VFXAttributeMode.Write);
}
}
#pragma warning disable 649
public class InputProperties
{
[Tooltip("Controls the mass of each fluid particle.")]
public float ParticleMass = 7.625f;
[Tooltip("Controls the overall density of the fluid.")]
public float Density = 998.29f;
[Tooltip("Controls the minimum density of any fluid particle. This can be used to help stabilize a low-viscosity fluid.")]
public float MinimumDensity = 499.145f;
[Tooltip("Controls the gas constant of the fluid, which in turn affects the pressure forces applied to particles.")]
public float GasConstant = 0.01f;
public Vector4 KernelSize = Vector4.one;
public Vector4 KernelFactors = Vector4.one;
public Texture2D FluvioSolverData;
public Vector2 FluvioSolverDataSize;
}
#pragma warning restore 649
public override string source => $@"
float3 dist;
float density = 0;
#ifdef FLUVIO_INDEX_GRID
uint neighborIndex;
for (uint j = 0; j < neighborCount; ++j)
{{
neighborIndex = GetNeighborIndex(FluvioSolverData, FluvioSolverDataSize, index, j);
#else
float distLenSq;
for (uint neighborIndex = 0; neighborIndex < nbMax; ++neighborIndex)
{{
if (index == neighborIndex) continue;
{FluvioFXAttribute.GetLoadAttributeCode(this, VFXAttribute.Alive, "neighborAlive", "neighborIndex")}
if (!neighborAlive) continue;
#endif
{FluvioFXAttribute.GetLoadAttributeCode(this, VFXAttribute.Position, "neighborPosition", "neighborIndex")}
dist = position - neighborPosition;
#ifndef FLUVIO_INDEX_GRID
distLenSq = dot(dist, dist);
if (distLenSq >= KernelSize.y) continue;
#endif
density += ParticleMass * Poly6Calculate(dist, KernelFactors.x, KernelSize.y);
}}
// Write to density/pressure texture
density = max(density, MinimumDensity);
densityPressure = float4(density, density, GasConstant * (density - Density), 0);";
}
}

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
Oops, something went wrong.

0 comments on commit 44aad84

Please sign in to comment.