#StackBounty: #shaders #glsl #graphic-effects How do I make my glsl RGB displacement map look like this

Bounty: 50

I want to use a RGB texture as described in this video here.

Here is my texture so far. enter image description here

The author says the first line has no R channel and ranges from B = 0 to B = 255.
While each other line has R channel = 255 and B = 255 to B = 0 as seen.

His colors do not match with mine. I wrote my shader like this:

  #version 110
  uniform sampler2D texture;
  uniform sampler2D pattern;
  uniform float progress;

  void main()
    vec4 displacement = texture2D(pattern, gl_TexCoord[0].xy);
    displacement = ((displacement * 2.0) - 1.0) * progress;

    vec2 newTexCoord = gl_TexCoord[0].xy + displacement.xy;
    vec4 pixel = texture2D(texture, newTexCoord);

    vec4 color = gl_Color * pixel;
    gl_FragColor = color;

which is based off his earlier videos but I’m not getting the effect at all. At best I see interlaced layers moving away but they move diagonally instead of left-right. Plus they clamp instead of leaving black color behind as seen in his video.

Here’s what mine looks like: click to view

Get this bounty!!!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.