Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #version 330
- layout (binding = 0) uniform sampler2D u_obstacles;
- layout (binding = 1) uniform sampler2D u_source;
- out vec4 color;
- void fetchNComp(ivec2 sourcePosition, ivec2 size, int offsetX, int offsetY, float multiplier, inout vec4 color) {
- int x = sourcePosition.x + offsetX;
- int y = sourcePosition.y + offsetY;
- if (x >= 0 && y >= 0 && x < size.x && y < size.y) {
- color = max(color, texelFetch(u_source, ivec2(x, y), 0) * multiplier);
- }
- }
- void main() {
- ivec2 position = ivec2(gl_FragCoord.x, gl_FragCoord.y);
- ivec2 ts = textureSize(u_source, 0);
- vec4 source = texelFetch(u_source, position, 0);
- color = source;
- fetchNComp(position, ts, 1, 0, 0.95, color);
- fetchNComp(position, ts, 2, 0, 0.85, color);
- fetchNComp(position, ts, 3, 0, 0.75, color);
- fetchNComp(position, ts, 4, 0, 0.60, color);
- fetchNComp(position, ts, -1, 0, 0.95, color);
- fetchNComp(position, ts, -2, 0, 0.85, color);
- fetchNComp(position, ts, -3, 0, 0.75, color);
- fetchNComp(position, ts, -4, 0, 0.60, color);
- fetchNComp(position, ts, 0, 1, 0.95, color);
- fetchNComp(position, ts, 0, 2, 0.85, color);
- fetchNComp(position, ts, 0, 3, 0.75, color);
- fetchNComp(position, ts, 0, 4, 0.60, color);
- fetchNComp(position, ts, 0, -1, 0.95, color);
- fetchNComp(position, ts, 0, -2, 0.85, color);
- fetchNComp(position, ts, 0, -3, 0.75, color);
- fetchNComp(position, ts, 0, -4, 0.60, color);
- float obstacle = 1 - texelFetch(u_obstacles, position, 0).a;
- color = max(source, color * obstacle);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement