https://www.youtube.com/watch?v=QFtK4QXwDmQ
This is a massive update. It’s so massive that I had to literally rewrite the whole asset from the ground up, took 6 months, stalling any other development or improvement, and made me call the upcoming version v2.
What changed?
Fist, It is now implemented nearly completely in Burst&Jobs, (multithreaded instead of single threaded in CPU).
Apart from improving efficiency a lot, it was needed in order to add buoyancy (floating forces) due to the amount of computation it required from the first tests. It is a simple but pretty realistic model, but depends a lot on the resolution of the surface and the properties you set. Needs a lot of testing.
Problems mentioned in the previous posts regarding unstable water around floating objects due to the “discretization of the surface” still happen, but that will be fixed in the next update now that I have multithreaded code and using raymarching or any other method like multisampling will allow for a smoother interaction.
Also, wave push effect mentioned by some users, not available in the velocity based simulation (previous) will be available in buoyancy based simulation.
Compatibility with the older version? The code has absolutely changed for the better, that it’s why I moved to v2. If you used the API it will probable need to be updated a little but. Let me know when the time comes, and I will help you gladly. The previous simulation method, which is velocity based, will be restored and shown as an option in the settings instead of buoyancy based, which is the default method now.
When will v2 be available? It will come asap, I don’t have an ETA since it took 6 months to do this and I lost track of everything else, but I’m restoring all to how it was, give the UI an upgrade, test and add everything that is left. But it will not take as much as it did. I would love to have this done in maximum a couple of months, probably less. I’ll let you know.
Future versions plan. From now on efficiency improvements will come and it will get faster and better. There’s only room for improvement here!. I had many bottlenecks that are still there and need more work (basically write physics engine methods myself instead of using Physx’s ones, because they are too slow! ). Also, some of the small features asked by the users plus more examples to show how this asset works are seriously needed. So I’ll be working on that soon.
I was asked in Reddit why I didn’t upgrade to Compute Shaders instead of using Jobs&Burst, which would allow a more flexible surface of liquid, (bigger, more efficient).
The first reason is very critical:
- There would be no two-way coupling : Objects floating would not affect the water and the water would not affect the object. If everything is calculated in the GPU, to affect Unity’s physics system would require to get the information out of there, which means milliseconds wasted each frame. We don’t have that luxury of miliseconds to spend. Compute shaders means EVERYTHING is done in the GPU. I would have to write a full physics engine on GPU to make this work and native physics could not be used.
Other reasons
-
Limitations on platforms of Compute Shaders. Some would be out of the game, which I don’t really like.
-
Lack of time and resources.
Some other reasons I commented before:
"Yep. That would be another future update. But since compute shaders are not compatible with a lot of devices and platforms, I prefer to do this step by step and allow people to choose. The same way Obi simulation plugins, made in the company I founded, do. You have the choice of simple, burst, and compute.
I have some bottlenecks even for burst that I can’t resolve because I’m using miltithreaded raycast functions made by unity instead of my own, because the results can’t be used inside another job. Something else is that I will have to make my own RecalculateNormals() by hand instead of using the slow default method.
Some of the algorithms in fact are impossible to move to jobs right now, I would have to implement by hand most of the basic mathematical methods of physx in order to make most of the algorithms work in jobs, just because jobs don’t allow the use of any UnityEngine methods, and add you can imagine, my time is limited. Constant updates are needed.
This one was a much needed cpu to miltithreaded upgrade, and the addition of buoyancy made it necessary. WebGL will not be supported probably now, and my live demos won’t work, so I have to add a lot of code in order to let people choose both methods.
From now on, there’s only room for improvement. It’s pretty fast right now but it will get better and better."