1
0
Fork 0
2022-untitled-game/code/shaders/screen.glsl

58 lines
1.2 KiB
Plaintext
Raw Normal View History

2022-08-01 23:11:10 +00:00
//////////////////////////////////////////////////////////////////////////////
#ifdef VERTEX
layout (location = 0) in vec2 a_position;
layout (location = 1) in vec2 a_texcoord;
out vec2 v_texcoord;
void main()
{
v_texcoord = a_texcoord;
gl_Position = vec4(a_position, 0.0f, 1.0f);
}
#endif
//////////////////////////////////////////////////////////////////////////////
#ifdef FRAGMENT
in vec2 v_texcoord;
out vec4 f_color;
uniform sampler2D u_texture;
uniform float u_powerup_timer;
const float START_TIMER = 15.0f;
const float START_R = 1.20f;
const float START_GB = 0.80f;
const float TIMER_STEPS_R = (START_R-1.0f) / START_TIMER;
const float TIMER_STEPS_GB = (1.0f-START_GB) / START_TIMER;
void main()
{
vec4 color = texture(u_texture, v_texcoord);
float gamma = 2.2f;
if (u_powerup_timer > 0.0f)
{
float timer = u_powerup_timer / 100.0f;
vec3 tint = vec3(
START_R - (TIMER_STEPS_R*(START_TIMER-u_powerup_timer)),
START_GB + (TIMER_STEPS_GB*(START_TIMER-u_powerup_timer)),
START_GB + (TIMER_STEPS_GB*(START_TIMER-u_powerup_timer)));
color.rgb *= tint;
}
f_color = vec4(pow(color.rgb, vec3(1.0f/gamma)), color.a);
}
#endif
//////////////////////////////////////////////////////////////////////////////