Special effects?

Started by
2 comments, last by Subconscious 20 years ago
I''m making a 2d game with directx and right now I''m working on the special effects. Most of the ideas I had involve playing around with images on the pixel level, but as far as I can tell, direct3d isn''t made for that. I know you can lock the back buffer and play with the pixels that way, but that would slow down my performance quite a bit and is not recomended by anything I''ve read. I was wondering if it''s reasonable to lock a texture, play around with the pixels and then unlock and render it every frame? Would this cause too much of a hit in performance? Is there some way around this? For example, I want to make a little circle where the color of each pixel is the opposite color of the pixel under it... any ideas on how to go about that with reasonable speed in direct3d? I can''t think of any way besides locking the back buffer every frame and I really don''t want it to come to that.
Advertisement
Your best option is to pre-process your effects bitmaps.

Im not sure but i think you can apply some effects filters to them quite quickly, doing stuff like fades, etc....

Imagine having a certain amount of bitmaps flying arround the screen, diferent sizes, diferent textures, diferent effects, etc....

Thats how the majority of effects are made. Don''t even try to manipulate things at pixel level, unless you''re using pixel shaders or something, it will kill whatever performance you had...

Salsa cooked it, your eyes eat it![Hugo Ferreira][Positronic Dreams][Colibri 3D Engine][Entropy HL2 MOD][My DevDiary]
[Yann L.][Enginuity] [Penny Arcade] [MSDN][VS RoadMap][Humus][BSPs][UGP][NeHe]
Prozak - The GameDever formally known as pentium3id
I realize most game effects are done using particle systems or layers of textures... I was just wondering if there was any way to do things that seem like they can only be done by pixel manipulation, like the example of using the opposite pixel color in an area.

Does anyone know if pixel shaders would work for something like that or if it would be overkill?

[edited by - Subconscious on March 27, 2004 1:33:37 PM]
You can do dynamic texture effects, but you generally have to limit yourself to small textures or the performance hit is too much. Create a DYNAMIC texture (or Managed if DYNAMIC isn''t supported), lock it, update, and unlock.

For your inverse colour circle effect, this might work (though I haven''t tested it). Create a texture that is transparent except for a circle. Set ALPHATEST so the transparent pixels are skipped. Then set you render states:
SRCBLEND:ZERO
DEST_BLEND:INVDEST_COLOR

I don''t know how well that is supported so you''d have to check your CAPS as well.


Stay Casual,

Ken
Drunken Hyena
Stay Casual,KenDrunken Hyena

This topic is closed to new replies.

Advertisement