Jump to content

  • Log In with Google      Sign In   
  • Create Account


Why do we Mask?


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
4 replies to this topic

#1 yati1   Members   -  Reputation: 100

Like
0Likes
Like

Posted 18 March 2011 - 09:13 PM

Hi,

I've recently programmed a 2d game and the artist who helped me made all the sprites with a true red background and I made a masking function in the game and it works and alls good. But WHY do we mask? I'm using .png format sprites so isn't it unnecessary seeing as .png uses RGBa? In websites that offered free sprites they had grey backgrounds so I'm assuming its standard practice but I still don't understand why this is advantageous.

Can someone please enlighten me?

Thanks

Sponsor:

#2 LancerSolurus   Members   -  Reputation: 546

Like
0Likes
Like

Posted 18 March 2011 - 09:47 PM

The reason is so you don't see the background around your sprite. If you didn't mask (or use an alpha channel) your sprites would consist of a box shape surrounding the main image.

******************************************************************************************
Youtube Channel


#3 KulSeran   Members   -  Reputation: 2223

Like
1Likes
Like

Posted 18 March 2011 - 09:47 PM

There are two parts to it.
1) The masking itself means you don't have to store 32bit images. You can store a 24bit or a paletted image and still make transparent images.
2) Using a mask lets you use much faster blending features, like hardware color-keying or cut-off alpha testing. Since you are doing a binary operation of keep or discard for each pixel this is faster to draw than doing a regular blend function that does a full blend calculation on every pixel. Cutoff alpha also has the benefit of being draw order independant.

#4 TobiasK   Members   -  Reputation: 126

Like
0Likes
Like

Posted 24 March 2011 - 11:40 AM

On a PC it's kind of pointless really, as we have the hardware to use an alpha channel. On handhelds masking is still a must, but in a year or two it'll probably be useless there as well.

#5 Krypt0n   Crossbones+   -  Reputation: 2358

Like
0Likes
Like

Posted 25 March 2011 - 03:16 AM

On a PC it's kind of pointless really, as we have the hardware to use an alpha channel. On handhelds masking is still a must, but in a year or two it'll probably be useless there as well.

I use it to render front2back, as masking allows me to have occlusion informations, which save some work on cpu, but even some gpus nowadays benefit from that.

that's also the reason why a lot of games use alpha test on e.g. vegetation, blending and z-buffering is still not really solved.







Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS