Jump to content
  • Advertisement
Sign in to follow this  
Boder

Masking

This topic is 4525 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I understand the tutorial. I have looked over it numerous times. I don't get how this technique has any advantages over normal transparency. Are there other examples besides this use of the technique that achieve cool effects other than achieving a simple on/off alpha channel?

Share this post


Link to post
Share on other sites
Advertisement
Until recently i thought this effect has no real use at all concidering that we now got alpha blending.

But i did find a use of it last week when i converted lesson14 for it to be antialised.
when you do use antialising (glEnable( GL_POLYGON_SMOOTH ); to be exact) you have to use a specific blending function, but this blending function(GL_SRC_ALPHA, GL_ONE) is additive, so you have to mask the text by first rendering the text in black using the (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA) blendfunc and then rendering the correct text in whatever color you want.

Anyway for most situations masking is pretty useless, i think nehe wrote this tut just because he couldn't load 32bit images.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Quote:

Anyway for most situations masking is pretty useless


For transparent object you have to order them from back to front before drawing them or you get incoorect results. It is also slower to render, because it must read the current contents of the backbuffer before render (to blend with it).

For masking you can just render them normally like a solid mesh, but you can only have a hard edge in your textures. Plant rendering among a vast range of other things benifit from this since you do not waste your CPU ording each triangle, so I wouldnt call it useless, since it is used all the time in current high-end games.

Share this post


Link to post
Share on other sites
Quote:
Original post by Anonymous Poster
Quote:

Anyway for most situations masking is pretty useless


For transparent object you have to order them from back to front before drawing them or you get incoorect results. It is also slower to render, because it must read the current contents of the backbuffer before render (to blend with it).

For masking you can just render them normally like a solid mesh, but you can only have a hard edge in your textures. Plant rendering among a vast range of other things benifit from this since you do not waste your CPU ording each triangle, so I wouldnt call it useless, since it is used all the time in current high-end games.


This is what alpha-testing is for isn't it?

Share this post


Link to post
Share on other sites
Quote:
Original post by Anonymous Poster
Quote:

Anyway for most situations masking is pretty useless


For transparent object you have to order them from back to front before drawing them or you get incoorect results. It is also slower to render, because it must read the current contents of the backbuffer before render (to blend with it).

For masking you can just render them normally like a solid mesh, but you can only have a hard edge in your textures. Plant rendering among a vast range of other things benifit from this since you do not waste your CPU ording each triangle, so I wouldnt call it useless, since it is used all the time in current high-end games.


1. as Boder said, that's what alpha-testing is for.

2. masking still needs to read from the backbuffer, infact it has to do that two times per pixel, alpha blending only has to do that once per pixel and alphatesting does not have to do that at all.

3, it's allmost never used anywhere because of 1 and 2.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
I assumed you were talking about alpha testing, i wasnt aware that there was an in-between/alternate(?) version of alpha blending/testing in openGL. Granted Ive only done a little bit of openGL programming, but it sounds to me like it is totally pointless, due to the high overhead and same(?) results as transpent/tested blending.

Share this post


Link to post
Share on other sites
The technique (Lesson 20) works like this.

Use glBlendFunc(GL_DST_COLOR,GL_ZERO) to draw the mask, which turns all black parts of the mask image to black in the frame buffer.

Then, with an image where black should be transparent, use glBlendFunc(GL_ONE, GL_ONE) to perform an additive blend. The transparent part (black) of course doesn't affect the frame buffer, and the color part is blended with black (because of the mask).

Share this post


Link to post
Share on other sites
So does it take alot of processing to do so? On the tutorials they run pretty fast. I chopped mine down into a few lines of code simple but using some for satements :D

Share this post


Link to post
Share on other sites
The tutorials are more cpu limited than gpu limited and runs OMGWTFPWN fast so any speed diference won't be noticable unless you use losts and lots of polygons, like more than 10000.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!