Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Shaders 2.0 port of Yourself's Cell Shader
- #version 120
- #define CELL_SHADING
- #define THRESHOLD 0.4
- #define THICKNESS 0.0025
- uniform sampler2D texture;
- uniform sampler2D gdepth;
- uniform float near;
- uniform float far;
- varying vec4 texcoord;
- #ifdef CELL_SHADING
- float getDepth(vec2 coord) {
- float depth = texture2D(gdepth, coord).x;
- return 2.0 * near * far / ( far + near - ( 2.0 * depth - 1.0 ) * ( far - near ) );
- }
- float getCellShaderFactor(vec2 coord) {
- float d=getDepth(coord);
- vec3 n=normalize(vec3(getDepth(coord+vec2(THICKNESS,0.0))-d,getDepth(coord+vec2(0.0,THICKNESS))-d ,THRESHOLD));
- return n.z;//clamp(n.z*3.0,0.0,1.0);
- }
- #endif
- void main()
- {
- vec4 color = texture2D(texture, texcoord.st);
- #ifdef CELL_SHADING
- color.rgb *= (getCellShaderFactor(texcoord.st));
- #endif
- gl_FragColor = color;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement