PDA

View Full Version : GFX - Combining two images?



Firlefanz
12-11-2005, 01:40 PM
Hello,

the Omega forums are not much visited these days, I hope you don't mind if I post something here I already posted over there. If I find a solution for this matter, this would be a huge step ahead.

I am working on some additional GFX.

If my startship gets shot and is damaged, I have a 'broken' image.
I want to alphablend it on my starship image so it looks broken a bit.

When creating the starship, nkapx1 and nkapx2 are -1.

When the ship is damaged, they are random values from 0 to image.width/height -broken image width/height.

When they are >-1 they are drawn blended on the ships image.

The only problem is I have different ships and so if the ship is smaller or something (not fills the whole image) the broken image is 'coming out' of the ship image.

Any possibility to 'combine' the ship image with the broken image before drawing so the broken image is only drawn where the ship image is not black?

This would also give me the possibility to make monsters bleed.

Any idea how to do this?

Is the problem understandable?

Thanks,
Firle

Paulius
12-11-2005, 02:44 PM
Let you?¢_Tre objects have their own surfaces and update them when necessary, with appropriate blending modes, something like multiplicatively blending damaged stuff on top of the object and the object again additively on top.

Firlefanz
12-11-2005, 02:47 PM
Hi Paulius,

thanks for the reply.
I am having a 2D sprite here with only an image with pixel=black other pixels <> black. No 3D body or something.

Can I just combine 2D images one only drawn where the other is not black?

Firle

Paulius
12-11-2005, 11:56 PM
I don?¢_Tt use Direct3D, but googling gave me this for multiplicative blending
device.SetRenderState(D3DRS_SRCBLEND, D3DBLEND_ZERO);
device.SetRenderState(D3DRS_DESTBLEND, D3DBLEND_SRCCOLOR);
Multiplying will kind of do what you want, incoming white fragments won?¢_Tt affect what was already there, but darker fragments will darken it, if the destination is black the result will remain black. Alternatively you could use multitexturing with appropriate combining to do this with one pass, but I?¢_Tm not sure how comfortable it would be with Omega.

LP
13-11-2005, 01:41 AM
I think you can do this by drawing your character to a render-target first (which includes alpha-channel), then apply any broken/bleeding effect to it. After that, use the render target as texture to draw it on the screen. Of course, another solution (which gives pretty the same result) is when your ship and its damaged image have the same size (in proportions), you can draw them both using multi-texturing.

Personally, I think using render-target is better idea, since multi-texturing is very hardware-dependent (or at least, more dependent, than the support for a single render target).

Firlefanz
13-11-2005, 10:09 AM
Hi Paulius and Lifepower,

thanks for the replies. I tried a few things, and that idea with the rendertarget is very good. Unfortunately I guess my idea was not so good, it works for not animated chars, but most things are animated, and then it does not look very good because the blood or damage image is not moving. I must find an other way, right now I am thinking about let damaged stuff smoke. I think I make a new topic if somebody can give me some nice particle formulae for X and Y because I am not very good at maths. :wink:

Firle