// 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
Leave a Reply. |
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:
|