DIfferent masking schemes

Blitz3D Forums/Blitz3D Programming/DIfferent masking schemes

Beaker(Posted 2003) [#1]
I've noticed that Blitz and other games vary in the look and style of the edge they create when masking textures.

For instance, HalfLife has a nice rounded edge, Blitz has a fairly octagonal edge and PikMin has a square edge.

They all seem to have their place dependant on where and what you use them on.

Question is: I presume that Mark creates the mask on loading the texture, but could we and should we have access to the way in which these are created?

Something else I don't quite understand is why masked textures get sorted correctly and alpha textures do not? They are essentially the same thing I thought.

I know why alpha textures *aren't* sorted, but I don't understand how masked textures are.

Any ideas?


skidracer(Posted 2003) [#2]
In theory masked textures don't have to read and mix with the pixels behind them so can be drawn in first pass with all the solid surfaces using standard perpixel zbuffering.

Blitz does give you certain control, when you writepixel to a masked texture you either have the high 8 bits set or clear depending on mask but when bilinear filtering comes along most cards will still mix the rgb component of clear pixels in with the solid ones around edges so it does make a difference what color you set the masked bits too on some cards.


Beaker(Posted 2003) [#3]
I understand. Are you also saying that the granular shape of the edge of the masked pixels is down to the way in which different games bi-linear filter? Blitz always creates a hex/octagonal shape for example.

Or, can anyone explain why these shapes differ?


Pudding(Posted 2003) [#4]
This is how I understand it:

In most engines this kind of masking is called "alpha testing." With alpha testing you pick a threshold value and a test to perform (e.g. greater than, less than etc.); now if the alpha component for a particular pixel in the texture passes that test (e.g. greater than 128) that pixel will be transparent.

The different edges you describe (rounded, octagonal, square) can result from differences in the alpha channel. For example, some texture formats might only have a one bit alpha channel resulting in square pixel edges. Eight bit alpha channels that are also bilinear filtered result in nice rounded edges (a greater than 128 operation will find nice curves through a blurred 8 bit alpha channel). The sharpness of the original alpha and the threshold value also effect the edge shapes.

It would be nice to have more explicit control of the alpha testing in Blitz. You can do some interesting things with the threshold value and the testing operation.

e.g. volumetric textures: create a texture with a "heightfield" alpha channel; now create a stack of planes and texture each plane with the same texture but with a threshold value less than the plane below it - voila, a cheap volumetric effect from a single texture! (if you can't see it, picture it like those those topographical models made from slices of cardboard cut from contour maps but in this case the countours are defined by the threshold values)