Plasma Effect

Started by
3 comments, last by tj963 22 years, 9 months ago
Hi, I''m trying to make a plasma effect for my game in DX7. The problem is it doesn''t run nearly fast enough. It''s only a few lines but this line: buffer[dest] = Coss[t1]+Coss[t2]+Coss[t3]; Drops the FPS about 20-30 frames. buffer is the pointer Lock() returns. dest is the destination pixel. Coss is a short lookup table and t1-t3 are just shorts. I execute this for every pixel and it costs me about 10 FPS on each side of the equals sign. Hopefully that was clear enough. Any suggestions on how I could speed it up? BTW, it''s a fullscreen effct. Thanks, tj963
tj963
Advertisement
Well, any effect that involves math operations on every pixel is going to slow things down quite a bit, keep in mind.

At what resolution are you running the effect?
Are you writing directly to video mem? Remember that reading and writing directly to video memory is very slow so if you really are going to manipulate the surface data directly it would probably be faster to create a surface in system memory. Then you lock it, write your data to it, unlock it and blit it to the back buffer. Of course this depends on the surface size. If you are writing to a small surface the slow read/write''s from/to video memory doesnt matter much, but if you are writing to a large surface it would be faster to do it the way i explained.

-René

Real programmers don't document, if it was hard to write it should be hard to understand

possibly use bitshifting to calculate _where_ to put the pixel, instead of any multiplication you maybe using for that task?


here in castle camelot we eat ham and jam and spam alot!

Edited by - warm0ng3r on June 24, 2001 12:28:20 AM
I''ve got a little suggestion, try coding it in...err...assembly I don''t think you''ll find it very hard. I remember quite a few years ago I wrote a fire routine in C using ModeX, it was very, very slow. A friend suggested I try it in assembly, I thought I might get a few fps extra but was absolutly amaze when I saw the difference. I don''t think you''ll get the same performance with Windows because I think VC does a fair amount of optimization anyway...but give it a try, its good experience.
Either way, like Spartacus says, I think a per-pixel operation will take a fair amount of time and don''t use video memory directly.

Anyway that was my good deed of the day...hope it helps

This topic is closed to new replies.

Advertisement