0
\$\begingroup\$

I'm using XNA and C#. I have two shapes (texture2ds), and I want to overlay shape 2 (50% transparent square) over shape 1 (opaque circle), but I want to get Option B, not Option A.

I basically want to render only the part of the square that's over the circle, without rendering the rest of the square over the background.

enter image description here

EDIT: Let me clarify why exactly I want to do this. I'm essentially using something like this as cheap shadows on top-down 2d planets. When a moon, planet, and sun are all in a 180 degree line, the moon is expected to be completely shaded. So I want to put a shadow behind the planet that won't cover the background, but when the moon passes under it, it gets shaded black.

\$\endgroup\$
3
  • \$\begingroup\$ What you want sounds like the Porter-Duff "atop" operator. \$\endgroup\$ Commented Nov 15, 2013 at 17:57
  • \$\begingroup\$ @NathanReed The "Dest Atop" is what I need, unfortunately I don't understand how this could be implemented, if I did I probably wouldn't ask such a simple question. However that was interesting and may be helpful for me in the future when I understand things better, so thanks for that! \$\endgroup\$ Commented Nov 16, 2013 at 0:36
  • \$\begingroup\$ This might help: gamedev.stackexchange.com/questions/38118/… \$\endgroup\$ Commented Nov 21, 2013 at 10:01

0

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.