Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Sprite under PNG  (Read 1703 times)

0 Members and 1 Guest are viewing this topic.

bszandras

  • Newbie
  • *
  • Posts: 6
    • View Profile
    • Email
Sprite under PNG
« on: May 04, 2020, 02:55:22 pm »
I want to check if a sprite is under another sprite's transparent part (textured with a png). I haven't really found a solution, is this even possible in SFML?

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11034
    • View Profile
    • development blog
    • Email
Re: Sprite under PNG
« Reply #1 on: May 04, 2020, 04:47:57 pm »
Really depends on what you want to achieve with it.

You can have some pixel "picking" with a shader, but you probably can't differentiate between different sprites themselves.

You can do everything in memory, but that's rather slow and you end up with a sort of software renderer, as you have to figure out what pixel is shown where.

Depending on the precision you could also have a sort of transparency mask, that may make it easier to differentiate the layers. It's probably still rather performance hungry and done on the CPU, but should probably be better than the second option.

But as I said, it really depends what you want to achieve and what trade-offs you can accept.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

 

anything