Posts: 12
Threads: 1
Joined: Mar 2022
Reputation:
0
(29-03-2022, 02:59 PM)josemendez Wrote: Would it be possible for you to share your project with me? Send it to support(at)virtualmethodstudio.com . This way I can take a closer look and hopefully be able to help you.
Diffusion is quite simple: each particle carries a Vector4 (the user data) and these get averaged together when particles go within the vicinity of each other. That’s all there is to it, that’s why I’m surprised it isn’t working correctly for you.
The screenshot in my previous post is from the “FluidMixing” sample scene. Changes to the original scene:
-switch the solver to 3D
-add a FluidRenderer to the camera, increase radius scale on the particle renderers and uncheck “render”.
-remove the components in the emitters that map diffusion data to a gradient and replace them with a simple color=userData script.
-set the user data to (1,0,0,1) and (1,1,0,1) in each fluid.
That should work, let me know how it goes. Anyway, if I can take a look at your project it would be great!
Hi there,I've sent the project yesterday, and I'll try what you wrote today and get back to you.
Could you let me know if you have received the email?
Posts: 6,322
Threads: 24
Joined: Jun 2017
Reputation:
400
Obi Owner:
(30-03-2022, 07:29 AM)canaydiin Wrote: Hi there,I've sent the project yesterday, and I'll try what you wrote today and get back to you.
Could you let me know if you have received the email?
Hi!
Received the email, opening the project right now. Will get back to you asap.
Posts: 12
Threads: 1
Joined: Mar 2022
Reputation:
0
(30-03-2022, 07:45 AM)josemendez Wrote: Hi!
Received the email, opening the project right now. Will get back to you asap.
Hi there,
Alrite im glad you've got the email. And I've tried modifying the FluidMixing Scene, I was able to get to 3D and all that, however the fluids arent mixing, red + yellow = red is how it's mixing
Posts: 6,322
Threads: 24
Joined: Jun 2017
Reputation:
400
Obi Owner:
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:
Posts: 12
Threads: 1
Joined: Mar 2022
Reputation:
0
(30-03-2022, 08:13 AM)josemendez Wrote: 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 destinationRGB 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. Blending is extensively used in literally all rendering systems / game engines so it's something you should definitely get familiar with.
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:
Thanks for explaining, so to just to clarify, i have made the Particle Blend Source - SRC ALPHA and the Particle Blend Destination to - One Minus Src Alpha
What do i make the blend source and blend destination?
Posts: 6,322
Threads: 24
Joined: Jun 2017
Reputation:
400
Obi Owner:
30-03-2022, 08:24 AM
(This post was last modified: 30-03-2022, 08:25 AM by josemendez.)
(30-03-2022, 08:22 AM)canaydiin Wrote: What do i make the blend source and blend destination?
Entirely depends on the look you want to achieve. Typically you want to blend the fluid with its background using alpha blending so Src Alpha and One Minus Src Alpha, the same values you use for particle blend.
Posts: 12
Threads: 1
Joined: Mar 2022
Reputation:
0
30-03-2022, 08:33 AM
(This post was last modified: 30-03-2022, 09:01 AM by canaydiin.)
(30-03-2022, 08:24 AM)josemendez Wrote: Entirely depends on the look you want to achieve. Typically you want to blend the fluid with its background using alpha blending so Src Alpha and One Minus Src Alpha, the same values you use for particle blend.
Okay thank you so much
I got one more question, does the blending change when the project is URP?
Posts: 6,322
Threads: 24
Joined: Jun 2017
Reputation:
400
Obi Owner:
30-03-2022, 09:12 AM
(This post was last modified: 30-03-2022, 09:16 AM by josemendez.)
(30-03-2022, 08:33 AM)canaydiin Wrote: I got one more question, does the blending change when the project is URP?
Blending is not part of the pipeline, it's part of your graphics card hardware and exposed by the graphics API being used.
OpenGL, Metal, Vulkan and DirectX all have support for blending, which means it's available and works the same way in all engines, all pipelines (built-in, UPR and HDRP), and -nowadays- all devices.
Even if you stopped using Unity and switched to another engine (Godot, Unreal, etc) blending would still work the same way .
Posts: 12
Threads: 1
Joined: Mar 2022
Reputation:
0
(30-03-2022, 09:12 AM)josemendez Wrote: Blending is not part of the pipeline, it's part of your graphics card hardware and exposed by the graphics API being used.
OpenGL, Metal and DirectX all have hardware support for blending, which means it's available and works the same way in all engines, all pipelines, and (nowadays) all devices.
I asked because with the same values for everything, in the Non URP project, i now get the same color as you have shown, however in the URP project, with the same values, i get a darker orange
Posts: 6,322
Threads: 24
Joined: Jun 2017
Reputation:
400
Obi Owner:
30-03-2022, 09:18 AM
(This post was last modified: 30-03-2022, 09:22 AM by josemendez.)
(30-03-2022, 09:15 AM)canaydiin Wrote: I asked because with the same values for everything, in the Non URP project, i now get the same color as you have shown, however in the URP project, with the same values, i get a darker orange
Colors can change as a result of things other than blending: most notably, lighting and/or the color space being used. If you're using linear color space, colors usually appear duller (darker) compared to gamma space.
Not sure is this is your case though. You can read more about color spaces, pipelines and how they interact with blending here:
https://docs.unity3d.com/Manual/LinearRe...kflow.html
Also, light intensity and decay change in all 3 render pipelines. So the same lighting setup values will look different in every pipeline, and you have to manually adjust your values for the pipeline you're using. Getting the same look in all 3 pipelines is basically impossible, you need to choose a pipeline and stick to it.
|