(done) Window spell mask

This forum is for the Lua scriptable clone of DM/CSB called Dungeon Strikes Back by Sophia. Use DSB to build your own highly customised games.

Moderator: Sophia

Forum rules
Please read the Forum rules and policies before posting.
Post Reply
User avatar
Gambit37
Should eat more pies
Posts: 13714
Joined: Wed May 31, 2000 1:57 pm
Location: Location, Location
Contact:

(done) Window spell mask

Post by Gambit37 »

It seems the widow spell is masked to the wall it appears on?

I created an animated visual glow around it that spills out larger than the wall and the extra stuff was cropped off.

Is it possible to get around this?
User avatar
Sophia
Concise and Honest
Posts: 4239
Joined: Thu Sep 12, 2002 9:50 pm
Location: Nowhere in particular
Contact:

Re: Window spell mask

Post by Sophia »

The wall that the window is on as well as the window itself are drawn onto a temporary bitmap, and then that temporary bitmap is drawn to the dungeon view. There is no easy way around this, but I have an alternate idea.

Why don't we make your actual wall window image a simple mask that shows the hole in the wall, and then have the animated visual glow be a separate effect that is drawn directly into the viewport? If this sounds good I'll add an option to do it this way to DSB 0.70.
User avatar
Gambit37
Should eat more pies
Posts: 13714
Joined: Wed May 31, 2000 1:57 pm
Location: Location, Location
Contact:

Re: Window spell mask

Post by Gambit37 »

That could work, thank you.

Would the mask include the static part of the wall graphic (the bit inside the wall simulating the perspective of how the bricks look)? Or just the pink hole? And the overlay is just the outer animation (the cyan colours in the image below):

Image
User avatar
Sophia
Concise and Honest
Posts: 4239
Joined: Thu Sep 12, 2002 9:50 pm
Location: Nowhere in particular
Contact:

Re: Window spell mask

Post by Sophia »

The exact division between the images is up to you. I personally would put as little as possible in the part that drew the hole in the wall because DSB's handling of graphics that put 'holes' in other graphics (e.g., magic windows, door windows) is a bit strange, and if you're using alpha as opposed to power pink transparency on your wall graphics it will not work properly because it relies on drawing power pink onto the base image. On the other hand including the bricks in the "hole" graphic probably makes it easier to align them... so it's your choice really!
User avatar
Gambit37
Should eat more pies
Posts: 13714
Joined: Wed May 31, 2000 1:57 pm
Location: Location, Location
Contact:

Re: Window spell mask

Post by Gambit37 »

Cool, thanks. I have tested the above image and both the power pink creates the hole and the alpha is respected, so it works already. It's just the cropping to the wall shape that is currently a bit limiting.
User avatar
Sophia
Concise and Honest
Posts: 4239
Joined: Thu Sep 12, 2002 9:50 pm
Location: Nowhere in particular
Contact:

Re: Window spell mask

Post by Sophia »

What I meant was, it needs to draw the power pink at full alpha to "cut" a hole in the wall bitmap. This means that the hole must be in the part of the image that is drawn directly onto the wall-- this won't matter, because wanting a hole bigger than the wall won't make sense anyway. (This also means that walls that use alpha transparency instead of power pink based transparency simply won't work with wall windows at the moment!)

Any glow or whatever that doesn't actually need to affect the wall can be drawn afterward.
User avatar
Gambit37
Should eat more pies
Posts: 13714
Joined: Wed May 31, 2000 1:57 pm
Location: Location, Location
Contact:

Re: (done) Window spell mask

Post by Gambit37 »

I never got around to investigating this at the time you implemented it. Do you have a code example of how to do this as I can't work it out, thanks.
User avatar
Sophia
Concise and Honest
Posts: 4239
Joined: Thu Sep 12, 2002 9:50 pm
Location: Nowhere in particular
Contact:

Re: (done) Window spell mask

Post by Sophia »

In your call to dsb_make_wallset_ext pass a table including the two bitmaps rather than the single "hole" bitmap. The first entry in the table is the hole, the second is the glow to add to the viewport.
User avatar
Gambit37
Should eat more pies
Posts: 13714
Joined: Wed May 31, 2000 1:57 pm
Location: Location, Location
Contact:

Re: (done) Window spell mask

Post by Gambit37 »

OK, thanks. Is there a special way to create the hole bitmap? The one in the graphics.dat uses black for the outer transparent bit and powerpink for the hole in a 4-bit bitmap, but I'd like to use either an 8-bit or even 24-bit bitmap.
User avatar
Sophia
Concise and Honest
Posts: 4239
Joined: Thu Sep 12, 2002 9:50 pm
Location: Nowhere in particular
Contact:

Re: (done) Window spell mask

Post by Sophia »

It uses a 4 bit bitmap because it's straight from DM, but you can use an 8 bit bitmap also and it'll still work. Color 0 is the transparent portion and power pink is the "hole" in the wall.

As noted above, this means there's no support for alpha channels. DM's graphics don't need it, and it'd be a big enough overhaul that given my current (lack of) investment in developing DSB it is something I have no plans to change.

You can of course use 24 bit bitmaps (and alpha channels) on the "overlay" portion of the wall window so you should hopefully still be able to get whatever effect you want.
User avatar
Gambit37
Should eat more pies
Posts: 13714
Joined: Wed May 31, 2000 1:57 pm
Location: Location, Location
Contact:

Re: (done) Window spell mask

Post by Gambit37 »

Perfect. Yep it's the glowy part that would need alpha. Thank you 😁
User avatar
Gambit37
Should eat more pies
Posts: 13714
Joined: Wed May 31, 2000 1:57 pm
Location: Location, Location
Contact:

Re: (done) Window spell mask

Post by Gambit37 »

OK, so I tried the new setup and it doesn't seem to work. The "hole" image is correctly indexed as you specified, with black at index 0 and powerpink at index 1, but it only makes the middle transparent and doesn't punch a hole in the wall, and the outer black areas don't go transparent.

There are also some strange errors appearing to the left and right of the alpha overlay -- the left most 2 pixels of my front1 bitmap are missing (should be dark lines there), and there's a 2 pixel error on the right. (My front1 image is 4 pixels wider than DSBs default image).

Image
User avatar
Gambit37
Should eat more pies
Posts: 13714
Joined: Wed May 31, 2000 1:57 pm
Location: Location, Location
Contact:

Re: (done) Window spell mask

Post by Gambit37 »

Update: the two pixel edge error appears for either of the images independently, so it's not just about the alpha overlay.
User avatar
Sophia
Concise and Honest
Posts: 4239
Joined: Thu Sep 12, 2002 9:50 pm
Location: Nowhere in particular
Contact:

Re: (done) Window spell mask

Post by Sophia »

The edge weirdness is because your image is a nonstandard size and DSB isn't accounting for that. I'll fix that.

The black not being transparent and the hole not being created in the wall seems like there's something wrong with your images. Are they included in the archive you sent me?
User avatar
Sophia
Concise and Honest
Posts: 4239
Joined: Thu Sep 12, 2002 9:50 pm
Location: Nowhere in particular
Contact:

Re: (done) Window spell mask

Post by Sophia »

Ok, I figured out what was up with your images.

DSB creates the hole in the wall by first drawing the wall to a separate bitmap, and then it draws the hole onto the wall. Transparent pixels in the hole are masked via whatever means the image uses-- in DM, this is color index 0 for an 8-bit image, but what I forgot before was the alpha channel also works!, and that's actually how the wall images in the file you sent me seem to work. If you load the 8-bit image with dsb_get_mask_bitmap instead of dsb_get_bitmap it'll work, but I'd rather move away from using 8-bit images anyway, given this other information.

So my recommended fix is change your "under" image (i.e., the one that creates the actual hole in the wall, not the glow) to be a 32-bit image with transparent portions of alpha 0 and the actual hole in the wall colored power pink. It should all work fine, then.
User avatar
Gambit37
Should eat more pies
Posts: 13714
Joined: Wed May 31, 2000 1:57 pm
Location: Location, Location
Contact:

Re: (done) Window spell mask

Post by Gambit37 »

Cool, thanks for looking at that again. It's a better fix. Must admit I'm having fun getting all these bits in place finally! :-)
Post Reply