Update Cel shading. Note, RageDisplay_D3D will need to be fixed for this.

This commit is contained in:
Colby Klein
2011-03-08 11:00:32 -08:00
parent bcd87f8c17
commit 704c7bff1d
8 changed files with 90 additions and 89 deletions
+26 -24
View File
@@ -1,24 +1,26 @@
varying vec2 texCoords;
varying vec3 normal, viewVector;
varying vec4 lightVector, lightColor;
uniform sampler2D Texture1;
void main(void)
{
float intensity = dot(normal, lightVector.xyz);
float fresnel = pow(1.0 - dot(viewVector, normal), 5.0);
fresnel = fresnel < 0.5 ? 0.0 : 0.4;
float shade = 1.0;
if( intensity > 0.35 )
shade = clamp(1.0 * intensity + 0.4, 0.0, 1.0);
else
shade = clamp(0.85 * intensity + 0.25, 0.4, 0.6);
shade = clamp(shade - fresnel, 0.3, 1.0);
vec4 vcol = gl_FrontMaterial.diffuse;
vec4 tex = texture2D(Texture1, texCoords);
gl_FragColor = lightColor * vec4(tex.rgb * shade, 1.0);
}
uniform sampler2D Texture0;
varying vec2 vCoord;
varying vec3 vNor;
const vec4 shadowColor = vec4(0.6, 0.75, 0.9, 1.0);
void main() {
vec3 nor, light;
nor = normalize(vNor);
vec4 diffuse, specular, color, lightSource;
float ambient = length(gl_FrontMaterial.ambient.rgb);
lightSource = gl_LightSource[0].position;
light = normalize(gl_ModelViewMatrix * lightSource).xyz;
color = texture2D(Texture0, vCoord.st);
float intensity = max(dot(light,nor), 0.0);
if (intensity < 0.5) {
intensity *= 0.5;
color *= shadowColor;
}
intensity = min(clamp(intensity, ambient, 1.0) + 0.25, 1.0);
gl_FragColor = color * intensity;
}
+9 -16
View File
@@ -1,16 +1,9 @@
varying vec3 normal, viewVector;
varying vec4 lightVector, lightColor;
varying vec2 texCoords;
void main(void)
{
texCoords = gl_MultiTexCoord0.st;
vec4 objectPos = gl_ModelViewMatrix * gl_Vertex;
normal = gl_NormalMatrix * gl_Normal;
lightVector = normalize(gl_LightSource[0].position);
lightColor = gl_LightSource[0].diffuse;
viewVector = normalize(vec3(0) - objectPos.xyz);
gl_Position = ftransform();
}
varying vec2 vCoord;
varying vec3 vNor;
void main() {
vCoord = gl_MultiTexCoord0.st;
vNor = gl_Normal.xyz;
gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
}