Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- // Shader Modified From Martinsh's Blender GLSL 2D Filter Demo: //
- //http://blenderartists.org/forum/showthread.php?156482-HDR-many-simple-GLSL-2D-Filters-v2.0&s=bbeb20ac111931da170fd6f8fea28d25//
- /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- uniform sampler2D sampler0;
- const float BRIGHT_PASS_THRESHOLD = 0.5;
- const float BRIGHT_PASS_OFFSET = 0.5;
- float contrast = 1.05;
- //Bloom
- #define blurclamp 0.002
- #define bias 0.01
- #define KERNEL_SIZE 3.0
- vec2 texcoord = vec2(gl_TexCoord[0]).st;
- vec4 texcolor = texture2D(sampler0, gl_TexCoord[0].st);
- vec4 bright(vec2 coo)
- {
- vec4 color = texture2D(sampler0, coo);
- color = max(color - BRIGHT_PASS_THRESHOLD, 0.0);
- return color / (color + BRIGHT_PASS_OFFSET);
- }
- //
- //Cross Processing
- vec4 gradient(vec4 coo)
- {
- vec4 stripes = coo;
- stripes.r = stripes.r*1.3+0.01;
- stripes.g = stripes.g*1.2;
- stripes.b = stripes.b*0.7+0.15;
- stripes.a = texcolor.a;
- return stripes;
- }
- //
- void main(void)
- {
- vec2 blur = vec2(clamp( bias, -blurclamp, blurclamp ));
- vec4 col = vec4( 0, 0, 0, 0 );
- for ( float x = -KERNEL_SIZE + 1.0; x < KERNEL_SIZE; x += 1.0 )
- {
- for ( float y = -KERNEL_SIZE + 1.0; y < KERNEL_SIZE; y += 1.0 )
- {
- col += bright( texcoord + vec2( blur.x * x, blur.y * y ) );
- }
- }
- col /= ((KERNEL_SIZE+KERNEL_SIZE)-1.0)*((KERNEL_SIZE+KERNEL_SIZE)-1.0);
- vec4 value = texture2D(sampler0, texcoord);
- vec4 fin = col + gradient(value);
- gl_FragColor = (fin - 0.5) * contrast + 0.5;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement