per-pixel "damage" rendering. possible?

Started by
5 comments, last by Promit 19 years, 6 months ago
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.
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!
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.
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?
are you using pixel shaders?
i would prefer to avoid them if possible... but im willing to explore all options
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.
SlimDX | Ventspace Blog | Twitter | Diverse teams make better games. I am currently hiring capable C++ engine developers in Baltimore, MD.

This topic is closed to new replies.

Advertisement