Special Effects Overlay

Started by
20 comments, last by stenny 16 years, 10 months ago
Good day, I'd like to know how to handle special effects overlay. This is probably not the official term, so I think I ought to explain what I mean. Special effect overlays are always used in 2d games. It's an image drawn over the screen to give a certain effect. These include weatherlike effects, lightbeams and so on. Some games that use these effects (and I can come up within this second) are Legend of Zelda: the Minish Cap, and a lót of RPGMaker games (hehe[grin]). I was wondering how this was done and how I could include these type of effects in my game, so I had a look into the directory of one RPGMaker game. This is one of the images it is done with: Simple, I at first thought...Just do something with alpha and the like, and it'll all come together. Not. When I thought for a second time I got to the conclusion that won't work. The screen will only be darkened for the dark parts, and even if I cut those out (transparent colours), it will only looks ugly. How is this done? -Stenny
What do I expect? A young man's quest to defeat an evil sorceror while discovering the truth of his origins. A plucky youngster attended by her brutish guardian. A powerful artifact which has been broken into a small number of artifactlets distributed around the world.What do I want? Fewer damn cliches. - Sneftel
Advertisement
Hi,

What programming lang are you using and what API?

I know you have pointed out some 2d games, but is this 3d?
It's going to be blended one way or another. Judging from the greyscale texture, it could be blended additively, or used as an alpha channel for some other image (possibly a single-colour overlay).

Tell us more about what it looks like in the game and we'll try to work out exactly what blending parameters are being used.

Admiral
Ring3 Circus - Diary of a programmer, journal of a hacker.
Thanks :). I'll try to give as much info.

I'm programming in c++ and using DirectX. I'm using Direct3D, but none of its 3D options.

Here is an example of a RPGMaker game that uses the kind of effect I'm looking for:



It's even the same picture used.

If you need more informatiom, please ask[smile]

-Stenny
What do I expect? A young man's quest to defeat an evil sorceror while discovering the truth of his origins. A plucky youngster attended by her brutish guardian. A powerful artifact which has been broken into a small number of artifactlets distributed around the world.What do I want? Fewer damn cliches. - Sneftel
It looks like the light effect image has an alpha channel in it that make it translucent. Then it is drawn on top of the seen. I can't tell if it is blended or not unless I could see the sprites with out the light effect on them.
Black CloakEpee Engine.
Hmm seems to me that it could be an alpha channel applied to a "light" picture and then perhaps it uses ADD or AND blending..
i am pretty sure it is a simple add, working in mguen i am used to those black background fx.
So you guys are suggesting I should use that picture as an alpha channel, and not just draw it over the screen with I-know-what.

Not that I know how to do that, but that's the idea right?

-Stenny
What do I expect? A young man's quest to defeat an evil sorceror while discovering the truth of his origins. A plucky youngster attended by her brutish guardian. A powerful artifact which has been broken into a small number of artifactlets distributed around the world.What do I want? Fewer damn cliches. - Sneftel
Actually I would recommend going with those who suggested additive blending. That way you shouldn't need to add any extra channels or use a separate translucency map, and it should, I believe, produce the effect that you're looking for.

MWAHAHAHAHAHAHA!!!

My Twitter Account: @EbornIan

You could alpha blend a white full-screen quad onto the screen, using that image as the alpha channel, but it's not the most direct way. Here's one method:

Load the image as a greyscale texture. Create a quad that spans the screen with appropriate texture coordinates - you could do this inline and call DrawPrimitiveUP, or you could put the quad into a vertex-buffer. It really doesn't make much difference in this case. When the time comes to add the effect, bind the texture to sampler 0 and call

IDirect3DDevice9::SetRenderState(D3DRS_SRCBLEND, D3DBLEND_ONE);
IDirect3DDevice9::SetRenderState(D3DRS_DESTBLEND, D3DBLEND_ONE);

(along with
m_pD3DDev->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE);
if you don't already have blending enabled.)

before rendering the quad. Rather than trying to render the new texture over the frame-buffer, or modulate the two together using an alpha value, it will simply add the texture's colour components to the existing image. The result is that black areas come out unchanged and white areas are lightened.

Remember to set the blend-mode back once you're done rendering. Presumably

IDirect3DDevice9::SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
IDirect3DDevice9::SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA);

Admiral
Ring3 Circus - Diary of a programmer, journal of a hacker.

This topic is closed to new replies.

Advertisement