Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help  Mixing Fluids
#14
(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:

[Image: mKxKRhc.png]

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:

[Image: ks5u8gl.png]
Reply


Messages In This Thread
Mixing Fluids - by canaydiin - 28-03-2022, 12:00 PM
RE: Mixing Fluids - by josemendez - 28-03-2022, 12:15 PM
RE: Mixing Fluids - by canaydiin - 28-03-2022, 01:14 PM
RE: Mixing Fluids - by josemendez - 28-03-2022, 02:49 PM
RE: Mixing Fluids - by canaydiin - 28-03-2022, 10:20 PM
RE: Mixing Fluids - by josemendez - 29-03-2022, 07:31 AM
RE: Mixing Fluids - by canaydiin - 29-03-2022, 01:48 PM
RE: Mixing Fluids - by josemendez - 29-03-2022, 02:18 PM
RE: Mixing Fluids - by canaydiin - 29-03-2022, 02:53 PM
RE: Mixing Fluids - by josemendez - 29-03-2022, 02:59 PM
RE: Mixing Fluids - by canaydiin - 30-03-2022, 07:29 AM
RE: Mixing Fluids - by josemendez - 30-03-2022, 07:45 AM
RE: Mixing Fluids - by canaydiin - 30-03-2022, 07:51 AM
RE: Mixing Fluids - by josemendez - 30-03-2022, 08:13 AM
RE: Mixing Fluids - by canaydiin - 30-03-2022, 08:22 AM
RE: Mixing Fluids - by josemendez - 30-03-2022, 08:24 AM
RE: Mixing Fluids - by canaydiin - 30-03-2022, 08:33 AM
RE: Mixing Fluids - by josemendez - 30-03-2022, 09:12 AM
RE: Mixing Fluids - by canaydiin - 30-03-2022, 09:15 AM
RE: Mixing Fluids - by josemendez - 30-03-2022, 09:18 AM
RE: Mixing Fluids - by khanx078 - 23-08-2022, 10:21 AM
RE: Mixing Fluids - by josemendez - 23-08-2022, 04:56 PM
RE: Mixing Fluids - by khanx078 - 24-08-2022, 04:53 AM
RE: Mixing Fluids - by josemendez - 24-08-2022, 07:32 AM
RE: Mixing Fluids - by khanx078 - 24-08-2022, 08:51 AM
RE: Mixing Fluids - by josemendez - 24-08-2022, 10:18 AM
RE: Mixing Fluids - by khanx078 - 24-08-2022, 12:22 PM
RE: Mixing Fluids - by josemendez - 24-08-2022, 12:50 PM
RE: Mixing Fluids - by khanx078 - 24-08-2022, 01:10 PM
RE: Mixing Fluids - by josemendez - 24-08-2022, 01:39 PM
RE: Mixing Fluids - by khanx078 - 25-08-2022, 03:33 AM
RE: Mixing Fluids - by josemendez - 25-08-2022, 07:57 AM
RE: Mixing Fluids - by khanx078 - 25-08-2022, 08:49 AM
RE: Mixing Fluids - by josemendez - 25-08-2022, 09:44 AM
RE: Mixing Fluids - by khanx078 - 25-08-2022, 10:05 AM
RE: Mixing Fluids - by josemendez - 25-08-2022, 10:23 AM
RE: Mixing Fluids - by khanx078 - 25-08-2022, 10:35 AM
RE: Mixing Fluids - by josemendez - 25-08-2022, 11:04 AM
RE: Mixing Fluids - by khanx078 - 25-08-2022, 11:35 AM
RE: Mixing Fluids - by josemendez - 25-08-2022, 11:57 AM
RE: Mixing Fluids - by khanx078 - 25-08-2022, 12:07 PM
RE: Mixing Fluids - by josemendez - 25-08-2022, 12:11 PM