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.
(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.
09-01-2020, 03:35 PM (This post was last modified: 09-01-2020, 03:41 PM by josemendez.)
(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));
(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?
09-01-2020, 05:10 PM (This post was last modified: 09-01-2020, 05:10 PM by josemendez.)
(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.