I would like to have an invisibility effect on my object, so I would not only like it to be transparent, but also to distort the colors behind it. For this I have my scene texture sent as an uniform to the shader I enable when rendering my object, but I do not know what to do next, so any help would be very appreciated.
Btw, sorry for my bad english :o
What function do you want to use for the distortion?
Depending on what that is, you may have several choices.
First, the standard GPU pipeline typically only keeps track of the closest aka front-most object “hit” per pixel (i.e. the closest “fragment”) from the eye’s vantage point. So to do translucent blending effects, typically you need to ensure that within every pixel on the screen, the translucent “fragments” are all rendered back-to-front.
For “simple” objects and no object intersections, this can be obtained through a mere front-to-back sort of the objects. Then if your distortion (aka blending) function is simple enough, you can use the built-in GPU hardware to do the blending.
For more complex scenarios, you can use “depth peeling” which is much more expensive but can work properly in some of those “hard to sort” scenarios.
In other situations, folks have used multisample render targets and shaders to store multiple levels of transparency in the pixel subsamples (typically 1-8 levels), and then gone back and implemented their own “blend” of these transparent surfaces.
In still other (simple) circumstances, folks can avoid this sorting altogether by using what’s called alpha-to-coverage with multisampling. This assumes a simple blend function though.
There are other options. But which is the most practical for your needs depends on your distort/blend function.
I think the effect you’re looking for is refraction. Here’s an image from one of my demo’s:
The refraction effect can be easy to implement depending on how physically accurate you want to be.
Nvidia’s “Developer Zone” offers many good resources, including the book GPU Gems 2 in full, to read for free. In it, there’s an article about general refraction techniques. Full shader source is included. Here’s a link:
Also, visit my recent post related to this subject for more info. Layered 2D Refraction Shader Help
Thank you for the replies
Dark Photon : I have no distortion function yet, and my problem is rather a problem of converting the object fragments positions to the sceneTex texels positions. I had this problem of sorting though, but I think I will adopt the manual method
Gut Flora : The Nvidia article is indeed very interesting in my case, thanks for the link. I’m sorry though, I’ve no idea for the problem you raised in your topic
This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.