30-03-2022, 08:13 AM
(This post was last modified: 30-03-2022, 08:25 AM by josemendez.)
(30-03-2022, 07:45 AM)josemendez Wrote: Hi!
Received the email, opening the project right now. Will get back to you asap.
The project works fine for me, fluids get mixed and the resulting color is orange. You can verify this by disabling the fluid renderer and enabling the "render" checkbox on the emitters. This is how it looks when fluids have been just poured:
However re-enabling fluid rendering and disabling particle rendering, the orange fluid its way too red-ish. As I mentioned in my previous posts, this is due to incorrect blending and high absorption:
A) You're using multiplicative particle blending: "Dst Color" as blend source, and "Zero" as blend destination. So the blending equation for your particles becomes this:
Final Color = DstColor * sourceValue + Zero * destinationValue
(see: https://docs.unity3d.com/Manual/SL-Blend.html)
Which means each time a particle is rendered, its color (sourceValue) gets multiplied by that of the particles behind it (DstColor). Note that the destinationValue gets multiplied by zero so it doesn't contribute.
So if your particles are orange (1,0.5,0), every time a new particle gets drawn this color gets multiplied by itself due to blending:
(1,0.5,0)*(1,0.5,0) = (1,0.25,0),
(1,0.25,0)*(1,0.5,0) = (1,0.125,0),
(1,0.125,0)*(1,0.5,0) = (1,0.0625,0)
.... etc, eventually reaching (1,0,0) which is pure red.
Using alpha blending instead (source:Src Alpha, dest:One Minus Src Alpha) respects the original color, instead of darkening it.
Blending is a basic concept in graphics, the blending equation (and blending factors / operators) are not explained in Obi's manual because they're covered by Unity's manual and many other online resources. It's assumed you know what they are and how they work. Blending is extensively used in literally all rendering systems / game engines so it's something you should definitely get familiar with. You can use resources for other engines, OpenGL, DirectX, etc... works the same way everywhere. Some more info on it:
https://www.informit.com/articles/articl...6&seqNum=5
http://www.opengl-tutorial.org/intermedi...nsparency/
http://www.directxtutorial.com/Lesson.as...nid=9-4-10
https://www.braynzarsoft.net/viewtutoria...2-blending
https://manual.yoyogames.com/Additional_...dmodes.htm
B) way too much absorption. Absorption darkens the fluid color (the output of the blending equation above) according to its "thickness". The deeper the fluid is, the longer light travels trough it and the less light reaches your eye. This is calculated using Beer's law, which results in exponential light decay. Reducing the absorption parameter from 5 to 1.2 will give better results.
Wrapping up: set your FluidRenderer's particle blend source/dest to SrcAlpha and One Minus Src Alpha respectively, and lower its absorption parameter to 1.2-1.5. This is the result: