12
2013
Water Particles
Converted this javascript demo to Unity C#: Aqualibrium by Gerard Ferrandez
Info:
– Had to make some modifications since all those javascript [this] that.x variables were quite complicated..but seems to work 🙂
– Screenshot shows 500 spheres with debug.drawlines to each neighbour particle (added gravity on by default)
Current version:
– Got distance calculation bit faster (mainloop went from: 192ms for 1500 particles, to: 104ms for 1500 particles) (debug.linedraw is on): using this sphere Distance Between 2 points
– If I use default sphere as prefab for the particle, it doesnt get batched, but default cube does ..Oo?
TODO:
– 3D version?
– Add Blobmesh = water?
– Optimize..if can..
– Different fluidish materials? (mass, friction, break-ability?)
– Sand simulation? (ground digging with excavator..or maybe better using the eulerian water sim grid?)
– Test threading? http://unitygems.com/threads/
Webplayer:
http://unitycoder.com/upload/demos/WaterParticles1/ (500 particles)
http://unitycoder.com/upload/demos/WaterParticles2/ (additive particle shader)
Download source:
waterParticles.unitypackage
—
Image#2: Testing threading with 1500 cubes.. its fast & kind of works, but some particles wont slown down at all..
(click for full size)
—
Image#3: Nice idea here..but it would pretty much need unity pro: http://www.patrickmatte.com/stuff/physicsLiquid/
Tried with additive particle shader instead:
(click for full size)
—
Image#4: Scaling particles based on neighbour count (would be also interesting to stretch them based on speed..)
(click for full size)
Related Posts
17 Comments + Add Comment
Leave a comment
Recent posts
- [GreaseMonkey] Unity Forum Fixer
- UnityHub: Make Hub application background Translucent
- Customize SpriteShapeRenderer quality (but has issues)
- Editor tool: Copy selected gameobject’s names into clipboard as rows (for Excel)
- Editor tool: Replace string in selected gameobject’s names
- UnityHub: Enable built-in Login Dialog (no more browser login/logout issues!)
- Use TikTok-TTS in Unity (with WebRequest)
- Create Scene Thumbnail Image using OnSceneSaved & OnPreviewGUI
- webgl+javascript TTS
- Using Moonsharp (LUA) + Unity Webgl
- Using 3D gameobject prefabs with Unity Tilemap + NavMesh Surface
- Custom Unity Hub Project Template Preview Image/Video (using HTML+CSS in package description)
Recent Comments
- Vector3 maths for dummies! on
- UnityHub: Make Hub application background Translucent on
- UnityHub: Make Hub application background Translucent on
- Install Android SDK+JDK+NDK for Unity (without AndroidStudio or Unity Hub) on
- Install Android SDK+JDK+NDK for Unity (without AndroidStudio or Unity Hub) on
- [Asset Store] Point Cloud Viewer & Tools on
- [Asset Store] Point Cloud Viewer & Tools on
- ffmpeg stream raw video into Unity Texture2D on
Do you have the source code posted?
Do you…? D=
Its coming up in next couple weeks.. need to fix/clean it up after it went broken with all the threading tests etc 🙂
This is seriously epic.. Very genius. 😀 Hope your SC is flexible, as in allowing for particles to be attracted rather than pushed..
Very cool result!
Can you share the source code with us?
Tks 😀
Source added.
[…] Water Particles « UnityCoder – Unity3D […]
2D dynamic fluid simulation (webplayer demo)
http://forum.unity3d.com/threads/205291-2D-dynamic-fluid-simulation
First of all, thanks for this! Really appreciate it!
What mesh do I use with this? I opened the file and the SphereParticle did not have a mesh attached with it, so when I clicked play, it did not show anything.
I’ve tried it with a Sphere particle which doesn’t look right enough and has 700 draw calls because of the routine in the for loop that creates the 700 particles. However when I tried it with the Quad mesh, it resulted in 1 draw call but that doesn’t look enough like water either.
So what mesh do we use? The mesh options that comes with Unity Free version don’t seem to make it look correctly like the water in the demo web player. What did you use?
hmm, might had been a custom quad mesh (from http://wiki.unity3d.com/index.php/CreatePlane ) ** yes, it was: custom mesh from createplane “Plane1x1W1L1HC”
(and transform scale was 32)
Awesome! That worked mgear! Thank You.
I noticed you showed a better version of water particle based simulation on the Unity forums. I was wondering if you can guide me on what I can do to achieve what you showed on the Unity forums. I don’t need the full source but some guidance on what could be adjusted, the direction and such should be enough.
you have the link to that topic?, cant remember what was it..
The link is here: http://forum.unity3d.com/threads/205291-2D-dynamic-fluid-simulation
What did you change specifically to make it more realistic and better colors? A different shader?
The link is here: http://forum.unity3d.com/threads/205291-2D-dynamic-fluid-simulation
What did you change specifically to make it more realistic and better colors? A different shader?
actually that is not mine 🙂 i saw that while ago also, looks very nice! (but needs unity pro for render textures, readpixels could work but slower..), to me it looks like using this idea or similar: http://www.patrickmatte.com/stuff/physicsLiquid/
Ahh nvm. It seems you were able to achieve scaling particles based on neighbour count in Image #4. How did you implement that? Did it change the performance in a bad way?
I think it didnt change it much, as it was only doing this:
// scale by neighbour count
// float s = Mathf.Clamp(ncount*0.5f, 0.5f,32.0f);
// this.obj.localScale = new Vector3(s,s,s);