This shader only blends the colors of the object with the scene behind, and what I would like it to do is to refract, that’s why I passed the position and the normal, but I do not know really how to proceed next, especially : If I calculate the refraction vector, how do I pass it to texture2D wich works with texel coordinates ?
Most GPUs I know of don’t provide the background colors in the shader, so you need to have the background you’re drawing over in a separate texture.
As for looking up the texture coordinate, that’s another matter. This is a very popular paper for performing refraction. You should read it a few times to get a idea of what you should do.
Thank you for the link
It seems quite complex actually :sick:
In my case, it would be ok to refract only through the surface facing the camera. The background that I want to refract is passed trough the uniform “Texture” in my fragment shader.
My main problem actually is to have precisely the “offset.xy” in the texture2D command, since I do not know how to “convert” a vector in space coordinate into a vector in texels coordinates