diff --git a/src/shader/pixelbuf.frag b/src/shader/pixelbuf.frag index f867bde..c45efae 100644 --- a/src/shader/pixelbuf.frag +++ b/src/shader/pixelbuf.frag @@ -1,13 +1,25 @@ #version 330 core -out vec4 FragColor; +out vec4 frag_color; -in vec3 ourColor; -in vec2 TexCoord; +in vec3 color; +in vec2 uv; -// texture sampler -uniform sampler2D texture1; +uniform sampler2D screen; void main() { - FragColor = texture(texture1, TexCoord); + // https://near.sh/video/color-emulation + // Thanks to Talarubi + Near for the Colour Correction + // Thanks to fleur + mattrb for the Shader Impl + + vec4 color = texture(screen, uv); + color.rgb = pow(color.rgb, vec3(4.0)); // LCD Gamma + + frag_color = vec4( + pow(vec3( + 0 * color.b + 50 * color.g + 255 * color.r, + 30 * color.b + 230 * color.g + 10 * color.r, + 220 * color.b + 10 * color.g + 50 * color.r + ) / 255, vec3(1.0 / 2.2)), // Out Gamma + 1.0); } diff --git a/src/shader/pixelbuf.vert b/src/shader/pixelbuf.vert index 0738b36..43ef32e 100644 --- a/src/shader/pixelbuf.vert +++ b/src/shader/pixelbuf.vert @@ -1,13 +1,13 @@ #version 330 core -layout (location = 0) in vec3 aPos; -layout (location = 1) in vec3 aColor; -layout (location = 2) in vec2 aTexCoord; +layout (location = 0) in vec3 pos; +layout (location = 1) in vec3 in_color; +layout (location = 2) in vec2 in_uv; -out vec3 ourColor; -out vec2 TexCoord; +out vec3 color; +out vec2 uv; void main() { - gl_Position = vec4(aPos, 1.0); - ourColor = aColor; - TexCoord = aTexCoord; + color = in_color; + uv = in_uv; + gl_Position = vec4(pos, 1.0); } \ No newline at end of file