Fixed scene position.
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 bool uUseLighting;
20 uniform vec3 uAmbientColour;
21 uniform vec3 uPointLightingLocation;
22 uniform vec3 uPointLightingColour;
29 lightWeighting = vec3(1.0, 1.0, 1.0);
33 vec3 lightDirection = normalize(uPointLightingLocation - vPosition.xyz);
34 float directionalLightWeighting = max(dot(normalize(vTransformedNormal), lightDirection), 0.0);
35 lightWeighting = uAmbientColour + uPointLightingColour * directionalLightWeighting;
37 gl_FragColor = vec4(vColour.rgb * lightWeighting, vColour.a);
41 <script id="vertex-shader" type="x-shader/x-vertex">
42 attribute vec3 aVertexPosition;
43 attribute vec3 aVertexNormal;
44 attribute vec4 aVertexColour;
46 uniform mat4 uMVMatrix;
47 uniform mat4 uPMatrix;
48 uniform mat3 uNMatrix;
51 varying vec3 vTransformedNormal;
52 varying vec4 vPosition;
56 vPosition = uMVMatrix * vec4(aVertexPosition, 1.0);
57 gl_Position = uPMatrix * vPosition;
58 vColour = aVertexColour;
59 vTransformedNormal = uNMatrix * aVertexNormal;
64 <body onload="boot();">
66 Download a browser with WebGL support, like Chrome or Firefox.