Refract background

Hi, in my scene i only have a background. Its like looking at a 2d wall, but i do have some other 3d objects in front of it.

I want to add a refraction effect to my objects with a shader. Normally i’d have to pass a cubemap. But since there is no sky/environment, it makes it kinda hard to make a cubemap with no images…

I tried to change the shader so that it would work with just one (background) image. But i’m not getting the desired result.

Original image i’m trying to refract:

How can i fix this, so that it does a refraction on a single (background) image?

varying vec3  Reflect;
varying vec3  Refract;
varying float Ratio;

//uniform samplerCube Cubemap;
uniform sampler2D Cubemap;

void main()
    //vec3 refractColor = vec3(textureCube(Cubemap, Refract));
    //vec3 reflectColor = vec3(textureCube(Cubemap, Reflect));

    vec3 refractColor = vec3(texture2D(Cubemap, Refract));
    vec3 reflectColor = vec3(texture2D(Cubemap, Reflect));

    vec3 color   = mix(refractColor, reflectColor, Ratio);

    gl_FragColor = vec4(color, 1.0);

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