Jump to content
  • Advertisement
Sign in to follow this  
stenny

Special Effects Overlay

This topic is 4077 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

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

Share this post


Link to post
Share on other sites
Advertisement
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

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!