16488
|
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
|
|
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 PARAM sizes = program.env[0];
|
|
10 TEMP res, y, u, v, pos, tmp;
|
|
11 TEX y, fragment.texcoord[0], texture[0], 2D;
|
|
12 MUL y, y, {4, 4, 4, 0};
|
|
13 ADD pos, fragment.texcoord[0], sizes.xwww; # texel to the right
|
|
14 TEX tmp, pos, texture[0], 2D;
|
|
15 SUB y, y, tmp;
|
|
16 SUB pos, fragment.texcoord[0], sizes.xwww; # texel to the left
|
|
17 TEX tmp, pos, texture[0], 2D;
|
|
18 SUB y, y, tmp;
|
|
19 ADD pos, fragment.texcoord[0], sizes.wyww; # texel... umm.. above?
|
|
20 TEX tmp, pos, texture[0], 2D;
|
|
21 SUB y, y, tmp;
|
|
22 SUB pos, fragment.texcoord[0], sizes.wyww; # texel... umm.. below?
|
|
23 TEX tmp, pos, texture[0], 2D;
|
|
24 SUB y, y, tmp;
|
|
25 MAD res, y, {2, 2, 2, 0}, {0.5, 0.5, 0.5, 0};
|
|
26 # now do the normal YUV -> RGB conversion
|
|
27 MAD res, res, {1.164, 1.164, 1.164, 0}, {-0.87416, 0.53133, -1.08599, 0};
|
|
28 TEX u, fragment.texcoord[1], texture[1], 2D;
|
|
29 MAD res, u, {0, -0.391, 2.018, 0}, res;
|
|
30 TEX v, fragment.texcoord[2], texture[2], 2D;
|
|
31 MAD res, v, {1.596, -0.813, 0, 0}, res;
|
|
32 # do gamma texture lookup
|
|
33 ADD res.a, res.a, 0.125;
|
|
34 TEX res.r, res.raaa, texture[3], 2D;
|
|
35 ADD res.a, res.a, 0.25;
|
|
36 TEX res.g, res.gaaa, texture[3], 2D;
|
|
37 ADD res.a, res.a, 0.25;
|
|
38 TEX res.b, res.baaa, texture[3], 2D;
|
|
39 # move res into result, this allows easily commenting out some parts.
|
|
40 ADD result.color, res, {0, 0, 0, 0};
|
|
41 END
|