How does Unity do several Wheels of fluid Physics
Editor to share with you how to do fluid physics Unity a few wheels, I believe that most people do not know much about it, so share this article for your reference, I hope you will learn a lot after reading this article, let's go to understand it!
The internal implementation is Liquidfun
Metaball implementation is also provided (although 2D metaball really has nothing to say)
Half4 frag (v2f I): COLOR {half4 texcol,finalColor; finalColor = tex2D (_ MainTex, i.uv)
If (finalColor.a < _ botmcut) {finalColor.a = 0;} else {finalColor.a * = _ constant;} return finalColor;}
The principle is to discard the pixels outside the threshold according to the transparency threshold, and the actual range of the disc will be more protruding than shown. If the protruding parts of the two discs are stacked together, the transparency will exceed the threshold and become able to display. It looks like the two water droplets will stick together instead of independent circles.
But 3D water can not only consider the density, but also consider the normal. And the density in 3D space can not be simply superimposed by Blend, and 3D space can not be as extravagant and wasteful as 2D space because of the limitation of texture size, which leads to a completely different algorithm. 2D water rendering is actually a very simple example of looking complex, while 3D water rendering is probably an example of looking complex and actually more complex.
However, to my surprise, most of the examples in Liquidfun do not use metaball technology, but draw all the particles directly with AlphaBlend. It uses particles close to the pixel size, and then directly colors the particles according to the physically calculated fluid density (the water surface and foam are white because of the low density, and the bottom is dark because of the high density). Enough ideal results can be obtained.
If you think about it, it's like metaball remapping according to transparency, it just puts the part of the cumulative density directly into the physical, and then draws the dots directly on the screen.
Its final weight demonstration fully demonstrates its coloring principle.
These are all the contents of the article "how to make a few Wheels of fluid Physics in Unity". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!