Author Topic: Layered alpha sprites  (Read 1312 times)

Real World

  • Newbie
  • *
  • Thank You
  • -Given: 2
  • -Receive: 0
  • Posts: 15
    • View Profile
Layered alpha sprites
« on: December 03, 2016, 04:36:49 PM »
I've got two sprites that are layered on top of each other. For the sake of argument, the bottom one is a square and a circle is on top. I want to set the opacity of the combined sprites to 50% alpha but doing so makes the square visible through the circle. I want to render it so that pixels that are invisible at fully opaque remain invisible at 50% opacity.
The only solution I can think of right now is to render the the set to a texture and then display the texture at 50% alpha instead. Problem being that I have about 100 of these to display on screen (all unique) so the performance overhead would be too great. Anyone aware of a shader solution or another solution?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Layered alpha sprites
« Reply #1 on: December 03, 2016, 10:18:03 PM »
You need to create a custom shader that samples two textures. What you have is essentially two passes, and what you want has to be done in a single pass.