Search code examples
c++openglshaderdistortion

Implementing photoshop glass distortion filter


I have a homework where I need to implement a glass distortion filter using OpenGL. Basically what I am allowed to do is read a pixel from one image and write it to another one (teacher's limitations).

The result of the filter should be something like this:

Filter

Is there any tutorial or code explaining how that works?


Solution

  • Try displacement noise, something like: new_pic(x,y) = old_pic( x+dx(x,y), y+dy(x,y) ) where dx and dy some bounded smooth functions, for example: dx(x,y)= 0 dy(x,y)= sin(y)*sin(x)

    p.s. After getting the main idea, you will probably want better displacement functions, I recomend Perlin noise, here's Ken Perlin's great article: http://www.noisemachine.com/talk1/