Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * Simple outline postprocessing effect
- * Author: nyuuzero
- */
- uniform sampler2D sampler0;
- uniform sampler2D sampler1;
- uniform sampler2D sampler2;
- uniform float displayWidth;
- uniform float displayHeight;
- uniform float aspectRatio;
- uniform float near;
- uniform float far;
- float rand(vec2 co){
- return fract(sin(dot(co.xy ,vec2(12.9898,78.233))) * 43758.5453);
- }
- float getLinearDepth(vec2 coords)
- {
- return (2 * near) / (far + near - texture2D( sampler1, coords ).x * (far - near));
- }
- float generateOutline(vec2 coords)
- {
- // pixelsize
- float horizontalPixelSize = 1.0 / displayWidth;
- float verticalPixelSize = 1.0 / displayHeight;
- // generate outline
- float tempDepth =
- getLinearDepth(coords + vec2(horizontalPixelSize,verticalPixelSize)) +
- getLinearDepth(coords + vec2(-horizontalPixelSize,verticalPixelSize)) +
- getLinearDepth(coords + vec2(0.0,-verticalPixelSize));
- tempDepth /= 3;
- return getLinearDepth(coords)-tempDepth;
- }
- void main()
- {
- gl_FragColor = mix(texture2D( sampler0, gl_TexCoord[0].st ),vec4(0.0,0.0,0.0,0.0),clamp(generateOutline(gl_TexCoord[0].st)*100,0.0,0.9));
- //gl_FragColor *= 1.0 - clamp(generateOutline(gl_TexCoord[0].st)*100,0.0,1.0);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement