Jump to content
  • Advertisement
Sign in to follow this  
datadawgx

per-pixel "damage" rendering. possible?

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

hey guys. im spinning an idea and maybe some of you could give me ur opinion/experience with this. imagine having a textured quad used to represent a 2d space ship. would it be practical to have a 2d array of 8bit values to represent the per-pixel "damage" rendered on a textued quad? maybe the array would be used as an alpha map with a flat black-colored diffuse texture to show burn marks and such? im basically trying to create a per-pixel combat system. each pixel on an object's textured quad might be colored a different color to show damage. collateral damage might discolor surrounding regions. when the quad is transformed, the damaged pixels would need to transform with the quad precisely. that sort of thing... is this possible? has it been done? what approaches might work and which would surely fail? and of course, this is all done in directx 8.

Share this post


Link to post
Share on other sites
Advertisement
yeah that seems like pretty cool idea for a 2d game.

with only a few moments thought i would suggest doing it by:
keeping 2 textures for each sprite (quad), one for its actual texture, and the other for a net effects texture.

then in the physics section or whatever handles your damage, what you would do is each time a new damage effect is applied to the sprites texture, combinde the new texture (with alpha blending) onto the net effects texture. so it will hold the sum damage effects to the sprite, then obviously just render it ontop of its parent sprite each frame. cake!

as for your net effects texture, i would recommend keeping it in both system memory and video memory (D3DPOOL_MANAGED), so it doesnt need to be fetched from video memory each time you need to update it.

note that this method should only be used to store permanite damage effects...if its going to be animated or only temporary dont save it into the net effects texture. intead alpha blend the temorary texture (like an explosion) over top of the sprite.

good luck, your game sounds intresting!

Share this post


Link to post
Share on other sites
yes this all sounds like excellent advice. im not all that sure about the system and video memory thing... i dont think im there yet. see im not sure how to render to a texture from a 2d array of values. i can load raster images and render with those, but im talking about generating a texture on the fly, in real time.

Share this post


Link to post
Share on other sites
i have an idea on this... but a question:

is it possible to get the alpha channel value of a single pixel on a 32 bit texture?

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
are you using pixel shaders?

Share this post


Link to post
Share on other sites
If you used projective texturing and a stencil buffer, you could create actual 3D damage to the ship.

The basic concept is that you use the stencil buffer to carve 3D holes and damage into the ship. There's a tutorial on GDNet about 3D decals that describes the basic concept. With that and some sort of mapping (you could, for example, create a texture that is spherically mapped and do some calculations), you could actually create real damage to your ship.

But I think this is far more complex than I am making it sound, and probably not worth the effort. I just thought I'd point it out as a possibility.

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!