groworld/plant-eyes/shaders/twig.frag.glsl_old

37 lines
1 KiB
Text
Raw Permalink Normal View History

2009-09-28 09:30:09 +00:00
varying vec3 N;
varying vec3 L;
varying vec3 V;
varying vec2 T;
uniform sampler2D BaseMap;
uniform sampler2D AltMap;
uniform sampler2D NormalMap;
void main()
{
vec3 bump = normalize(texture2D(NormalMap,T).xyz*2.0-1.0)-vec3(0,0,1);
vec3 n = normalize(N)//+bump*5.0);
vec3 l = normalize(L);
vec3 v = normalize(V);
float HighlightSize=0.1;
float ShadowSize=0.2;
float OutlineWidth=0.2;
vec4 MidColour=gl_FrontMaterial.diffuse;
vec4 HighlightColour=MidColour*2.0;
vec4 ShadowColour=MidColour*0.5;
HighlightColour.a=1.0;
ShadowColour.a=1.0;
float lambert = dot(l,n);
vec4 colour = vec4(MidColour.xyz*lambert,1);
if (lambert > 1.0-HighlightSize) colour = HighlightColour;
if (lambert < ShadowSize) colour = ShadowColour;
if (dot(n,v) < OutlineWidth) colour = vec4(0,0,0,1);
if (dot(n,v) < 0.0) colour = MidColour;//*texture2D(BaseMap, T);
colour = mix(colour+texture2D(AltMap, T*10.0),colour,smoothstep(4.0,8.0,length(V)));
colour.a *= smoothstep(2.0,6.0,length(V));
gl_FragColor = colour;
}