MythTV  master
mythrenderopenglshaders.h
Go to the documentation of this file.
1 #ifndef MYTHRENDER_OPENGL_SHADERS_H
2 #define MYTHRENDER_OPENGL_SHADERS_H
3 
4 #include <QString>
5 
6 static const QString kDefaultVertexShader =
7 "attribute vec2 a_position;\n"
8 "attribute vec4 a_color;\n"
9 "attribute vec2 a_texcoord0;\n"
10 "varying vec4 v_color;\n"
11 "varying vec2 v_texcoord0;\n"
12 "uniform mat4 u_projection;\n"
13 "uniform mat4 u_transform;\n"
14 "void main() {\n"
15 " gl_Position = u_projection * u_transform * vec4(a_position, 0.0, 1.0);\n"
16 " v_texcoord0 = a_texcoord0;\n"
17 " v_color = a_color;\n"
18 "}\n";
19 
20 static const QString kDefaultFragmentShader =
21 "uniform sampler2D s_texture0;\n"
22 "varying highp vec4 v_color;\n"
23 "varying highp vec2 v_texcoord0;\n"
24 "void main(void)\n"
25 "{\n"
26 " gl_FragColor = texture2D(s_texture0, v_texcoord0) * v_color;\n"
27 "}\n";
28 
29 static const QString kDefaultFragmentShaderLimited =
30 "uniform sampler2D s_texture0;\n"
31 "varying highp vec4 v_color;\n"
32 "varying highp vec2 v_texcoord0;\n"
33 "void main(void)\n"
34 "{\n"
35 " gl_FragColor = (texture2D(s_texture0, v_texcoord0) * v_color * vec4(0.85882, 0.85882, 0.85882, 1.0)) + vec4(0.06274, 0.06274, 0.06274, 0.0);\n"
36 "}\n";
37 
38 static const QString kSimpleVertexShader =
39 "attribute vec2 a_position;\n"
40 "attribute vec4 a_color;\n"
41 "varying vec4 v_color;\n"
42 "uniform mat4 u_projection;\n"
43 "uniform mat4 u_transform;\n"
44 "void main() {\n"
45 " gl_Position = u_projection * u_transform * vec4(a_position, 0.0, 1.0);\n"
46 " v_color = a_color;\n"
47 "}\n";
48 
49 static const QString kSimpleFragmentShader =
50 "varying highp vec4 v_color;\n"
51 "void main(void)\n"
52 "{\n"
53 " gl_FragColor = v_color;\n"
54 "}\n";
55 
56 static const QString kDrawVertexShader =
57 "attribute vec2 a_position;\n"
58 "attribute vec4 a_color;\n"
59 "varying vec4 v_color;\n"
60 "varying vec2 v_position;\n"
61 "uniform mat4 u_projection;\n"
62 "uniform mat4 u_transform;\n"
63 "void main() {\n"
64 " gl_Position = u_projection * u_transform * vec4(a_position, 0.0, 1.0);\n"
65 " v_color = a_color;\n"
66 " v_position = a_position;\n"
67 "}\n";
68 
69 static const QString kCircleFragmentShader =
70 "varying highp vec4 v_color;\n"
71 "varying highp vec2 v_position;\n"
72 "uniform highp mat4 u_parameters;\n"
73 "void main(void)\n"
74 "{\n"
75 " highp float dis = distance(v_position.xy, u_parameters[0].xy);\n"
76 " highp float mult = smoothstep(u_parameters[0].z, u_parameters[0].w, dis);\n"
77 " gl_FragColor = v_color * vec4(1.0, 1.0, 1.0, mult);\n"
78 "}\n";
79 
80 static const QString kCircleEdgeFragmentShader =
81 "varying highp vec4 v_color;\n"
82 "varying highp vec2 v_position;\n"
83 "uniform highp mat4 u_parameters;\n"
84 "void main(void)\n"
85 "{\n"
86 " highp float dis = distance(v_position.xy, u_parameters[0].xy);\n"
87 " highp float rad = u_parameters[0].z;\n"
88 " highp float wid = u_parameters[0].w;\n"
89 " highp float mult = smoothstep(rad + wid, rad + (wid - 1.0), dis) * smoothstep(rad - (wid + 1.0), rad - wid, dis);\n"
90 " gl_FragColor = v_color * vec4(1.0, 1.0, 1.0, mult);\n"
91 "}\n";
92 
93 static const QString kVertLineFragmentShader =
94 "varying highp vec4 v_color;\n"
95 "varying highp vec2 v_position;\n"
96 "uniform highp mat4 u_parameters;\n"
97 "void main(void)\n"
98 "{\n"
99 " highp float dis = abs(u_parameters[0].x - v_position.x);\n"
100 " highp float y = u_parameters[0].y * 2.0;\n"
101 " highp float mult = smoothstep(y, y - 0.1, dis) * smoothstep(-0.1, 0.0, dis);\n"
102 " gl_FragColor = v_color * vec4(1.0, 1.0, 1.0, mult);\n"
103 "}\n";
104 
105 static const QString kHorizLineFragmentShader =
106 "varying highp vec4 v_color;\n"
107 "varying highp vec2 v_position;\n"
108 "uniform highp mat4 u_parameters;\n"
109 "void main(void)\n"
110 "{\n"
111 " highp float dis = abs(u_parameters[0].x - v_position.y);\n"
112 " highp float x = u_parameters[0].y * 2.0;\n"
113 " highp float mult = smoothstep(x, x - 0.1, dis) * smoothstep(-0.1, 0.0, dis);\n"
114 " gl_FragColor = v_color * vec4(1.0, 1.0, 1.0, mult);\n"
115 "}\n";
116 
117 #endif // MYTHRENDER_OPENGL_SHADERS_H
kCircleEdgeFragmentShader
static const QString kCircleEdgeFragmentShader
Definition: mythrenderopenglshaders.h:80
kSimpleFragmentShader
static const QString kSimpleFragmentShader
Definition: mythrenderopenglshaders.h:49
kDrawVertexShader
static const QString kDrawVertexShader
Definition: mythrenderopenglshaders.h:56
kDefaultVertexShader
static const QString kDefaultVertexShader
Definition: mythrenderopenglshaders.h:6
kHorizLineFragmentShader
static const QString kHorizLineFragmentShader
Definition: mythrenderopenglshaders.h:105
kSimpleVertexShader
static const QString kSimpleVertexShader
Definition: mythrenderopenglshaders.h:38
kCircleFragmentShader
static const QString kCircleFragmentShader
Definition: mythrenderopenglshaders.h:69
kVertLineFragmentShader
static const QString kVertLineFragmentShader
Definition: mythrenderopenglshaders.h:93
kDefaultFragmentShader
static const QString kDefaultFragmentShader
Definition: mythrenderopenglshaders.h:20
kDefaultFragmentShaderLimited
static const QString kDefaultFragmentShaderLimited
Definition: mythrenderopenglshaders.h:29