Skip to content

Commit

Permalink
Merge pull request #15174 from iota97/ctr-anim
Browse files Browse the repository at this point in the history
Make CRT animation speed configurable
  • Loading branch information
hrydgard authored Dec 7, 2021
2 parents f1a4abf + 6d38ea3 commit 1f21796
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
14 changes: 9 additions & 5 deletions assets/shaders/crt.fsh
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@ precision mediump int;
uniform sampler2D sampler0;
varying vec2 v_texcoord0;
uniform vec4 u_time;
uniform vec4 u_setting;

void main()
{
// scanlines
int vPos = int( ( v_texcoord0.y + u_time.x * 0.5 ) * 272.0 );
int vPos = int( ( v_texcoord0.y + u_time.x * u_setting.x * 0.5 ) * 272.0 );
float line_intensity = mod( float(vPos), 2.0 );

// color shift
Expand All @@ -26,8 +27,11 @@ void main()
float b = texture2D( sampler0, v_texcoord0 ).z;

vec4 c = vec4( r, g * 0.99, b, 1.0 ) * clamp( line_intensity, 0.85, 1.0 );

float rollbar = sin( ( v_texcoord0.y + u_time.x ) * 4.0 );

gl_FragColor.rgba = c + (rollbar * 0.02);

if (u_setting.x > 0.0) {
float rollbar = sin( ( v_texcoord0.y + u_time.x * u_setting.x ) * 4.0 );
c += rollbar * 0.02;
}

gl_FragColor.rgba = c;
}
5 changes: 5 additions & 0 deletions assets/shaders/defaultshaders.ini
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ Author=KillaMaaki
Fragment=crt.fsh
Vertex=fxaa.vsh
60fps=True
SettingName1=Animation speed (0 = disable)
SettingDefaultValue1=1.0
SettingMaxValue1=2.0
SettingMinValue1=0.0
SettingStep1=0.05
[Natural]
Name=Natural Colors
Fragment=natural.fsh
Expand Down

0 comments on commit 1f21796

Please sign in to comment.