Multi-Color Lack
Ein Mehrfarbiger Lack.
Screenshot:

Vertex Shader:
uniform vec3 LightPos; varying float LightIntensity; varying float SpecIntensity; varying float CrossP; vec3 Normal; void main(){ vec3 zMinus = vec3(0.0,0.0,-1.0); gl_Position = ftransform(); vec3 pos = vec3(gl_ModelViewMatrix * gl_Vertex); Normal = normalize(gl_NormalMatrix * gl_Normal); LightIntensity = max(dot(normalize(LightPos - pos), Normal), 0.0); //Specular Calculation inspired by Randi Rost's brick-shader: www.3dshaders.com vec3 lightVec = normalize(LightPos - pos); vec3 reflectVec = reflect(-lightVec, Normal); vec3 viewVec = normalize(-pos); SpecIntensity = max(dot(reflectVec, viewVec), 0.0); CrossP = max(dot(Normal, viewVec),0.0); //CrossP = clamp(dot(Normal, zMinus),0.0,1.0); }
Fragment Shader:
uniform vec3 Color1; uniform vec3 Color2; uniform float SpecularLevel; uniform float SpecularSize; varying float LightIntensity; varying float SpecIntensity; varying float CrossP; void main(){ vec3 tmpCol = mix(Color1, Color2, CrossP)*LightIntensity; tmpCol += max(0.0, SpecularLevel * pow(SpecIntensity, SpecularSize)); gl_FragColor = vec4(tmpCol, 1.0); }