Sign in to follow this  
Richard Geslot

binary alpha

Recommended Posts

Richard Geslot    235



In order to avoid the need of sorting the objects that need a simple binary alpha mask, I'm forcing  the alpha transparancy to be only 0 or 1.





To do that, I have added this line in all my pixel shaders :

//force alpha to 0 or 1
if ( finalColor.w > 0.5f ) { finalColor.w = 1.0f; } else { finalColor.w = 0.0f; }

This doesn't seem very beautiful.

I'm wondering if there is another way to do that ?

Like a DirectX implemented feature ?


Thank you !

Share this post

Link to post
Share on other sites
C0lumbo    4411

For bonus points, use this technique to avoid jaggies on your foliage (not invented by Wolfire, but they have a relatively short clear explanation):


TLDR version: Render all foliage twice. First pass use clip/discard/alpha test on your foliage (as Hodgman describes). Second pass, render with alpha blending.


A more correct solution might be to look into alpha-to-coverage with multi-sample antialiasing.

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this