Created
February 18, 2016 09:51
-
-
Save marcosbitetti/13c081b5f25ddf7ba8ab to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
///// ----------- Fragment | |
uniform texture diffuse; | |
uniform texture normal; | |
vec4 cor = tex(diffuse,UV); | |
vec3 norm = 2.0 * tex(normal,UV).rgb;// - vec3(0.5,0.5,0.5); | |
DIFFUSE = cor.rgb; | |
NORMAL = NORMAL*norm; | |
///// ------------ Light | |
float NdotL = max(0.0,dot( NORMAL, LIGHT_DIR )); | |
// toon | |
if (NdotL<0.2) | |
{ | |
NdotL = 0.2; | |
} else { | |
if (NdotL<0.4) | |
{ | |
NdotL = 0.4; | |
} else { | |
if (NdotL<0.65) | |
{ | |
NdotL = 0.65; | |
} else | |
{ | |
NdotL = 1.0; | |
} | |
} | |
} | |
LIGHT = LIGHT_DIFFUSE * DIFFUSE * NdotL; | |
if (NdotL > 0.0) { | |
vec3 half_vec = normalize(LIGHT_DIR + EYE_VEC); | |
float eye_light = max(dot(NORMAL, half_vec),0.0); | |
LIGHT += LIGHT_SPECULAR * SPECULAR * pow( eye_light, SPECULAR_EXP ); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment