Archived

This topic is now archived and is closed to further replies.

Davaris

Baldurs Gate: Making creatures transparent

Recommended Posts

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:12:31 PM

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Here''s how I do in my own game:
(http://www.envy.nu/valkin2/en)

I draw everything normally, then, for each object that I want
to be seen even when obscured (eg characters, objects), I
draw them again with transparency. If nothing was obscuring
them in the first place, they appear as if nothing was drawn
over them (since the new alpha''d color is the exact same as
the original one), and if something had obscured it, it will
appear in a ghostly way.
This way, it''s pixel perfect.

In BG though, seeing that the gfx are interlaced, it''s possible
that they draw the scene twice, first time drawing even pixels,
then draw characters (all pixels) then draw the scene with only
odd pixels. Probably would make bad use of the cache though.

OTOH, you''ll need the solution you mention if you want to have
Z information to know what must be drawn over and what must be
drawn under.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Cheers
I was thinking that it would be even faster using hardware.
I use only software rendering, so fillrate is an issue.
Next game will be OpenGL

Share this post


Link to post
Share on other sites
usually, the objects in the game are all given zOrder values, the lower the value, the sooner the object is drawn.

thus you merely then need to check collision with objects of higher zOrder, with objects of higher zOrder, and change the transparency accordingly.

-vulcan

Share this post


Link to post
Share on other sites
Hey don''t do the OpenGl thing dude! I just tried it and it didn''t work out (a major waste of time). The problem is the animations. If you need to have a lot it takes up too much memory. Just one of my critters would take up 8 meg. So if you want to keep it isometric keep it in software. Otherwise go full 3D thats what the cards are designed for.

Share this post


Link to post
Share on other sites
What do you mean by "don''t do the OpenGL thing"? And what is this about one critter taking 8 MB? If you mean it''s the space taken by all animation frames, that''s not a problem. It would be totally stupid to upload each and every possible animation to the video card. Store them in disk, and read them when necessary. Even better, group related motions and read whole groups at once.

If you use OpenGL for 2D rendering, it''s not that different from an engine using DirectDraw, for example(I''m speaking about funcionality). The OpenGL version, however, can be hardware-accelerated on modern video cards, and that''s more than just bit-blting.


Gaiomard Dragon
-===(UDIC)===-

Share this post


Link to post
Share on other sites
Unless you have an awesome machine you are going to get a slow down when you load the images for an animation. If the images aren''t RLE compressed or something like that you are going to get a big slow down. I tried it. It didn''t work well at all. And all that power of two stuff is a real pain in the neck to deal with as well. I''ve heard that the new cards are finally doing away with it and allowing images of any dimension.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Yes Davaris, this is a good point.
I thought of this, but I don''t have that many anims.
I think I''ll try OpenGL anyway, just for a change
I was thinking of doing a small RTS, maybe even top down, so
the problem would go away, as rotation is free and would
allow me to get any kind of direction. This should not take
much texture space.
Well, time will tell

Share this post


Link to post
Share on other sites