Obi Official Forum
Mesh and Fluid Problem - Printable Version

+- Obi Official Forum (https://obi.virtualmethodstudio.com/forum)
+-- Forum: Obi Users Category (https://obi.virtualmethodstudio.com/forum/forum-1.html)
+--- Forum: Obi Fluid (https://obi.virtualmethodstudio.com/forum/forum-3.html)
+--- Thread: Mesh and Fluid Problem (/thread-1555.html)

Pages: 1 2 3 4 5 6 7


RE: Mesh and Fluid Problem - sc00b - 29-12-2019

(29-12-2019, 12:28 AM)josemendez Wrote: ...

https://www.dropbox.com/s/oz8pww6q17zz617/%D0%A1%D0%BA%D1%80%D0%B8%D0%BD%D1%88%D0%BE%D1%82%202019-12-29%2013.53.31.png?dl=0 - When mixing red and blue, obviously not black)

https://i.pinimg.com/736x/01/ed/b2/01edb25187bf46c6c9359cf62127b27f--paint-color-chart-color-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/LightAndColor/ColorCodification/ColorsMixing/ - 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?


RE: Mesh and Fluid Problem - josemendez - 29-12-2019

(29-12-2019, 11:54 AM)sc00b Wrote: https://www.dropbox.com/s/oz8pww6q17zz617/%D0%A1%D0%BA%D1%80%D0%B8%D0%BD%D1%88%D0%BE%D1%82%202019-12-29%2013.53.31.png?dl=0 - When mixing red and blue, obviously not black)

https://i.pinimg.com/736x/01/ed/b2/01edb25187bf46c6c9359cf62127b27f--paint-color-chart-color-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/LightAndColor/ColorCodification/ColorsMixing/ - 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/elements-color/primary-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



RE: Mesh and Fluid Problem - sc00b - 29-12-2019

(29-12-2019, 01:17 PM)josemendez Wrote: ....

Great) that you can change the mixing modes)


RE: Mesh and Fluid Problem - sc00b - 09-01-2020

(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)


RE: Mesh and Fluid Problem - josemendez - 09-01-2020

(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));



RE: Mesh and Fluid Problem - sc00b - 09-01-2020

(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?


RE: Mesh and Fluid Problem - josemendez - 09-01-2020

(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.


RE: Mesh and Fluid Problem - sc00b - 09-01-2020

(09-01-2020, 05:10 PM)josemendez Wrote:
Code:
Blend One One

We get all the white fluids, although it is red)


RE: Mesh and Fluid Problem - josemendez - 09-01-2020

(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?