Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Mesh and Fluid Problem
#61
(29-12-2019, 12:28 AM)josemendez Wrote: ...

https://www.dropbox.com/s/oz8pww6q17zz61...1.png?dl=0 - When mixing red and blue, obviously not black)

https://i.pinimg.com/736x/01/ed/b2/01edb...charts.jpg - I do not see black

Black can be obtained by mixing, blue + green + red, but I do not mix three colors, but mix two)

https://tehtab.ru/Guide/GuidePhysics/Lig...orsMixing/ - in Russian, but the whole palette is visible when mixing colors

I correctly understand that if I do not multiply, but add numbers, will I get the result that I need? In other words, Green + Red = Brown?

How do we change the blending mode, such as I pointed out above?
Reply
#62
(29-12-2019, 11:54 AM)sc00b Wrote: https://www.dropbox.com/s/oz8pww6q17zz61...1.png?dl=0 - When mixing red and blue, obviously not black)

https://i.pinimg.com/736x/01/ed/b2/01edb...charts.jpg - I do not see black

Black can be obtained by mixing, blue + green + red, but I do not mix three colors, but mix two)

https://tehtab.ru/Guide/GuidePhysics/Lig...orsMixing/ - in Russian, but the whole palette is visible when mixing colors

All these examples use additive blending, they add colors together, which is how LIGHT behaves. Not fluids (paints, inks, or any kind of pigment). When light passes trough a colored fluid (or glass, paper, gas, etc), certain wavelengths are attenuated or removed according to the media color. Light is absorbed, no light is ever added. That's why multiplicative blending is used by default. Using additive blending for fluids is not physically correct.

Here's a image illustrating both blending modes:
[Image: primaries.jpg]
The website also gives a good introduction to color theory:
http://learn.leighcotnoir.com/artspeak/e...ry-colors/

(29-12-2019, 11:54 AM)sc00b Wrote: I correctly understand that if I do not multiply, but add numbers, will I get the result that I need? In other words, Green + Red = Brown?

Exactly. But pure green + red = yellow, not brown. To get brown you’d need dark green and dark red.

You can change the blending mode in FluidColorsBlendSimple.shader. Here's a list of all blending modes supported by Unity:
https://docs.unity3d.com/Manual/SL-Blend.html

So instead of multiplicative:
Code:
Blend DstColor Zero
use additive blending:
Code:
Blend One One
Reply
#63
(29-12-2019, 01:17 PM)josemendez Wrote: ....

Great) that you can change the mixing modes)
Reply
#64
(29-12-2019, 01:17 PM)josemendez Wrote: Exactly. But pure green + red = yellow, not brown. To get brown you’d need dark green and dark red.

You can change the blending mode in FluidColorsBlendSimple.shader. Here's a list of all blending modes supported by Unity:
https://docs.unity3d.com/Manual/SL-Blend.html

So instead of multiplicative:
Code:
Blend DstColor Zero
use additive blending:
Code:
Blend One One

Blend One One - this mode creates a red center and white in a circle, but in the end everything is white)
Reply
#65
(09-01-2020, 03:23 PM)sc00b Wrote: Blend One One - this mode creates a red center and white in a circle, but in the end everything is white)

Make sure the background buffer is cleared to black, not white. If you add any color to white, you'll of course get white. In additive blending,  you need to start from black and gradually add color to it. In multiplicative blending, you start from white and gradually remove color from it. Like in the image I posted depicting both blending modes.

So in the ObiSimpleFluidRendererColored file I provided, change this line:

Code:
renderFluid.ClearRenderTarget(true,true, new Color(1, 1, 1, 0));

to this:

Code:
renderFluid.ClearRenderTarget(true,true, new Color(0, 0, 0, 0));
Reply
#66
(09-01-2020, 03:35 PM)josemendez Wrote: Make sure the background buffer is cleared to black, not white. If you add any color to white, you'll of course get white. In additive blending,  you need to start from black and gradually add color to it. In multiplicative blending, you start from white and gradually remove color from it. Like in the image I posted depicting both blending modes.

So in the ObiSimpleFluidRendererColored file I provided, change this line:

Code:
renderFluid.ClearRenderTarget(true,true, new Color(1, 1, 1, 0));

to this:

Code:
renderFluid.ClearRenderTarget(true,true, new Color(0, 0, 0, 0));

we use this shader, can you make the corrections we need in it?


Attached Files
.shader   FluidColorsBlend.shader (Size: 2.82 KB / Downloads: 1)
Reply
#67
(09-01-2020, 04:50 PM)sc00b Wrote: we use this shader, can you make the corrections we need in it?

Only thing I would do is changing the blending mode from multiplicative to additive, as told before.

Code:
Blend DstColor Zero

to

Code:
Blend One One

That's all that is needed in the shader. The other change is in the renderer as explained in my last message: change the clear color from white to black.
Reply
#68
(09-01-2020, 05:10 PM)josemendez Wrote:
Code:
Blend One One

We get all the white fluids, although it is red)
Reply
#69
(09-01-2020, 05:24 PM)sc00b Wrote: We get all the white fluids, although it is red)

Did you clear the buffer to black, as I told you to?
Reply