Pixel masking in GLB?

Previous topic - Next topic

doimus

I'm mondering how something like this can be done in GLBasic:
(sorry for a bit large images)

Example is from Bioware's Baldur's Gate, RPG from 1998.
Running on Infinity Engine, one of the finest 2D engines ever made.


On image A we got our character (guy at the bottom) in front of a tree.
On image B the character is behind the tree, and is drawn shaded, to appear obscured by the tree.
On image C character is only partially obscured by the tree.

What is interesting here is that background is completely static all the time. Background is made from a single image, it's not like the tree id drawn after the character - it's only character's sprite changing it's shade.

Here's how it's done in Infinity Engine:


The white outline here depicts the mask which determines shading of the character pixel. When any part of the character is inside that mask it gets shaded (it's actuall drawn with every odd pixel left out).
That mask is sorted by vertical axis too, as shown in image A. Although the part of the character is inside the mask, it's still drawn, since the character sprite is lower on vertical axis (ie. "in front" of the tree).

I know this is basically specific software-2D technology here, but could something similar be done in GLB? Some kind of invisible polygon that would affect the shading of the character sprite/polygon).
Of course, it could all be done in pure 3D, or by drawing specific sprites in specific order (kind of 2.5D), but I'm interested in this particular approach, with single background with masks.

Kitty Hello

I can think of 2 ways.

Check every drawn background with SPRCOLL against all players. If you have contact, you must draw the hidden player part strippled.

1st  Method -> Use a shader to draw every other pixel, only, then draw the complete player again.
2nd method -> Have a strippled image for every player in memory and DRAWSPRITE that.