- Home /
Blend colors in overlapping areas.
Hello,
I would like to achieve the following effect.
If two sprites overlap, the colors should blend in the overlapping area.
So, as in the following picture: I also found a shader that comes close to it. The particles/additive shader.
However, this does not seem to display all colors accurately.
For example, if I have a color with R-G-B values r = 201, g = 255, b = 0 (a greenish-yellow color), this is shown as pure yellow, as seen in the following image. I am still new to unity and have no idea of shader programming yet.
Is there perhaps a shader that can achieve the effect I want? Or can you get the additive shader to display the colors correctly?
Answer by TheSky · Jul 05, 2017 at 08:14 AM
If someone needs something similar, I have a solution now.
Just download the code for the sprite/default shader and
replace the line "blend one OneMinusSrcAlpha" with "blend one One".
Then set the alpha to 255 in the color settings.
However, the color is too dark. I don't know how to fix this, because I don't know about shader programming.
My workaround is to just put two sprites with the new shader and the same color consecutively. Then the color has the correct brightness.
Behind it you can put a sprite with a simple sprite/default shader with black color, so that the sprites with the new shader do not mix with the background.
This may not be the most elegant solution, but it works.
Your answer
Follow this Question
Related Questions
¿UsePass overrides Render State? 0 Answers
one shader for multiple sprites 0 Answers
Greyscale shading 0 Answers
Scripting Shader: How to control Alpha with slider? 1 Answer