diff -r 99652d00489f -r 95688249c40c machine.html
--- a/machine.html Wed Apr 27 13:35:56 2011 +0200
+++ b/machine.html Wed Apr 27 14:14:07 2011 +0200
@@ -32,6 +32,8 @@
uniform vec3 uAmbientColour;
uniform vec3 uLightingDirection;
uniform vec3 uDirectionalColour;
+ uniform vec3 uPointLightingLocation;
+ uniform vec3 uPointLightingColour;
uniform bool uUseLighting;
@@ -40,7 +42,8 @@
void main(void)
{
- gl_Position = uPMatrix * uMVMatrix * vec4(aVertexPosition, 1.0);
+ vec4 mvPosition = uMVMatrix * vec4(aVertexPosition, 1.0);
+ gl_Position = uPMatrix * mvPosition;
vColour = aVertexColour;
if (!uUseLighting)
@@ -49,9 +52,14 @@
}
else
{
+ //vec3 transformedNormal = uNMatrix * aVertexNormal;
+ //float directionalLightWeighting = max(dot(transformedNormal, uLightingDirection), 0.0);
+ //vLightWeighting = uAmbientColour + uDirectionalColour * directionalLightWeighting;
+
+ vec3 lightDirection = normalize(uPointLightingLocation - mvPosition.xyz);
vec3 transformedNormal = uNMatrix * aVertexNormal;
- float directionalLightWeighting = max(dot(transformedNormal, uLightingDirection), 0.0);
- vLightWeighting = uAmbientColour + uDirectionalColour * directionalLightWeighting;
+ float directionalLightWeighting = max(dot(transformedNormal, lightDirection), 0.0);
+ vLightWeighting = uAmbientColour + uPointLightingColour * directionalLightWeighting;
}
}