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.

  • \$\begingroup\$ What you want sounds like the Porter-Duff "atop" operator. \$\endgroup\$ – Nathan Reed Nov 15 '13 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\$ – Postman Nov 16 '13 at 0:36
  • \$\begingroup\$ This might help: gamedev.stackexchange.com/questions/38118/… \$\endgroup\$ – Kai Hartmann Nov 21 '13 at 10:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.