Jump to content
  • Advertisement

Archived

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

Jiia

Bit-Maps (Not images)

This topic is 5756 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have a situation in my game where all is needed is a Yes-No bitmap. Has anyone ever tried to use a map of single bits as a transparency map? And is there an effecient way to use them? I want to use them for a "water map" for each tile that would tell the graphics functions which pixels of a 32x16 image need to be drawn. It just seems insane to spend 8 bits on such a thing, considering the sizes of my maps. The problem is, I''m not sure how I would go about accessing them. It almost sounds like fate, though: 32 bits wide for each tile. Would it be unheard of to assign an unsigned long per line, for 16 lines? Wouldn''t that make accessing them pretty quick? Anyway, I''m just wondering if anyone has ever attempted this and had any problems. Appreciate any suggestions. Jiia

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster
quote:
Original post by Jiia
I have a situation in my game where all is needed is a Yes-No bitmap. Has anyone ever tried to use a map of single bits as a transparency map?
Are you refering to a bit-mask?
quote:
Original post by Jiia And is there an effecient way to use them? I want to use them for a "water map" for each tile that would tell the graphics functions which pixels of a 32x16 image need to be drawn.
So instead of animating the tiles, you want to mask off the portions that would make them seem to move?
quote:
Original post by Jiia It just seems insane to spend 8 bits on such a thing, considering the sizes of my maps.[/quotes]8-bits of alpha? I believe there are some texture formats that have a 1-bit alpha transparency.
[quote]Original post by Jiia
The problem is, I''m not sure how I would go about accessing them. It almost sounds like fate, though: 32 bits wide for each tile. Would it be unheard of to assign an unsigned long per line, for 16 lines? Wouldn''t that make accessing them pretty quick?
Look into the alpha channel of a texture format. Although this seems permanent, after creating alpha masks, I would see if there was a way to combine the textures using the alpha channel of one texture and the color channel of the other. Otherwise I would mask off the portion on the screen that I didn''t want to be covered with the stencil buffer and the render the water tiles.

Bear in mind I''m guessing at what you are trying to do. I''m thinking you are doing a 2d tile scrolling game with a 3d api and you want to animate the waves of water without storing a 128x128 texture with the animations for the waves.

Share this post


Link to post
Share on other sites
I'm sorry, I should have been more clear. Yes, my game is 2D but my graphics API is custom built, but uses Normal DirectDraw 7 to finally transfer to the screen.

What I was asking is a little more simple than what your answer seems to be to. My water does use an alpha map when it is drawn, but the Bit-Mask doesn't apply to it. A single type of liquid on a tile would be a single animated image, 32x16. For example, I would have a single "swamp" image that would be drawn on every tile that used that type of liquid, yet only one image of it will be allocated. The liquid on the tile doesn't have to cover the entire tile. It actually forms around the land, so not every pixel will contain the swamp or water. The bitmask was to hold that info, about which pixels had water. An alpha mask would have also worked, but I plan to have all of the liquid at the same opacity, even when it is very deep.

I'm thinking I would just have to do something simular to this, right?..
ULONG Mask[16];
int x,y;
for(y=0; y<16; y++)
{
for(x=0; x<32; x++)
if(Mask[y] & (1 << x))
DrawPixel(x,y);
}
Would this be as effiecent as using a normal BYTE or LONG mask?
Thanks,
Jiia

[edited by - Jiia on September 14, 2002 11:46:34 AM]

Share this post


Link to post
Share on other sites
I think I know what you''re after... water that covers terrain, but does not conform to tile edges or fringing?

Hmm... For each tile, make a "pointer to an bitmask", and a 2 bit variable, "waterstate". If the "waterstate" is 01 (1), there''s no water here. If 10 (2), there''s nothing but water here. If 11 (3), there is partial water here. If (11), make that "pointer to bitmask" point to something. Otherwise, give it a NULL pointer.

Now, this whole system would still be a waste of memory. What I''d suggest for efficiency is to use pre-generated fringe masks. So, these will still be bitmasks/alpha values for when you draw the water, but they will be selected and generated out of a selection of pre-made bitmasks, instead of making a bitmask for each individual edge-of-water tile.

However, since these are simple Yes/No (1-bit per pixel) bitmaps, you can make quite a lot without terribly high memory costs. You could make quite a bit of variety, as long as you can write the fringe-generating algorithm for it.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
I believe with stencil buffers you have to render with the 3D hardware. This is what I suggested to begine with.

Another suggestion might be to use one of the D3DX functions to render your sprites in the manner you are acustom.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
er..to allow stencil buffering with 3D hardware in a 2d paradigm I mean.

Share this post


Link to post
Share on other sites
Want to see my current progress? I'm just developing this landscape routine, I've never really done anything like this before. You can also see how simple the water really is, and how it conforms to the land. This is straight up 2D. Tell me what you think.
Take a look here: http://www.geocities.com/jiiqs/Snap.jpg

Kylotan: Oh no, not another new word!

Wyrframe said "I think I know what you're after... water that covers terrain, but does not conform to tile edges or fringing?"

Yes, exactly.

Wyrframe said "Hmm... For each tile, make a "pointer to an bitmask", and a 2 bit variable, "waterstate". If the "waterstate" is 01 (1), there's no water here. If 10 (2), there's nothing but water here. If 11 (3), there is partial water here. If (11), make that "pointer to bitmask" point to something. Otherwise, give it a NULL pointer."

That's a really great idea, but its still too much information for what I need. Think smaller, simpler. I haven't came up with how I will actually draw the water yet. I might use alpha maps so that I can create waves and such, but they will be larger images that cover several tiles.

Is there water? Or is there no water? That's the only information I want each pixel to contain. After this is known, I can draw high res images over these areas knowing which pixels to render and which not. My real question is the best way to go about this. Would the above example be as fast as using an array of BYTE's? Using BYTE's will cost 512 bytes per tile, while using bits will only cost 64. I won't be concerned about memory if using BYTE's will result in more speed, I just don't want to waste memory for nothing.

Thanks again,
Jiia

[edited by - Jiia on September 15, 2002 2:25:03 AM]

Share this post


Link to post
Share on other sites
Whoa, whoa, whoa! We''re talking 3D? Whole new info, here!

Looks like you''re doing software rendering on your own. First off, good for you! Second off, that terrain looks like triangles. Yes? Are you doing all your own rendering? If yes, the below paragraph will be useful...

As well as interpolating the X and Y values for each pixel of a polygon, interpolate the Z/Height values as well. Test them against the waterheight (local or global, whatever). If we''re above water, normal rendering is performed. If below water, we''ll either draw this pixel blue-tinted, or we will draw this pixel blended with the water color.

Now, if what all I just said was off track, and I''m just going crazy...

Yes. A good idea might be to generate larger, say 4x4 tile bitmaps, although it might be a great idea to RLE-decode them in realtime. If you don''t know what RLE encoding/compression is, just ask. And don''t worry about slowdown... RLE decoding is often faster than raw data copying.

Hope this helps!

Share this post


Link to post
Share on other sites
Okay, so my land smoothing routine still needs work. Otherwise it would not look like polygons. This is 2D, 2D, 2D

Have you ever played with one of those useless "Pinhead" toys you can find at craft shops? That's exactly how my terrain works. But it is per pixel, 2D. So it can take any shape, except where points overlap vertically. It then generates tile images out of each 32x32 section, so drawing it within the game is just as fast as tiles, and the height map is kept for moving objects. I'm not sure if I should take thinking it is 3D as a compliment or an insult How does it look? Like crap?? And imagine it even more round and smooth, how about then?

[edited by - Jiia on September 15, 2002 10:39:03 AM]

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!