You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

45 lines
1.1 KiB

  1. #version 330
  2. // Input vertex attributes (from vertex shader)
  3. in vec2 fragTexCoord;
  4. in vec4 fragColor;
  5. // Input uniform values
  6. uniform sampler2D texture0;
  7. uniform vec4 fragTintColor;
  8. // Output fragment color
  9. out vec4 finalColor;
  10. // NOTE: Add here your custom variables
  11. float offset = 0.0;
  12. float frequency = 720.0/3.0;
  13. uniform float time;
  14. void main()
  15. {
  16. /*
  17. // Scanlines method 1
  18. float tval = 0; //time
  19. vec2 uv = 0.5 + (fragTexCoord - 0.5)*(0.9 + 0.01*sin(0.5*tval));
  20. vec4 color = texture(texture0, fragTexCoord);
  21. color = clamp(color*0.5 + 0.5*color*color*1.2, 0.0, 1.0);
  22. color *= 0.5 + 0.5*16.0*uv.x*uv.y*(1.0 - uv.x)*(1.0 - uv.y);
  23. color *= vec4(0.8, 1.0, 0.7, 1);
  24. color *= 0.9 + 0.1*sin(10.0*tval + uv.y*1000.0);
  25. color *= 0.97 + 0.03*sin(110.0*tval);
  26. fragColor = color;
  27. */
  28. // Scanlines method 2
  29. float globalPos = (fragTexCoord.y + offset) * frequency;
  30. float wavePos = cos((fract(globalPos) - 0.5)*3.14);
  31. // Texel color fetching from texture sampler
  32. vec4 texelColor = texture(texture0, fragTexCoord);
  33. finalColor = mix(vec4(0.0, 0.3, 0.0, 0.0), texelColor, wavePos);
  34. }