Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #version 330 core
- in vec2 pos;
- layout (location = 0) out vec3 frag_col;
- uniform sampler2D input_texture;
- uniform bool generate_random;
- uniform int width;
- uniform int height;
- float random (in vec2 st) {
- return fract(sin(dot(st.xy,
- vec2(12.9898,78.233)))
- * 43758.5453123);
- }
- void main() {
- int pixel_size = 2;
- ivec2 screen_pos = ivec2(pos.x * width, pos.y * height);
- if(generate_random) {
- if (random(vec2(screen_pos.x - (screen_pos.x%pixel_size), screen_pos.y - (screen_pos.y%pixel_size))) < 0.5) {
- frag_col = vec3(0.0);
- } else {
- frag_col = vec3(1.0);
- }
- return;
- }
- int wyn = 0;
- wyn += int(texture(input_texture, vec2(pos.x + (pixel_size/float(width)), pos.y + (pixel_size/float(height)))).r);
- wyn += int(texture(input_texture, vec2(pos.x - (pixel_size/float(width)), pos.y + (pixel_size/float(height)))).r);
- wyn += int(texture(input_texture, vec2(pos.x - (pixel_size/float(width)), pos.y - (pixel_size/float(height)))).r);
- wyn += int(texture(input_texture, vec2(pos.x + (pixel_size/float(width)), pos.y - (pixel_size/float(height)))).r);
- wyn += int(texture(input_texture, vec2(pos.x + (pixel_size/float(width)), pos.y)).r);
- wyn += int(texture(input_texture, vec2(pos.x - (pixel_size/float(width)), pos.y)).r);
- wyn += int(texture(input_texture, vec2(pos.x, pos.y + (pixel_size/float(height)))).r);
- wyn += int(texture(input_texture, vec2(pos.x, pos.y - (pixel_size/float(height)))).r);
- int state = int(texture(input_texture, vec2(pos.x, pos.y)).r);
- if(wyn < 2 && state == 1) frag_col = vec3(0.0);
- else if(wyn < 4 && state == 1) frag_col = vec3(1.0);
- else if(state == 1) frag_col = vec3(0.0);
- else if(wyn == 3 && state == 0) frag_col = vec3(1.0f);
- else frag_col = vec3(0.0);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement