From bedd6906eabdd513042d6a178d4dc56a3a41d1d3 Mon Sep 17 00:00:00 2001 From: Fox Caminiti Date: Fri, 16 Dec 2022 20:16:43 -0500 Subject: v3, file/build organization --- src/effects_gl_shader.cpp | 57 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 src/effects_gl_shader.cpp (limited to 'src/effects_gl_shader.cpp') 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"; -- cgit v1.2.3