Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #ifdef GL_ES
- precision mediump float;
- #endif
- float normpdf(in float x, in float sigma)
- {
- return 0.39894*exp(-0.5*x*x/(sigma*sigma))/sigma;
- }
- void mainImage( out vec4 fragColor, in vec2 fragCoord )
- {
- vec2 uv = fragCoord/iResolution.xy;
- // GAUSSIAN BLUR PASS
- //vec4 color = texture(iChannel0, uv).rgba;
- const int mSize = 32;
- const int kSize = (mSize-1)/2;
- float kernel[mSize];
- vec3 final_colour = vec3(0.0);
- //create the 1-D kernel
- float sigma = 4.0;
- float Z = 0.0;
- for (int j = 0; j <= kSize; ++j)
- {
- kernel[kSize+j] = kernel[kSize-j] = normpdf(float(j), sigma);
- }
- //get the normalization factor (as the gaussian has been clamped)
- for (int j = 0; j < mSize; ++j)
- {
- Z += kernel[j];
- }
- //read out the texels
- for (int i=-kSize; i <= kSize; ++i)
- {
- for (int j=-kSize; j <= kSize; ++j)
- {
- final_colour += kernel[kSize+j]*kernel[kSize+i]*texture(iChannel0, (fragCoord.xy+vec2(float(i),float(j))) / iResolution.xy).rgb;
- }
- }
- fragColor = vec4(final_colour/(Z*Z), 1.0);
- // GREEN COLOR PASS
- fragColor *= vec4(1, 1.20, 1, 1);
- // VIGNETTE PASS
- vec2 coord = (uv - 0.5) * (iResolution.x/iResolution.y) * 2.0;
- float rf = sqrt(dot(coord, coord)) * 0.3;
- float rf2_1 = rf * rf + 1.0;
- float e = 1.0 / (rf2_1 * rf2_1);
- vec4 src = vec4(1.0,1.0,1.0,1.0);
- fragColor = vec4(fragColor.rgb * e, 1.0);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement