Jump to content
  • Advertisement
Sign in to follow this  
ViperG

Selective Sprite Blending - Adding Damage in 2D

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

Ok i'm making a 2d game called Black Sky www.blackskygame.com So im in Ortho mode, and I have depth testing off. Blending is on. Is there anyway I can draw decals/sprites and only have them blend with a certain sprite? I want to add battle damage to my ships, but I only want the decal to blend into the ship, and not blend on the background.

Share this post


Link to post
Share on other sites
Advertisement
Never done such things, but the stencil buffer may help you.

Just set the stencil buffer to zero everywhere except for the pixels of the only sprites you want to blend.
When rendering the "blending" sprites (the decals) write the pixels only where the stencil buffer is nonzero.

Using different stencil values for different objects I think you can create very interesting effects!

Hope you know what the stencil buffer is, otherwise my post will not be really helpful! :P

Share this post


Link to post
Share on other sites
Yeah i sorta do. Can anyone show me a quicky psuedo example of overlapping two polly gons, but only draw the second polygon where the first one is already drawn.

Doesn't even need to be code really. Step by step with just theory works for me :D

Or point me to a simple stencil tutorial please :D

Thanks Dave

[Edited by - ViperG on May 23, 2005 7:58:47 PM]

Share this post


Link to post
Share on other sites
Different subject, but it shows a nice simple use of Stencil Buffering:

http://www.devmaster.net/articles/projectiveshadows/

I think that may be overkill for your needs, though. I think multitexturing would do the trick: setting the second texture layer to your damage decal and setting it to modulate blending, then tweaking the texture coordinates to get the correct positioning. MAy not work for your needs, but it's a thought.

EDIT: Hyperlinked for great justice!

Share this post


Link to post
Share on other sites
Well, I gave it a shot, using the stencil buffer that is, and it killed my fps big time.

I just placed it on 1 polygon, where as I was getting 280 fps. But then once I opengl to also draw it in the stencil buffer, my fps dropped to 40 :(. And it was a pretty small poly gon. Probably only took about around 100~200 pixels.

I'll play with it some more. But that is what I got :(.

Share this post


Link to post
Share on other sites
Quote:
Original post by ViperG
...my fps dropped to 40 :(. And it was a pretty small poly gon. Probably only took about around 100~200 pixels.


What!?
I know the stencil buffer has some overhead, but this seems just too much overhead!
It may be a problem with the graphics card, I heard that older card (5+ years old) have performance troubles with the stencil buffer...
Just a guess, but are you sure you're hardware-accelerated? If not, it might be that the driver is emulating the stencil buffer in software!

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!