revert commits 26437-26439 the right way[tm]
[mplayer/glamo.git] / TOOLS / edgedetect.fp
blob2d872197820049bc036d82964bcb949c7a476074
1 !!ARBfp1.0
2 # Custom YUV->RGB conversion program for MPlayer's -vo gl.
3 # Copyleft (C) Reimar Döffinger, 2005
4 # Licensed under the GNU GPL v2 or later
5 # Usage: mplayer -vo gl:yuv=4:customprog=edgedetect.fp
6 # This is some custom edge-detect like effect.
7 # Try adjusting the gamma!
8 # program.env[0].xy contains the size of one source texel
9 TEMP res, yuv, pos, tmp, sizes;
10 SWZ sizes, program.env[0], x, y, 0, 0;
11 TEX yuv.r, fragment.texcoord[0], texture[0], 2D;
12 ADD pos, fragment.texcoord[0].xyxy, sizes.xwwy; # texels to the right and below
13 TEX tmp.r, pos.xyxy, texture[0], 2D;
14 MAD yuv.r, yuv.rrrr, {4}, -tmp.rrrr;
15 TEX tmp.r, pos.zwzw, texture[0], 2D;
16 SUB yuv.r, yuv.rrrr, tmp.rrrr;
17 SUB pos, fragment.texcoord[0].xyxy, sizes.xwwy; # texels to the left and above
18 TEX tmp.r, pos.xyxy, texture[0], 2D;
19 SUB yuv.r, yuv.rrrr, tmp.rrrr;
20 TEX tmp.r, pos.zwzw, texture[0], 2D;
21 SUB yuv.r, yuv.rrrr, tmp.rrrr;
22 TEX yuv.g, fragment.texcoord[1], texture[1], 2D;
23 TEX yuv.b, fragment.texcoord[2], texture[2], 2D;
24 # now do the normal YUV -> RGB conversion but include effect strength
25 # multiplication by 2 and 0.5 offset
26 MAD res, yuv.rrrr, {2.328, 2.328, 2.328, 0}, {-0.37416, 1.03133, -0.58599, 0.125};
27 MAD res.rgb, yuv.gggg, {0, -0.391, 2.018, 0}, res;
28 MAD res.rgb, yuv.bbbb, {1.596, -0.813, 0, 0}, res;
29 # do gamma texture lookup
30 TEX res.r, res.raaa, texture[3], 2D;
31 ADD res.a, res.a, 0.25;
32 TEX res.g, res.gaaa, texture[3], 2D;
33 ADD res.a, res.a, 0.25;
34 TEX res.b, res.baaa, texture[3], 2D;
35 # move res into result, this allows easily commenting out some parts.
36 MOV result.color, res;
37 END