-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.html
75 lines (53 loc) · 2.14 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
<html>
<head>
<title>WebGL Demo</title>
<link rel="stylesheet" href="style.css"/>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script data-main="scripts/app" src="bower_components/requirejs/require.js"></script>
<script src="scripts/libs/dat.gui.js" type="text/javascript"></script>
<link href='http://fonts.googleapis.com/css?family=Roboto' rel='stylesheet' type='text/css'>
<!-- Fragment shader program -->
<script id="shader-fs" type="x-shader/x-fragment">
varying highp vec3 vColor;
varying highp vec3 vLightWeighting;
void main(void) {
gl_FragColor = vec4(vColor, 1.0); //vec4(vColor * vLightWeighting, 1.0);
}
</script>
<!-- Vertex shader program -->
<script id="shader-vs" type="x-shader/x-vertex">
attribute vec3 aVertexPosition;
attribute vec3 aVertexColor;
attribute vec3 aVertexNormal;
uniform highp mat3 uNMatrix;
uniform highp mat4 uMVMatrix;
uniform highp mat4 uPMatrix;
varying highp vec3 vColor;
varying vec3 vLightWeighting;
uniform vec3 uAmbientColor;
uniform vec3 uPointLightingLocation;
uniform vec3 uPointLightingColor;
void main(void) {
vColor = aVertexColor;
gl_PointSize = 8.0;
vec4 mvPosition = uMVMatrix * vec4(aVertexPosition, 1.0);
gl_Position = uPMatrix * mvPosition;
// Lighting
vec3 lightDirection = normalize(uPointLightingLocation - mvPosition.xyz);
vec3 transformedNormal = uNMatrix * aVertexNormal;
float directionalLightWeighting = max(dot(transformedNormal, lightDirection), 0.0);
vLightWeighting = uAmbientColor + uPointLightingColor * directionalLightWeighting;
//vLightWeighting = uPointLightcolor * directionalLightWeighting;
}
</script>
</head>
<body>
<canvas id="glcanvas">
Your browser doesn't appear to support the HTML5 <code><canvas></code> element.
</canvas>
<div id="btmTxt">
<h1 id="originalTxt">Original Vertices</h1>
<h1 id = "currentTxt">Current Vertices </h1>
</div>
</body>
</html>