Skip to content

Commit

Permalink
Make scanlines and grille non-destructive
Browse files Browse the repository at this point in the history
  • Loading branch information
hiulit committed Oct 19, 2020
1 parent 787933b commit 9b6b06f
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions crt_shader.shader
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
shader_type canvas_item;

uniform float boost : hint_range(1.0, 2.0, 0.01) = float(1.2);
uniform float grille_opacity : hint_range(0.0, 1.0, 0.01) = float(0.85);
uniform float scanlines_opacity : hint_range(0.0, 1.0, 0.01) = float(0.95);
uniform float grille_opacity : hint_range(0.0, 1.0, 0.01) = float(1.0);
uniform float scanlines_opacity : hint_range(0.0, 1.0, 0.01) = float(1.0);
uniform float vignette_opacity : hint_range(0.1, 0.5, 0.01) = float(0.2);
uniform float scanlines_speed : hint_range(0.0, 1.0, 0.01) = float(1.0);
uniform bool show_grille = true;
Expand Down Expand Up @@ -35,15 +35,15 @@ void DrawVignette(inout vec3 color, vec2 uv) {
}

void DrawScanline(inout vec3 color, vec2 uv, float time) {
float scanline = clamp((scanlines_opacity - 0.05) + 0.05 * sin(3.1415926535 * (uv.y + 0.008 * time) * screen_size.y), 0.0, 1.0);
float grille = (grille_opacity - 0.15) + 0.15 * clamp(1.5 * sin(3.1415926535 * uv.x * screen_size.x), 0.0, 1.0);
float scanline = clamp(sin(3.1415926535 * (uv.y + 0.008 * time) * screen_size.y), 0.0, 1.0);
float grille = clamp(1.5 * sin(3.1415926535 * uv.x * screen_size.x), 0.0, 1.0);

if (show_scanlines) {
color *= scanline;
color *= (1.0 - scanlines_opacity * scanline);
}

if (show_grille) {
color *= grille;
color *= (1.0 - grille_opacity * grille);
}

color *= boost;
Expand Down

0 comments on commit 9b6b06f

Please sign in to comment.