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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
const char *GLShader_Levels = "#version 330 core\n"
"out vec4 FragColor;\n"
"in vec2 TexCoord;\n"
"uniform float Start;\n"
"uniform float Mid;\n"
"uniform float End;\n"
"uniform vec4 StartCol;\n"
"uniform vec4 MidCol;\n"
"uniform vec4 EndCol;\n"
"uniform sampler2D Texture;\n"
"void main()\n"
"{\n"
"vec4 OutCol = texture(Texture, TexCoord);\n"
// individual channels
"vec4 ColorI = pow(OutCol, MidCol);\n"
"vec4 ValI = 1.0f / (EndCol - StartCol) * (ColorI - StartCol);\n"
// global channel (doesn't affect alpha)
"vec4 ColorG = pow(ValI, vec4(Mid));\n"
"vec4 ValG = 1.0f / (End - Start) * (ColorG - Start);\n"
"ValG = vec4(ValG.rgb, ValI.a);\n"
"FragColor = clamp(ValG, 0.0f, 1.0f);\n"
"}\0";
const char *GLShader_SolidColor = "#version 330 core\n"
"out vec4 FragColor;\n"
"in vec2 TexCoord;\n"
"uniform vec4 Color;\n"
"uniform sampler2D Texture;\n"
"void main()\n"
"{\n"
"vec4 OutCol = texture(Texture, TexCoord);\n"
"FragColor = Color*OutCol;\n"
"}\0";
const char *GLShader_GaussianBlur = "#version 330 core\n"
"uniform float Radius;\n"
"uniform vec2 Direction;\n"
"uniform sampler2D Texture;\n"
"out vec4 FragColor;\n"
"in vec2 TexCoord;\n"
"\n"
"vec4 blur(sampler2D image, vec2 uv, vec2 resolution, vec2 direction) {\n"
" vec4 color = vec4(0.0f);\n"
" float Omega = Radius / 3;\n"
" float Divisor = 2*Omega*Omega;\n"
" float A2 = 1.0f / (Omega * sqrt(2*3.141592));\n"
" for (float Span = -round(Radius); Span < round(Radius); Span++) {\n"
" float Dividend = -Span * Span;\n"
" float Multiplier = A2 * exp(Dividend/Divisor);\n"
" vec2 Dir = Span*direction;\n"
" color += texture(image, uv + (Dir / resolution)) * Multiplier;\n"
" }\n"
" return color;\n"
"}\n"
"void main(void) {\n"
" FragColor = blur(Texture, TexCoord, vec2(1280, 720), Direction);\n"
"}\0";
|