Need help with a grab Shader

How can I make grab Shader similar to Unity - Manual: ShaderLab command: GrabPass in GLSL.

The idea, is that you grab exact pixels from background (ex. from composited renderTarget) and put on rendered object. So it’s like 100% transparency, because it always has the pixels right behind. Later if you disort the pixels, can give very cool effects like Shader - Shadertoy BETA.

SO far I have texture of background (plane to renderTarget), and object cube right before it. My vertex shader for cube is gl_Position = WVP * spos; and I have no idea how do the frag shader to copy the pixels from background. Any help appreciated.


I realized I can use simply

vec2 uv = gl_FragCoord.xy / screensize;
fragColor.rgb = texture(snapshot, uv.xy).rgb;

But it has slight error

Nailed!, the screensize was incorrect

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.