groworld/plant-eyes/shaders/toon.frag.glsl

35 lines
861 B
Text
Raw Permalink Normal View History

2009-07-30 15:03:21 +00:00
varying vec3 N;
varying vec3 L;
varying vec3 V;
varying vec2 T;
2009-10-21 18:07:30 +00:00
varying vec3 P;
2009-07-30 15:03:21 +00:00
uniform sampler2D BaseMap;
2009-10-21 18:07:30 +00:00
uniform vec3 Origin;
2009-07-30 15:03:21 +00:00
void main()
{
vec3 n = normalize(N);
vec3 l = normalize(L);
vec3 v = normalize(V);
float HighlightSize=0.1;
float ShadowSize=0.2;
2009-08-15 08:03:28 +00:00
float OutlineWidth=0.2;
2009-07-30 15:03:21 +00:00
vec4 MidColour=gl_FrontMaterial.diffuse;
2009-10-22 10:31:11 +00:00
if (Origin.y<0.0) MidColour=vec4(0.171,0.273,0.336,1.0);
2009-10-21 18:07:30 +00:00
vec4 HighlightColour=MidColour*1.3;
vec4 ShadowColour=MidColour*0.6;
2009-07-30 15:08:51 +00:00
HighlightColour.a=1.0;
ShadowColour.a=1.0;
2009-07-30 15:03:21 +00:00
float lambert = dot(l,n);
vec4 colour = MidColour;
if (lambert > 1.0-HighlightSize) colour = HighlightColour;
if (lambert < ShadowSize) colour = ShadowColour;
if (dot(n,v) < OutlineWidth) colour = vec4(0,0,0,1);
2009-07-30 15:10:10 +00:00
if (dot(n,v) < 0.0) colour = MidColour*texture2D(BaseMap, T);
2009-07-30 15:03:21 +00:00
2009-10-21 18:07:30 +00:00
gl_FragColor = vec4(colour.xyz,1);
2009-07-30 15:03:21 +00:00
}