old_film.gdshader 1.1 KB

12345678910111213141516171819202122232425262728293031323334
  1. shader_type canvas_item;
  2. uniform sampler2D screen_texture : hint_screen_texture, filter_linear_mipmap;
  3. uniform vec4 base: source_color;
  4. uniform sampler2D grain;
  5. uniform float grain_strength = 0.3;
  6. uniform sampler2D vignette;
  7. uniform float fps = 12.0;
  8. uniform float stretch = 0.5;
  9. uniform float flashing = 0.01;
  10. float make_grain(float time, vec2 uv) {
  11. vec2 ofs = vec2(sin(41.0 * time * sin(time * 123.0)), sin(27.0 * time * sin(time * 312.0)));
  12. return texture(grain, (uv + mod(ofs, vec2(1.0, 1.0))) * stretch).r;
  13. }
  14. void fragment() {
  15. vec3 c = textureLod(screen_texture, SCREEN_UV, 0.0).rgb;
  16. //float v = max(c.r, max(c.g, c.b));
  17. float v = dot(c, vec3(0.33333, 0.33333, 0.33333));
  18. v = sqrt(v);
  19. //v *= v;
  20. float f = 1.0 / fps;
  21. float g = make_grain(TIME - mod(TIME, f), UV);
  22. g = max(g, make_grain(TIME - mod(TIME, f) + f, UV) * 0.5);
  23. g = max(g, make_grain(TIME - mod(TIME, f) + f * 2.0, UV) * 0.25);
  24. COLOR.rgb = base.rgb * v - vec3(g) * grain_strength;
  25. COLOR.rgb *= texture(vignette, UV).r;
  26. float ft = TIME * 0.002;
  27. COLOR.rgb += vec3(sin(75.0 * ft * sin(ft * 123.0))) * flashing;
  28. }