motion-blur-exponential-decay.fs 992 B

12345678910111213141516171819202122232425262728
  1. #version 150
  2. uniform sampler2D source[];
  3. uniform vec4 sourceSize[];
  4. uniform sampler2D frame[];
  5. uniform vec4 frameSize[];
  6. out vec4 color;
  7. #define response_time 0.333 //simulate response time, higher values result in longer color transition periods - [0, 1]
  8. in Vertex {
  9. vec2 texCoord;
  10. };
  11. out vec4 fragColor;
  12. void main() {
  13. color = abs(texture(frame[6], texCoord).rgba);
  14. color += (abs(texture(frame[5], texCoord).rgba) - color) * response_time;
  15. color += (abs(texture(frame[4], texCoord).rgba) - color) * pow(response_time, 2.0);
  16. color += (abs(texture(frame[3], texCoord).rgba) - color) * pow(response_time, 3.0);
  17. color += (abs(texture(frame[2], texCoord).rgba) - color) * pow(response_time, 4.0);
  18. color += (abs(texture(frame[1], texCoord).rgba) - color) * pow(response_time, 5.0);
  19. color += (abs(texture(frame[0], texCoord).rgba) - color) * pow(response_time, 6.0);
  20. color += (abs(texture(source[0], texCoord).rgba) - color) * pow(response_time, 7.0);
  21. fragColor = color;
  22. }