Override champion mirror rendering?
Moderator: Sophia
Forum rules
Please read the Forum rules and policies before posting.
Please read the Forum rules and policies before posting.
- Gambit37
- Should eat more pies
- Posts: 13715
- Joined: Wed May 31, 2000 1:57 pm
- Location: Location, Location
- Contact:
Override champion mirror rendering?
Is it possible to override how champion mirrors are drawn? I'd like to improve them, so that their contained champion portrait is rendered at all wall positions (not just front1). But I can't find anything in the base code that handles this?
- Sophia
- Concise and Honest
- Posts: 4240
- Joined: Thu Sep 12, 2002 9:50 pm
- Location: Nowhere in particular
- Contact:
Re: Override champion mirror rendering?
It isn't handled in the base code at all aside from setting a renderer_hack, which tells the engine to draw the champion portraits. So to do anything beyond that would have to be done in the core engine, and might be kind of a mess to do.
An alternate possibility would be to composite the images yourself using DSB's various graphics commands, and then just give each champion their own archetype for a mirror with their own picture on it. You can then dsb_qswap to a blank mirror when the champion is actually taken.
An alternate possibility would be to composite the images yourself using DSB's various graphics commands, and then just give each champion their own archetype for a mirror with their own picture on it. You can then dsb_qswap to a blank mirror when the champion is actually taken.
- Gambit37
- Should eat more pies
- Posts: 13715
- Joined: Wed May 31, 2000 1:57 pm
- Location: Location, Location
- Contact:
Re: Override champion mirror rendering?
Perfect, yep, I can do that alternate suggestion, thanks.
- Gambit37
- Should eat more pies
- Posts: 13715
- Joined: Wed May 31, 2000 1:57 pm
- Location: Location, Location
- Contact:
Re: Override champion mirror rendering?
I clone the mirror and pass precomposed images to the clone. Let's say the clone is obj.mirror_zed. What other settings in this arch do I need to change to disable the core mirror rendering? DSB still renders an extra portrait at front1 view. Or should I not clone the mirror at all and just create a wallitem, since I'm going to write my own resurrect function anyway?
- Gambit37
- Should eat more pies
- Posts: 13715
- Joined: Wed May 31, 2000 1:57 pm
- Location: Location, Location
- Contact:
Re: Override champion mirror rendering?
OK, well this seems to work fine as my archetype:
However, I'm struggling to pre-compose my mirror graphics using DSB bitmap functions.
Both images have alpha channels (the champion portrait, and the mirror) and when I use dsb_bitmap_blit to merge the the portrait onto the mirror, the alpha pixels of the portrait overwrite the mirror beneath and create unwelcome gaps:
If I instead use dsb_bitmap_draw to merge the two bitmaps, the alpha channel isn't respected at all and is replaced by black + some weird junk.
How can I merge these images in code and preserve the alpha channels?
Or do I need to just give up and prepare 24 pre-composed images in PhotoShop? I can certainly do that, but I was hoping to avoid it in case I want to modify the portraits. (better to just export them from PhotoShop once, and let DSB handle merging them with other graphics, rather than having to update a whole bunch of PhotoShop files and re-export multiple times)
Code: Select all
obj.mirror_zed = {
type="WALLITEM",
class="CHAMPION_HOLDER",
on_click=custom_resurrect
no_party_clickable=true,
default_silent=true,
front=gfx.mirror_front_zed,
side=gfx.mirror_side_zed,
}
Both images have alpha channels (the champion portrait, and the mirror) and when I use dsb_bitmap_blit to merge the the portrait onto the mirror, the alpha pixels of the portrait overwrite the mirror beneath and create unwelcome gaps:
Code: Select all
mirror_front_w = dsb_bitmap_width(gfx.mirror_front)
mirror_front_h = dsb_bitmap_height(gfx.mirror_front)
for i = 1, table.getn(champion_names) do
portrait = "port_" .. champion_names[i]
gfx[portrait] = dsb_get_bitmap(path .. portrait)
mirror_front_new = "mirror_front_" .. champion_names[i]
-- Create new Front image
gfx[mirror_front_new] = dsb_new_bitmap(mirror_front_w, mirror_front_h)
-- Copy original mirror into new image
dsb_bitmap_blit(gfx.mirror_front, gfx[mirror_front_new], 0, 0, 0, 0, mirror_front_w, mirror_front_h)
-- Copy current portrait [i] into new mirror
dsb_bitmap_blit(gfx[portrait], gfx[mirror_front_new], 0, 0, 26, 18, mirror_front_w, mirror_front_h)
-- Offsets
gfx[mirror_front_new].y_off = -16
end
How can I merge these images in code and preserve the alpha channels?
Or do I need to just give up and prepare 24 pre-composed images in PhotoShop? I can certainly do that, but I was hoping to avoid it in case I want to modify the portraits. (better to just export them from PhotoShop once, and let DSB handle merging them with other graphics, rather than having to update a whole bunch of PhotoShop files and re-export multiple times)
- Sophia
- Concise and Honest
- Posts: 4240
- Joined: Thu Sep 12, 2002 9:50 pm
- Location: Nowhere in particular
- Contact:
Re: Override champion mirror rendering?
If I understand what you're trying to do correctly, you should dsb_bitmap_blit the first image, and then dsb_bitmap_draw the second one. That will copy the mirror image directly to the new bitmap, overwriting everything, and then draw the portrait on top of that, respecting the portrait's alpha.
As an aside, whenever you see an image that is black + some weird junk, you are typically looking at uninitialized memory, which is mostly 0 (black) but not completely (the weird junk); DSB doesn't initialize a bitmap created by dsb_new_bitmap so it's full of whatever is there before. You'd see that if you tried to dsb_bitmap_draw a bitmap with alpha onto an uninitialized bitmap.
As an aside, whenever you see an image that is black + some weird junk, you are typically looking at uninitialized memory, which is mostly 0 (black) but not completely (the weird junk); DSB doesn't initialize a bitmap created by dsb_new_bitmap so it's full of whatever is there before. You'd see that if you tried to dsb_bitmap_draw a bitmap with alpha onto an uninitialized bitmap.
- Gambit37
- Should eat more pies
- Posts: 13715
- Joined: Wed May 31, 2000 1:57 pm
- Location: Location, Location
- Contact:
Re: Override champion mirror rendering?
Aha, perfect, that works
It's been a while since I've done any of this stuff with DSB and I've forgotten a lot of the details around the various functions. Thanks for clarifying.
It's been a while since I've done any of this stuff with DSB and I've forgotten a lot of the details around the various functions. Thanks for clarifying.
- Sophia
- Concise and Honest
- Posts: 4240
- Joined: Thu Sep 12, 2002 9:50 pm
- Location: Nowhere in particular
- Contact:
Re: Override champion mirror rendering?
You might also want to define your archetypes in a loop pulling from the same champion_names variable instead of having to copy/paste everything multiple times. You can programmatically add to obj the same way as you can add to gfx, which is one of the things that makes DSB so flexible. (And confusing at times...)
- Gambit37
- Should eat more pies
- Posts: 13715
- Joined: Wed May 31, 2000 1:57 pm
- Location: Location, Location
- Contact:
Re: Override champion mirror rendering?
Yep, I have a loop for that too:
It would be great if I could avoid defining the champion names table and pick them up directly from the dungeon.lua, but I assume dungeon.lua is always parsed last which is why that wouldn't work?
Code: Select all
for i = 1, table.getn(champion_names) do
mirror_name = "mirror_" .. champion_names[i]
gfx_front = "mirror_front_" .. champion_names[i]
gfx_side = "mirror_side_" .. champion_names[i]
obj[mirror_name] = {
type="WALLITEM",
class="CHAMPION_HOLDER",
champion=string.upper(champion_names[i]),
on_click=custom_resurrect,
no_party_clickable=true,
default_silent=true,
front=gfx[gfx_front],
side=gfx[gfx_side],
}
end
- Sophia
- Concise and Honest
- Posts: 4240
- Joined: Thu Sep 12, 2002 9:50 pm
- Location: Nowhere in particular
- Contact:
Re: Override champion mirror rendering?
Right. You could probably make it work with some custom additions to dungeon.lua but nothing that will survive a load and save in ESB, so this is the best we can do.
- Gambit37
- Should eat more pies
- Posts: 13715
- Joined: Wed May 31, 2000 1:57 pm
- Location: Location, Location
- Contact:
Re: Override champion mirror rendering?
Heh, I was just looking at some old DSB threads and it seems I asked the same thing 6 years ago!