Baldurs Gate: Making creatures transparent

Started by
8 comments, last by Davaris 22 years, 4 months ago
As I understand it (in the Baldurs Gate engine) trees, rocks etc are part of a single image that is drawn onto the screen. My questions are these: Assuming they use alpha information in the image to make the creatures transparent when they walk behind a tree or a rock. How do they detect when a creature is behind a tree or a rock as opposed to infront of it? Then how would they copy only the useful information? Imagine the case of a tree just to the left and below the player and another tree just above and to the right of the player. My solution would be to create a poly line around each object and test this with the bounding rect of the creature. Then you have the problem of only using the alpha info inside the poly line to make that section of the creature transparent. I don't know if this is possible using hardware acceleration. Anyone have any ideas? Edited by - Davaris on January 2, 2002 6:13:36 PM
"I am a pitbull on the pantleg of opportunity."George W. Bush
Advertisement
All game objects have a position: whether its x,z for isometric games or if they choose to 3d space x,y,z. Isometric games usually draw objects in an order such that objects at the top of your monitor seem further back. Basically objects are drawn top-to-bottom, left-to-right.

If your player is higher up on the screen, then it has a postion further back into the map, then lets say a tree on the bottom of your screen. So, any objects drawn after your player and around your player, will be alpha blended with the scene.

The isometric forum is full of info if you dig around.

Hope that helps.
From what I understand they didn''t use the old isometric method. The castles, buildings and trees were all drawn in by the artists. Then this resultant image was blitted to the screen. Then on top of this image they drew the creatures and some how made parts of them transparent according to the overlap with the alpha channels.
"I am a pitbull on the pantleg of opportunity."George W. Bush
Hello there,

this is just an idea but i believe
they may use a destination alpha buffer.

Each pixel on the screen has an alpha value
and when the chars are blitted they use
a destination blend , for example a destination
of 255 would be opaque 0 would be transparent.

Some cards do this in hardware ( in OpenGL anyway )

Hope it helps ( And makes sense )

Mark
My ideas on this matter:

The alpha channel "dicates" where you can walk, can''t walk, and can walk but are behind something.

Then, when the character has to be drown, the alpha value for his *feet* is located, and that one decides if the character should be "invis" or "vis"

-Maarten Leeuwrik
"Some people when faced with the end of a journey simply decide to begin anew I guess."
Wouldn''t it have been easier to use layered blitting instead?

-----------------------------
The sad thing about artificial intelligence is that it lacks artifice and therefore intelligence.
SlimDX | Ventspace Blog | Twitter | Diverse teams make better games. I am currently hiring capable C++ engine developers in Baltimore, MD.
or you can sort the heights of all objects and draw them top to bottom

so if the player is in front of a object he is lower on the screen, and will get drawn on top of it, and if he moves up a bit, he will get drawn behind the object.
Just a guess, but : Z-Buffer

Have a seperate non-displayed "map" of depths - a z-map. Since the visible map is hand drawn, the "z-map" would have to be too.

Each Frame:

Blit the Map to the Screen
Init the Z-Buffer with the Z-Map

Then for each object (character, monster, NPC, etc.) Get the Depth of the point at the objects base (as suggested above) and use this as the objects z-value.

For each pixel of the object compare to the Z-Buffer and only draw if it's closer to the viewer. Updating the z-buffer accordingly so that objects are drawn on top of each other properly.


EDIT: cleaned it up so it resembled actual english

Edited by - Peeper on January 3, 2002 11:14:56 AM
I remember the Baldurs Gate people mentioned something about height maps. At the time I wasn''t a programmer so I assumed it was for something else. Perhaps they were refering to something like your idea Peeper.
"I am a pitbull on the pantleg of opportunity."George W. Bush
I just had a look at the hacker editor. And I think this is the way to do it.

The artist fills out all areas with blocking objects using the bitmap's alpha channel.

Then a tool the programmer creates modifies the bitmap in the following way:

bool alpha_set = false;

for (x=0; x < image_width; x++)
{
for (y=0; y < image_height; y++)
{
if (isapha (x, y, image) != 0)
{
if (!alpha_set)
{
alpha_set = true;
alpha = y*image_width;
}
set_alpha (alpha, image);
}
else
alpha_set = false;
}
}

This information can be saved in an unsigned 16 bit array. I noticed that their height maps and light maps are save in 16 and 256 color bitmaps. Perhaps the same can be done with this data.


Now after you have drawn the player you use the alpha info from the area map in the following way:

Each alpha pixel that overlaps the player and whose alpha value is greater than the player's feet (is in front of player) draw a dark pixel. Otherwise the pixel is behind the player so do nothing.



Edited by - Davaris on January 3, 2002 11:28:25 PM
"I am a pitbull on the pantleg of opportunity."George W. Bush

This topic is closed to new replies.

Advertisement