mirror of
https://github.com/AleziaKurdis/overte.git
synced 2025-04-19 08:18:05 +02:00
Shed some light on what these shaders are doing, so to speak.
This commit is contained in:
parent
ec0b1a99fb
commit
5241c41ddd
2 changed files with 11 additions and 0 deletions
|
@ -15,7 +15,10 @@ uniform sampler2D texture;
|
|||
varying vec4 normal;
|
||||
|
||||
void main(void) {
|
||||
// compute the specular component (sans exponent) based on the normal OpenGL lighting model
|
||||
float specular = max(0.0, dot(normalize(gl_LightSource[0].position + vec4(0.0, 0.0, 1.0, 0.0)), normalize(normal)));
|
||||
|
||||
// modulate texture by diffuse color and add specular contribution
|
||||
gl_FragColor = vec4(gl_Color.rgb * texture2D(texture, gl_TexCoord[0].st).rgb +
|
||||
pow(specular, gl_FrontMaterial.shininess) * gl_FrontLightProduct[0].specular.rgb, 1.0);
|
||||
}
|
||||
|
|
|
@ -12,9 +12,17 @@
|
|||
varying vec4 normal;
|
||||
|
||||
void main(void) {
|
||||
|
||||
// transform and store the normal for interpolation
|
||||
normal = normalize(gl_ModelViewMatrix * vec4(gl_Normal, 0.0));
|
||||
|
||||
// compute standard diffuse lighting per-vertex
|
||||
gl_FrontColor = gl_Color * (gl_LightModel.ambient + gl_LightSource[0].ambient +
|
||||
gl_LightSource[0].diffuse * max(0.0, dot(normal, gl_LightSource[0].position)));
|
||||
|
||||
// copy the tex coordinate for interpolation
|
||||
gl_TexCoord[0] = gl_MultiTexCoord0;
|
||||
|
||||
// use standard pipeline transform
|
||||
gl_Position = ftransform();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue