Added cube vbos and ids.
3 <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
4 <title>Machine Alpha</title>
5 <style type="text/css">
8 <script language="javascript" src="scripts/boot.js"></script>
9 <script id="fragment-shader" type="x-shader/x-fragment">
11 precision highp float;
15 varying vec3 vTransformedNormal;
16 varying vec4 vPosition;
18 uniform float uMaterialShininess;
20 uniform bool uUseLighting;
22 uniform vec3 uAmbientColour;
23 uniform vec3 uPointLightingLocation;
24 uniform vec3 uPointLightingSpecularColour;
25 uniform vec3 uPointLightingDiffuseColour;
32 lightWeighting = vec3(1.0, 1.0, 1.0);
36 vec3 lightDirection = normalize(uPointLightingLocation - vPosition.xyz);
37 vec3 normal = normalize(vTransformedNormal);
38 vec3 eyeDirection = normalize(-vPosition.xyz);
39 vec3 reflectionDirection = reflect(-lightDirection, normal);
40 float specularLightWeighting = pow(max(dot(reflectionDirection, eyeDirection), 0.0), uMaterialShininess);
41 float diffuseLightWeighting = max(dot(normal, lightDirection), 0.0);
42 lightWeighting = uAmbientColour + uPointLightingSpecularColour * specularLightWeighting
43 + uPointLightingDiffuseColour * diffuseLightWeighting;
45 gl_FragColor = vec4(vColour.rgb * lightWeighting, vColour.a);
49 <script id="vertex-shader" type="x-shader/x-vertex">
50 attribute vec3 aVertexPosition;
51 attribute vec3 aVertexNormal;
52 attribute vec4 aVertexColour;
54 uniform mat4 uMVMatrix;
55 uniform mat4 uPMatrix;
56 uniform mat3 uNMatrix;
59 varying vec3 vTransformedNormal;
60 varying vec4 vPosition;
64 vPosition = uMVMatrix * vec4(aVertexPosition, 1.0);
65 gl_Position = uPMatrix * vPosition;
66 vColour = aVertexColour;
67 vTransformedNormal = uNMatrix * aVertexNormal;
72 <body onload="boot();">
74 Download a browser with WebGL support, like Chrome or Firefox.