diff options
author | Fox Caminiti <fox@foxcam.net> | 2022-12-16 20:16:43 -0500 |
---|---|---|
committer | Fox Caminiti <fox@foxcam.net> | 2022-12-16 20:16:43 -0500 |
commit | bedd6906eabdd513042d6a178d4dc56a3a41d1d3 (patch) | |
tree | 2bcbd3e46ae61e583707a2ccc5b3f5cfeacb61a8 /src/effects_gl_shader.cpp | |
parent | cdb9e1f7240cb0716b7d99df5e1fd7c3fc3407a8 (diff) |
v3, file/build organization
Diffstat (limited to 'src/effects_gl_shader.cpp')
-rw-r--r-- | src/effects_gl_shader.cpp | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/src/effects_gl_shader.cpp b/src/effects_gl_shader.cpp new file mode 100644 index 0000000..b2e1fc1 --- /dev/null +++ b/src/effects_gl_shader.cpp @@ -0,0 +1,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"; |