I would like to know how to make this effect of merged circle selection. Here are images to illustrate:
Basically I'm looking for this effect:
How the merge effect of the circles can be achieved ? I didn't found any explanation concerning this effect. I know that to project those texture I can develop a decal system but I don't know how to create the merging effect.
If possible, I'm looking for purely shaders solution.
Answer
There are a few tricks you can do:
Z-buffer
After you have rendered all other objects, for each unit render a transparent circle of smaller size with max Z value. Then render selection circles decals on the ground. Since they are below in Z-order, they will be discarded when under units.
Being fully transparent means that the circle gets written only to Z-buffer (max Z value). Now when you render decals, they are tested against Z buffer values, and if they are passing the test they get rendered (which happens only outside of the circles)
Stencil
Same as with previous approach, but this time use a stencil buffer. Render smaller circles for units with some stencil value, then render selection decals. Setup stencil to discard any elements with your stencil value.
No comments:
Post a Comment