2896
NeoLemmix Main / Re: Alpha blending - how should it work for terrain?
« on: January 26, 2016, 11:46:06 AM »
Thanks for making the thread!
According to Wikipedia on alpha compositing: Let αbottom be the alpha component of the target image (real number between 0 and 1 inclusive, with 0 = fully transparent, 1 = fully opaque). Let αtop be the image that's blitted on top the bottom image.
Then, rule of alpha composition: αresult = αtop + αbottom (1 − αtop).
Corollary: We have both αresult ≥ αtop and αresult ≥ αbottom. So, when we stack images, the opaqueness per pixel may only increase.
Air/solid threshold: This is a rule to determine which pixels are solid, and which are air. Fix a threshold value. Whenever a pixel has opaqueness under that value, we make that pixel fully transparent instead. Otherwise, we leave it alone. The fully transparent pixels become air, all others become solid.
The corollary guarantees that, with the air/solid threshold, we can't punch holes into terrain by adding more pieces. (We would have to use eraser pieces.) This is very desirable, level designers can't screw up mistakenly by adding decoration.
A problem arises when the bottom tile is steel, and the top tile is normal terrain. The rule in NL and Lix has been: It's steel iff it looks like steel. This has worked for α = 0, 1 only. Anything here needs study of the full formula for colors in dependence of the alphas, not only for the alphas themselves.
-- Simon
According to Wikipedia on alpha compositing: Let αbottom be the alpha component of the target image (real number between 0 and 1 inclusive, with 0 = fully transparent, 1 = fully opaque). Let αtop be the image that's blitted on top the bottom image.
Then, rule of alpha composition: αresult = αtop + αbottom (1 − αtop).
Corollary: We have both αresult ≥ αtop and αresult ≥ αbottom. So, when we stack images, the opaqueness per pixel may only increase.
Air/solid threshold: This is a rule to determine which pixels are solid, and which are air. Fix a threshold value. Whenever a pixel has opaqueness under that value, we make that pixel fully transparent instead. Otherwise, we leave it alone. The fully transparent pixels become air, all others become solid.
The corollary guarantees that, with the air/solid threshold, we can't punch holes into terrain by adding more pieces. (We would have to use eraser pieces.) This is very desirable, level designers can't screw up mistakenly by adding decoration.
A problem arises when the bottom tile is steel, and the top tile is normal terrain. The rule in NL and Lix has been: It's steel iff it looks like steel. This has worked for α = 0, 1 only. Anything here needs study of the full formula for colors in dependence of the alphas, not only for the alphas themselves.
-- Simon