-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.html
103 lines (85 loc) · 3.71 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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
<!doctype html>
<html>
<head>
<title>requirejs入门(一)</title>
<meta charset="utf-8">
<!--<script id="shader-vs" type="x-shader/x-vertex">-->
<!--attribute vec3 aVertexPosition;-->
<!--attribute vec3 aVertexNormal;-->
<!--attribute vec4 aVertexColor;-->
<!--uniform mat4 uMVMatrix;-->
<!--uniform mat4 uPMatrix;-->
<!--uniform mat4 uNMatrix;-->
<!--uniform vec3 uLightPosition;-->
<!--uniform vec4 uLightAmbient;-->
<!--uniform vec4 uLightDiffuse;-->
<!--uniform vec4 uMaterialDiffuse;-->
<!--uniform bool uWireframe;-->
<!--uniform bool uPerVertexColor;-->
<!--varying vec4 vFinalColor;-->
<!--void main(void) {-->
<!--if (uWireframe) {-->
<!--if (uPerVertexColor){-->
<!--vFinalColor = aVertexColor;-->
<!--}-->
<!--else{-->
<!--vFinalColor = uMaterialDiffuse;-->
<!--}-->
<!--}-->
<!--else{-->
<!--vec3 N = vec3(uNMatrix * vec4(aVertexNormal, 0.0)); // This is a vector w = 0;-->
<!--vec3 L = normalize(-uLightPosition); // Given a light position, use the inverse is the direction (to the center of the world)-->
<!--//L = vec3(uNMatrix*vec4(L,0.0)); // vector light direction-->
<!--float lambertTerm = dot(N,-L);-->
<!--if (lambertTerm <= 0.0) lambertTerm = 0.01;-->
<!--vec4 Ia = uLightAmbient;-->
<!--vec4 Id = uMaterialDiffuse * uLightDiffuse * lambertTerm;-->
<!--vFinalColor = Ia + Id;-->
<!--vFinalColor.a = 1.0; //alpha channel-->
<!--}-->
<!--//Transformed vertex position-->
<!--gl_Position = uPMatrix * uMVMatrix * vec4(aVertexPosition,1.0); // vertex w=1-->
<!--}-->
<!--</script>-->
<!--<script id="shader-fs" type="x-shader/x-fragment">-->
<!--#ifdef GL_ES-->
<!--precision highp float;-->
<!--#endif-->
<!--varying vec4 vFinalColor;-->
<!--void main(void) {-->
<!--gl_FragColor = vFinalColor;-->
<!--}-->
<!--</script>-->
<!-- Fragment Shader //-->
<script id="shader-fs" type="x-shader/x-fragment">
#ifdef GL_ES
precision highp float;
#endif
uniform vec3 og_sunPosition;
//uniform vec3 u_color;
uniform sampler2D og_texture0;
varying vec3 vPosition;
void main(void) {
//gl_FragColor = vec4(1.0,0.0,0.0, 1.0);
vec3 texColor = texture2D(og_texture0, vec2(abs(vPosition.x),abs(vPosition.y))).rgb;
gl_FragColor = vec4(texColor,1.0);
}
</script>
<!-- Vertex Shader //-->
<script id="shader-vs" type="x-shader/x-vertex">
attribute vec3 aVertexPosition;
//uniform mat4 og_modelViewPerspectiveMatrix;
varying vec3 vPosition;
void main(void) {
vPosition = aVertexPosition;
gl_Position = vec4(aVertexPosition,1.0);
}
</script>
<!--<script src="Source/thirdparty/gl-matrix.js"></script>-->
<script src="Source/thirdparty/webgl-utils.js"></script>
</head>
<body>
<canvas id="canvas" width="680" height="680"></canvas>
<script data-main="main" src="require.js"></script>
</body>
</html>