Advertisement
Guest User

Untitled

a guest
Jan 19th, 2021
896
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.14 KB | None | 0 0
  1. #version 450
  2. layout(set = 0, binding = 0, std140) uniform UBO
  3. {
  4. mat4 MVP;
  5. vec4 SourceSize; // Not used here, but doesn't hurt
  6. };
  7.  
  8. float color_blend(float color_prev, float color_curr, float x)
  9. {
  10. float sum = color_curr;
  11. sum = sum + color_prev;
  12. return sum / 2.0;
  13. }
  14.  
  15. #pragma name Composite blending
  16.  
  17. #pragma stage vertex
  18. layout(location = 0) in vec4 Position;
  19. layout(location = 1) in vec2 TexCoord;
  20. layout(location = 0) out vec2 vTexCoord;
  21. void main()
  22. {
  23. gl_Position = MVP * Position;
  24. vTexCoord = TexCoord;
  25. }
  26.  
  27.  
  28. #pragma stage fragment
  29. layout(location = 0) in vec2 vTexCoord;
  30. layout(location = 0) out vec4 FragColor;
  31. layout(set = 0, binding = 2) uniform sampler2D Source;
  32.  
  33. void main()
  34. {
  35. vec2 onePixel = vec2(1.0, 1.0) / SourceSize.xy;
  36. vec3 currentColor = texture(Source, vTexCoord).rgb;
  37. vec3 prevColor = texture(Source, vTexCoord - vec2(onePixel.x, 0)).rgb;
  38.  
  39. float r = color_blend(prevColor.r, currentColor.r, vTexCoord.x);
  40. float g = color_blend(prevColor.g, currentColor.g, vTexCoord.x);
  41. float b = color_blend(prevColor.b, currentColor.b, vTexCoord.x);
  42. FragColor = vec4(r, g, b, 1.0);
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement