-
Notifications
You must be signed in to change notification settings - Fork 1
/
earth.html
69 lines (47 loc) · 2.05 KB
/
earth.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
<html>
<head>
<title>Hello world</title>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
<script src="thirdparty/Sylvester/sylvester.js" type="text/javascript"></script>
<script src="js/glUtils.js" type="text/javascript"></script>
<style type="text/css">
</style>
</head>
<body onload="start()" style="padding: 0px;margin: 0px;">
<canvas id="glcanvas">
Your browser doesn't appear to support the html5<code><canvas></code> element.
</canvas>
<script id="shader-vs" type="x-shader/x-vertex">
attribute highp vec3 aVertexPosition;
attribute highp vec2 aTextureCoord;
attribute highp vec3 aVertexNormal;
uniform highp mat4 uMVMatrix;
uniform highp mat4 uPMatrix;
uniform highp mat4 uNormalMatrix;
varying highp vec2 vTextureCoord;
varying highp vec3 vLighting;
void main(void){
gl_Position = uPMatrix * uMVMatrix * vec4(aVertexPosition,1.0);
vTextureCoord = aTextureCoord;
//光照
highp vec3 ambientLight = vec3(0.1,0.1,0.1);
highp vec3 directionalLightColor = vec3(0.8,0.8,0.8);
//highp vec3 directionalLightColor = vec3(0.5,0.0,0.0);
highp vec3 directionalVector = vec3(0.85,0.8,0.75);
highp vec4 transformedNormal = uNormalMatrix * vec4(aVertexNormal,1.0);
highp float directional = max(dot(transformedNormal.xyz,directionalVector),0.0);
vLighting = ambientLight + (directionalLightColor * directional);
}
</script>
<script id="shader-fs" type="x-shader/x-fragment">
varying highp vec2 vTextureCoord;
varying highp vec3 vLighting;
uniform sampler2D uSampler;
void main(void){
mediump vec4 texelColor = texture2D(uSampler,vec2(vTextureCoord.s,vTextureCoord.t));
gl_FragColor = vec4(texelColor.rgb * vLighting,texelColor.a);
}
</script>
<script src="js/earth.js" type="text/javascript"></script>
</body>
</html>