2024-09-16 10:51:08 +00:00
|
|
|
// Shader that replicates the LCD Colorspace from Gameboy Advance --
|
2017-04-13 12:39:35 +00:00
|
|
|
varying vec2 texCoord;
|
2024-09-16 10:51:08 +00:00
|
|
|
varying mat4 profile;
|
2017-04-13 12:39:35 +00:00
|
|
|
uniform sampler2D tex;
|
|
|
|
uniform vec2 texSize;
|
|
|
|
|
|
|
|
uniform float darken_screen;
|
2024-09-16 10:51:08 +00:00
|
|
|
const float target_gamma = 2.0;
|
|
|
|
const float display_gamma = 2.0;
|
2017-04-13 12:39:35 +00:00
|
|
|
|
|
|
|
void main() {
|
2024-09-16 10:51:08 +00:00
|
|
|
// bring out our stored luminance value
|
|
|
|
float lum = profile[3].w;
|
|
|
|
|
|
|
|
// our adjustments need to happen in linear gamma
|
2017-04-13 20:29:00 +00:00
|
|
|
vec4 screen = pow(texture2D(tex, texCoord), vec4(target_gamma + darken_screen)).rgba;
|
2024-09-16 10:51:08 +00:00
|
|
|
|
2017-04-13 12:39:35 +00:00
|
|
|
screen = clamp(screen * lum, 0.0, 1.0);
|
2024-09-16 10:51:08 +00:00
|
|
|
screen = profile * screen;
|
|
|
|
gl_FragColor = pow(screen, vec4(1.0 / display_gamma));
|
2017-04-13 12:39:35 +00:00
|
|
|
}
|