Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- varying vec2 vcoord; //passed from the vertex shader and is pos.xy*0.5+0.5, where pos is the vertex coordinate of the screen quad used to render the pass.
- uniform sampler2D color_buffer; //the back buffer (the previous pass's lighting).
- uniform sampler2D mask; //the conduction mask (with the conduction in the alpha channel because it is a GL_ALPHA texture).
- uniform vec2 radius; //vec2(1.0/mask.width, 1.0/mask.height) - the size of a single pixel
- void main(void){
- vec4 ret = vec4(0.0); float sum = 0.0; vec2 coord = vcoord; float me = texture2D(mask,coord).a;
- //left pixel (weight 2)
- coord.x -= radius.x; float m = me*texture2D(mask,coord).a*2.0; sum += m; ret += m*texture2D(color_buffer,coord);
- //top left pixel (weight 4)
- coord.y -= radius.y; m = me*texture2D(mask,coord).a*4.0; sum += m; ret += m*texture2D(color_buffer,coord);
- //bottom left pixel (weight 4)
- coord.y += radius.y*2.0; m = me*texture2D(mask,coord).a*4.0; sum += m; ret += m*texture2D(color_buffer,coord);
- //center pixel (weight 1)
- coord.y -= radius.y; coord.x += radius.x; sum += 1.0; ret += texture2D(color_buffer,coord);
- //top pixel (weight 2)
- coord.y -= radius.y; m = me*texture2D(mask,coord).a*2.0; sum += m; ret += m*texture2D(color_buffer,coord);
- //bottom pixel (weight 2)
- coord.y += radius.y*2.0; m = me*texture2D(mask,coord).a*2.0; sum += m; ret += m*texture2D(color_buffer,coord);
- //right pixel (weight 2)
- coord.y -= radius.y; coord.x += radius.x; m = me*texture2D(mask,coord).a*2.0; sum += m; ret += m*texture2D(color_buffer,coord);
- //top right pixel (weight 4)
- coord.y -= radius.y; m = me*texture2D(mask,coord).a*4.0; sum += m; ret += m*texture2D(color_buffer,coord);
- //bottom right pixel (weight 4)
- coord.y += radius.y*2.0; m = me*texture2D(mask,coord).a*4.0; sum += m; ret += m*texture2D(color_buffer,coord);
- sum = 1.0/sum; gl_FragColor = ret*sum;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement