Question submitted by (22 June 1999)
|Return to The Archives|
|I've been trying to figure out how to achieve a "predator" like stealth effect but I can't think of a solution that would work in hardware as well as software. I had thought of using the output frame as a texture and dynamically mapping the UV coords on a model to the appropriate areas of the screen to produce the slight visual shift. However, this method could fail in hardware are cards like the Voodoo range would not recognize an 800x600 output frame as a texture. Any ideas how I might do this in hardware?|
I've contemplated this very same thing myself a few times, and I've come
up with a couple of approaches which have never been tested. But if
you're interested, read on...
If you're trying to distort a specific area (say.. an area of the screen occupied by a single object) you can blt the region behind that area from the frame buffer to system RAM. Sure, this can cause a slow-down, but if you use the hardware to perform the operations, you can minimize this. You can then use this image as the texture for the object, with a warping of the UVs applied to the object's texture. To get the right effect, you'll need to pick your UVs according to the image, rather than using UVs that wrap the object.
Another possibility is to sample a grid of pixels from the object's screen-space rectangle rather than blit from video RAM to system RAM. From this sampling, you can use these random samples to guide a noise routine to generate a likeness of the background for which to distort. This, of course, would only work on certain backgrounds. It would have the advantage of very few read-backs from video RAM which could be a negligible performance hit.
Response provided by Paul Nettle
This article was originally an entry in flipCode's Fountain of Knowledge, an open Question and Answer column that no longer exists.