File: TextureWarpShader.frag.txt

package info (click to toggle)
psychtoolbox-3 3.0.19.14.dfsg1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 86,796 kB
  • sloc: ansic: 176,245; cpp: 20,103; objc: 5,393; sh: 2,753; python: 1,397; php: 384; makefile: 193; java: 113
file content (28 lines) | stat: -rw-r--r-- 1,034 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
/* Shader for warping/distortion of textures during drawing.
 * This shader is meant for image distortion/warping. It is used by
 * the high-level routine AddImageWarpToGLOperator.m
 *
 * The shader is meant for blitting a texture to the framebuffer. It
 * perturbs the texture lookup coordinates by some 2D offset, which it
 * reads from a distortion/warpmap bound to the "WarpMap" sampler.
 *
 * (w)2007 by Mario Kleiner. Licensed under MIT license.
*/

#extension GL_ARB_texture_rectangle : enable

uniform sampler2DRect Image;
uniform sampler2DRect WarpMap;

void main()
{
    /* Get wanted texture coordinate for which we should perform lookup: */
    vec2 texinpos = gl_TexCoord[0].st;

    /* Retrieve texture lookup 2D offset from red and green channels of WarpMap: */
    vec2 delta = texture2DRect(WarpMap, texinpos).rg;

    /* Perform perturbed lookup in source image texture and */
    /* assign result as output fragment color: */
    gl_FragColor = texture2DRect(Image, texinpos + delta);
}