// Note to self, put some screenshots up // Used some of the techniques mentioned here: kalogirou.net/2006/05/20/how-to-do-good-bloom-for-hdr-rendering/ vec4 bloom4(vec4 input_colour) { //1. Find the light sources from the normal render. vec4 normalColour = normal();//reduce calls to this? Would the compiler do this anyway? float avg = (normalColour.r + normalColour.g + normalColour.b) / 3.0; vec4 sum = vec4(0.0); int sample_size = 16; int spacingFactor = 8; for (int i = -1 * sample_size / 2; i <= sample_size / 2; i++) { for (int j = -1 * sample_size / 2; j <= sample_size / 2; j++) { sum += texture(tex, vec2(tex_coord.x + (i * spacingFactor) * inv_width, tex_coord.y + (j * spacingFactor) * inv_height)); } } sum /= (sample_size * sample_size); vec4 sum2 = vec4(0.0); sample_size = 4; spacingFactor = 1; for (int i = -1 * sample_size / 2; i <= sample_size / 2; i++) { for (int j = -1 * sample_size / 2; j <= sample_size / 2; j++) { sum2 += texture(tex, vec2(tex_coord.x + (i * spacingFactor) * inv_width, tex_coord.y + (j * spacingFactor) * inv_height)); } } sum2 /= (sample_size * sample_size); sum = mix(sum, sum2, 0.5); float difference = clamp(2 * abs(grey(sum).r - grey(input_colour).r),0.0,1.0); return mix(sum, input_colour, 1 - difference); }
0 Comments
This effect is unlisted.
// Do not use if you suffer from epilepsy. Seriously. vec4 movInterlace(vec4 input1, vec4 input2) { if ((positionY + scaledTime) % 2 == 0 || (positionX + scaledTime) % 2 == 0) return input1; return input2; } //Why is time in there too? Why do I use both? Don't ask me, I wrote it a few weeks ago... // Don't worry it'll take about 9x10^32 years before there's a stack overflow because of the timer counting up. vec4 scan(vec4 input_colour) { int gap = 8; if ((positionY + scaledTime) % gap == 0) { return input_colour - vec4(0.2, 0.2, 0.2, 0.0); } return input_colour; } // I'd say it's 8-bit but that's not true, it's 4-bit vec4 col8(vec4 input_colour) { vec4 returnCol; //Prepare for the world's longest if statement if ((input_colour.r > input_colour.g && input_colour.r > input_colour.b) || (input_colour.g > input_colour.r && input_colour.g > input_colour.b) || (input_colour.b > input_colour.r && input_colour.b > input_colour.g)) { if (input_colour.r * 2.0 > input_colour.g + input_colour.b) returnCol = vec4(1.0, 0.0, 0.0, 1.0); //red if (input_colour.g * 2.0 > input_colour.r + input_colour.b) returnCol = vec4(0.0, 1.0, 0.0, 1.0); //green if (input_colour.b * 2.0 > input_colour.r + input_colour.g) returnCol = vec4(0.0, 0.0, 1.0, 1.0); //blue } else { if (input_colour.r + input_colour.g > 2.0 * input_colour.b) returnCol = vec4(1.0, 1.0, 0.0, 1.0); //yellow if (input_colour.g + input_colour.b > 2.0 * input_colour.r) returnCol = vec4(0.0, 1.0, 1.0, 1.0); //cyan if (input_colour.b + input_colour.r > 2.0 * input_colour.g) returnCol = vec4(1.0, 0.0, 1.0, 1.0); //magenta } if ((input_colour.r + input_colour.g + input_colour.b) / 3.0 > 0.8) returnCol = vec4(1.0, 1.0, 1.0, 1.0); //white if ((input_colour.r + input_colour.g + input_colour.b) / 3.0 < 0.2) returnCol = vec4(0.0, 0.0, 0.0, 1.0); //black return returnCol; } // It may not look pretty but it's actually fairly efficient vec4 CRT(vec4 input_colour) { float intensity = 0.225; vec4 returnCol = input_colour; if ((positionY - 0) % 3 == 0) { if ((positionX - 0) % 3 == 0) returnCol = mix(input_colour, vec4(1.0, 0.0, 0.0, 1.0), intensity); if ((positionX - 1) % 3 == 0) returnCol = mix(input_colour, vec4(0.0, 1.0, 0.0, 1.0), intensity); if ((positionX - 2) % 3 == 0) returnCol = mix(input_colour, vec4(0.0, 0.0, 1.0, 1.0), intensity); } if ((positionY - 1) % 3 == 0) { if ((positionX - 0) % 3 == 0) returnCol = mix(input_colour, vec4(0.0, 1.0, 0.0, 1.0), intensity); if ((positionX - 1) % 3 == 0) returnCol = mix(input_colour, vec4(0.0, 0.0, 1.0, 1.0), intensity); if ((positionX - 2) % 3 == 0) returnCol = mix(input_colour, vec4(1.0, 0.0, 0.0, 1.0), intensity); } if ((positionY - 2) % 3 == 0) { if ((positionX - 0) % 3 == 0) returnCol = mix(input_colour, vec4(0.0, 0.0, 1.0, 1.0), intensity); if ((positionX - 1) % 3 == 0) returnCol = mix(input_colour, vec4(1.0, 0.0, 0.0, 1.0), intensity); if ((positionX - 2) % 3 == 0) returnCol = mix(input_colour, vec4(0.0, 1.0, 0.0, 1.0), intensity); } return returnCol; } vec4 AA() { float twoThirds = 0.6667; float threeQuarters = 0.75; vec4 xc = texture(tex, tex_coord); vec4 u1 = texture(tex, tex_coord + vec2(0.0, -oneTexel.y)); vec4 u2 = texture(tex, tex_coord + vec2(0.0, -oneTexel.y * 2.0)); vec4 d1 = texture(tex, tex_coord + vec2(0.0, oneTexel.y)); vec4 d2 = texture(tex, tex_coord + vec2(0.0, oneTexel.y * 2.0)); vec4 l1 = texture(tex, tex_coord + vec2(-oneTexel.x, 0.0)); vec4 l2 = texture(tex, tex_coord + vec2(-oneTexel.x * 2.0, 0.0)); vec4 r1 = texture(tex, tex_coord + vec2(oneTexel.x, 0.0)); vec4 r2 = texture(tex, tex_coord + vec2(oneTexel.x * 2.0, 0.0)); vec4 v1 = mix(xc, mix(l1, l2, twoThirds), threeQuarters); vec4 v2 = mix(xc, mix(r1, r2, twoThirds), threeQuarters); vec4 v3 = mix(xc, mix(u1, u2, twoThirds), threeQuarters); vec4 v4 = mix(xc, mix(d1, d2, twoThirds), threeQuarters); vec4 v5 = mix(v1, v2, 0.5); vec4 v6 = mix(v3, v4, 0.5); return mix(v5, v6, 0.5); } |
AuthorHi there, the name's Matthew Jenkinson and I'm currently working at Firesprite. In my spare time I work on programming projects like you see here. Archives
March 2021
CategoriesLinks to each effect in order:
|