Hashed alpha testing

We have 3 types of transparencies:

  1. None (fully opaque)
  2. Mask (some parts are 100% transparent some parts are 100% opaque)
  3. Blended

I recently wrote about the Blended kind, which is the most flexible and generic case.

But masked transparency is bread and butter of transparencies, it’s less impressive but whenever you see a tree with leaves or some grass in a video game - you’re most-likely looking at masked transparency in action.

Long story short, I implemented “Hashed Alpha Testing” technique a while ago for Shade

But I wasn’t using it, because the main purpose I implemented it was for the 3rd case, and I wasn’t happy with the noise.

Recently I was testing the Emeral Square scene, which has a lot of foliage.


The problem is - that foliage disappears as you zoom out, because of mipmapping, which is the exact problem that hashed alpha was invented to overcome. Here are a few screenshots from the paper to demonstrate

So I figures I would use it for masked transparencies, which yields pretty spectacular results


here’s side-by-side


And closer up




The technique requires a good TAA implementation to be stable, which I have, so it was a free win for me.

6 Likes

The comparison images seems to have too much compression , are you posting the images anywhere else ? (like a blog or something)

Sadly I have no blog, but here are raw screenshots side-by-side taken with low resolution, I’ll use three.js for comparison because it implements standard alpha masking:

Hashed alpha (Shade)

Standard alpha masking (three.js)

Here’s a different view on the same square, closer to the tree


You can see how the leaves on the tree in the middle become visible when you get closer, when using standard masking, and how the foliage remains pretty much the same when using hashed alpha, regardless of the distance.

If you look really close, you can see a few pixels of grass starting to appear on the lawn as well, whereas with hashed alpha the grass is perfectly visible at every distance.

If we keep zooming on the grass with the standard masking, we eventually start to see it

1 Like