mgba/res/shaders/gba-color.shader/gba-color.fs

22 lines
604 B
Forth
Raw Normal View History

// Shader that replicates the LCD Colorspace from Gameboy Advance --
2017-04-13 12:39:35 +00:00
varying vec2 texCoord;
varying mat4 profile;
2017-04-13 12:39:35 +00:00
uniform sampler2D tex;
uniform vec2 texSize;
uniform float darken_screen;
const float target_gamma = 2.0;
const float display_gamma = 2.0;
2017-04-13 12:39:35 +00:00
void main() {
// 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;
2017-04-13 12:39:35 +00:00
screen = clamp(screen * lum, 0.0, 1.0);
screen = profile * screen;
gl_FragColor = pow(screen, vec4(1.0 / display_gamma));
2017-04-13 12:39:35 +00:00
}