Advertisement
netgrind

displacement

Oct 27th, 2014
182
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.39 KB | None | 0 0
  1. uniform sampler2D tex0;
  2. varying vec2 tcoord;
  3. uniform sampler2D offset;
  4. uniform float intensity;
  5. void main() {
  6. // Sample the input pixel
  7. vec2 uv = tcoord;
  8. uv.y = 1-uv.y;
  9. vec4 c = texture2D(offset,uv);
  10. uv.x += (c.r-0.5)*intensity;
  11. uv.y += (c.g-0.5)*intensity;
  12. uv.x = clamp(uv.x,0,1);
  13. uv.y = clamp(uv.y,0,1);
  14. // Save the result
  15. gl_FragColor = texture2D(tex0,uv);
  16. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement