Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #version 450
- layout(set = 0, binding = 0, std140) uniform UBO
- {
- mat4 MVP;
- vec4 SourceSize; // Not used here, but doesn't hurt
- };
- float color_blend(float color_prev, float color_curr, float x)
- {
- float sum = color_curr;
- sum = sum + color_prev;
- return sum / 2.0;
- }
- #pragma name Composite blending
- #pragma stage vertex
- layout(location = 0) in vec4 Position;
- layout(location = 1) in vec2 TexCoord;
- layout(location = 0) out vec2 vTexCoord;
- void main()
- {
- gl_Position = MVP * Position;
- vTexCoord = TexCoord;
- }
- #pragma stage fragment
- layout(location = 0) in vec2 vTexCoord;
- layout(location = 0) out vec4 FragColor;
- layout(set = 0, binding = 2) uniform sampler2D Source;
- void main()
- {
- vec2 onePixel = vec2(1.0, 1.0) / SourceSize.xy;
- vec3 currentColor = texture(Source, vTexCoord).rgb;
- vec3 prevColor = texture(Source, vTexCoord - vec2(onePixel.x, 0)).rgb;
- float r = color_blend(prevColor.r, currentColor.r, vTexCoord.x);
- float g = color_blend(prevColor.g, currentColor.g, vTexCoord.x);
- float b = color_blend(prevColor.b, currentColor.b, vTexCoord.x);
- FragColor = vec4(r, g, b, 1.0);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement