I am working on a game that incorporates two circular sprites - they are identical and imported from a spritesheet that consists of one single all-white circle. The two sprites are different colors and I choose the colors by changing the color property of the material on the sprite renderer.
Question: when the two circles overlap (say partially overlap), is there any way to automatically have the color of the portion that overlaps be a blend / combination of the two original circles. eg specifically if sprite1 is 0xFF0000 (red) and sprite2 is 0x0000FF (blue) I would want ONLY the overlapping portions of the two circles to be 0xFF00FF (purple) and the non-overlapping portions to remain red and blue respectively.
eg - Is there some sort of material that is ‘additive’ to what is under it rather than simply covering up?
Any help / hints would be greatly appreciated. I am new to Unity but it is fantastic!
When you say “partially transparent” … do you mean setting the alpha of each to, say, 0.5? I have tried that but it has the wrong effect that I want where the background blends / shows through. It is an all black background, so the end effect is that the separate red or separate blue circles are simply dull red and dull blue. Or do you mean something different when you say “partially transparent”?
You could give each one a moving white background as a child object. Then, if you get the sorting layers correct, they’ll blend with each other but not the background.
Thank you all for the suggestions. I have my original question working with the shader examples from the response by zombiegorilla, which is very similar to Bivrost mod.
Unfortunately I now realize that my original question wasn’t what I was looking for, and instead I want a shader that can programatically produce a different color in the portions that the two sprites overlap. eg something like:
where ColorOfPixel is the COMBINED color of the two sprites that I am moving around. So specifically sprite 1 is a red circle, sprite 2 is a blue circle … and for the portions that overlap as I move them around, I want only that overlapping portion to be green. Can this be done?
Here is the key part of my shader code (but it does NOT work):