Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #shader vertex
- #version 330 core
- uniform int Time;
- uniform vec4 Camera;
- layout(location = 0) in ivec2 InPosition;
- layout(location = 1) in ivec2 InIndexes;
- layout(location = 2) in uvec4 InData;
- flat out vec4 TilePosition;
- flat out ivec2 TexIndexes;
- float rand(int x, int y)
- {
- return fract(sin(x) * cos(y) * 43758.5453123);
- }
- void main()
- {
- vec2 pos = InPosition - Camera.xy;
- TilePosition = vec4(pos - 0.5f, pos + 0.5f) / Camera.zwzw;
- int back_delay = int((InData.y >> 16) & 0xffffu);
- int back_count = int((InData.y >> 8) & 0xffu);
- int back_dist = int((InData.y) & 0xffu);
- int back_offset = int((InData.x >> 16) & 0xffffu);
- int front_delay = int((InData.w >> 16) & 0xffffu);
- int front_count = int((InData.w >> 8) & 0xffu);
- int front_dist = int((InData.w) & 0xffu);
- int front_offset = int((InData.z >> 16) & 0xffffu);
- int back_time = Time;
- int front_time = Time;
- if (back_dist != 0)
- back_time += abs((((InPosition.x ^ InPosition.y) % 100) * 100 + (InPosition.x << 8) *
- (InPosition.y << 8) + (InPosition.x % 10) * 50 + (InPosition.y % 10) * 50) % 65536);
- if (front_dist != 0)
- front_time += abs((((InPosition.x ^ InPosition.y) % 100) * 100 + (InPosition.x << 8) *
- (InPosition.y << 8) + (InPosition.x % 10) * 50 + (InPosition.y % 10) * 50) % 65536);
- TexIndexes = InIndexes + ivec2(((back_time / back_delay) % back_count) * back_offset,
- ((front_time / front_delay) % front_count) * front_offset);
- }
- #shader geometry
- #version 330 core
- layout (points) in;
- layout (triangle_strip, max_vertices = 4) out;
- flat in vec4 TilePosition[1];
- flat in ivec2 TexIndexes[1];
- out vec2 TexPixel;
- flat out ivec3 BackPixel;
- flat out ivec3 FrontPixel;
- void main()
- {
- if (TexIndexes[0].x >= 0) BackPixel = ivec3(TexIndexes[0].x % 64 * 16,
- TexIndexes[0].x / 64 % 64 * 16, TexIndexes[0].x / 4096);
- else BackPixel = ivec3(-1, -1, -1);
- if (TexIndexes[0].y >= 0) FrontPixel = ivec3(TexIndexes[0].y % 64 * 16,
- TexIndexes[0].y / 64 % 64 * 16, TexIndexes[0].y / 4096);
- else FrontPixel = ivec3(-1, -1, -1);
- gl_Position = vec4(TilePosition[0].zy, 0.0f, 1.0f);
- TexPixel = vec2(16.0f, 16.0f);
- EmitVertex();
- gl_Position = vec4(TilePosition[0].xy, 0.0f, 1.0f);
- TexPixel = vec2(0.0f, 16.0f);
- EmitVertex();
- gl_Position = vec4(TilePosition[0].zw, 0.0f, 1.0f);
- TexPixel = vec2(16.0f, 0.0f);
- EmitVertex();
- gl_Position = vec4(TilePosition[0].xw, 0.0f, 1.0f);
- TexPixel = vec2(0.0f, 0.0f);
- EmitVertex();
- EndPrimitive();
- }
- #shader fragment
- #version 330 core
- uniform sampler2DArray TextureArray;
- in vec2 TexPixel;
- flat in ivec3 BackPixel;
- flat in ivec3 FrontPixel;
- out vec4 FragColor;
- void main()
- {
- ivec3 offset = ivec3(TexPixel, 0);
- if (offset.x >= 16) offset.x = 15;
- if (offset.y >= 16) offset.y = 15;
- if (offset.x < 0) offset.x = 0;
- if (offset.y < 0) offset.y = 0;
- vec4 BackFrag = vec4(0.0f, 0.0f, 0.0f, 0.0f);
- if (BackPixel.x >= 0 && BackPixel.y >= 0) BackFrag =
- texelFetch(TextureArray, BackPixel + offset, 0) * vec4(0.4f, 0.4f, 0.4f, 1.0f);
- vec4 FrontFrag = vec4(0.0f, 0.0f, 0.0f, 0.0f);
- if (FrontPixel.x >= 0 && FrontPixel.y >= 0) FrontFrag =
- texelFetch(TextureArray, FrontPixel + offset, 0);
- FragColor = mix(BackFrag, FrontFrag, FrontFrag.w);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement