Skip to main content
gamedev.net
🔒 Locked

Distortion Effect.

Started by _WannaBe_ 2 replies 400+ views
Original Post
_WannaBe_
_WannaBe_
Hi. In some scene demos I''ve looked at, they are using a kind of distortion effect. Each scanline is moved either a few pixels to the left or a few pixels to the right(all scanlines using a randomized offset value for distortion). I''ve tried to create this effect myself, but I can''t figure out how to get some speed out of it. I''ve tried 2 different approches. 1: -- What I do is that I render some 3D object to the backbuffer, the use the GetBackBuffer from the D3DDevice object. Then I get the memory surface pointer through the LockRect function. After that I loop through all scanlines and use the ''memcpy'' function to copy each scanline a random amount of pixels to the left. However, this is extremly slow. 2: -- Same way to get the backbuffer surface. But this time I was using the CopyRects function from the D3DDevice object to move the scanlines. Using arrays of RECTs and POINTs. Still very slow. Any ideas anyone?
NightShade
NightShade
Yeah doing anything to the screen buffers directly is going to slow you down, and there''s really no remedy except for maybe running in 320x200 mode, hehe..

A couple ideas I have are... go check out the BumpUnderWater demo in the DirectX SDK. If your hardware supports it (mine doesn''t, bleh) you could probably modify that to do what you want.

Other than that, and writing your own software renderer (where you could actually offset the pixels in the first place) I dont really know. I''m curious, I would like to see that demo. Do you have a URL?



-ns-
_WannaBe_
_WannaBe_
ok..

I''m going to try one other thing. Will see if that works..

Anyway, Nightshade, here is the link to the demo.

http://www.farb-rausch.com/prod.html

Download to top file, ''la sculpture [fr-015]'', and about 1 minute from the start of the demo you will see the distortion effect.

Thanks.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.