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.

37 lines
858 B

  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. void main()
  12. {
  13. vec4 sum = vec4(0);
  14. vec4 tc = vec4(0);
  15. for (int i = -4; i < 4; i++)
  16. {
  17. for (int j = -3; j < 3; j++)
  18. {
  19. sum += texture(texture0, fragTexCoord + vec2(j, i)*0.004)*0.25;
  20. }
  21. }
  22. // Texel color fetching from texture sampler
  23. vec4 texelColor = texture(texture0, fragTexCoord);
  24. // Calculate final fragment color
  25. if (texelColor.r < 0.3) tc = sum*sum*0.012 + texelColor;
  26. else if (texelColor.r < 0.5) tc = sum*sum*0.009 + texelColor;
  27. else tc = sum*sum*0.0075 + texelColor;
  28. finalColor = tc;
  29. }