-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
152 lines (108 loc) · 3.34 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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
<!DOCTYPE html>
<html lang="en">
<head>
<title>three.js webgl - lights - hemisphere light</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
<style>
body {
background-color: #fff;
color: #111;
margin: 0px;
overflow: hidden;
font-family: Monospace;
font-size: 13px;
}
#info {
position: absolute;
top: 0px; width: 100%;
padding: 5px;
text-align: center;
}
a {
color: #0080ff;
text-decoration: none;
}
a:hover {
color: #f00;
}
#footer { width: 100%; margin: 2em auto; text-align: center; position: absolute; bottom: 0 }
strong { color: red }
</style>
</head>
<body>
<div id="container"></div>
<div id="info">
<a href="http://threejs.org" target="_blank" rel="noopener">three.js</a> >rome</a><br />
</div>
<div id="footer">
press <strong>h</strong> to toggle hemisphere light, <strong>d</strong> to toggle directional light
</div>
<script src="js/three.min.js"></script>cp
<script src="js/WebGL.js"></script>
<script src="js/stats.min.js"></script>
<script src="js/OrbitControls.js"></script>
<script src="js/LoaderSupport.js"></script>
<script src="js/OBJLoader2.js"></script>
<script src="js/MTLLoader.js"></script>
<script type="x-shader/x-vertex" id="vertexShader_sky">
varying vec3 vWorldPosition;
varying vec2 vUv;
varying float randomNum;
float rand(vec2 co){
return fract(sin(dot(-co.xy ,vec2(12.9898,78.233))) * 43758.5453);
}
void main() {
vUv = uv;
vec4 worldPosition = modelMatrix * vec4( position, 1.0 );
vWorldPosition = worldPosition.xyz;
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
}
</script>
<script type="x-shader/x-fragment" id="fragmentShader_sky">
uniform vec3 topColor;
uniform vec3 bottomColor;
uniform float offset;
uniform float exponent;
uniform sampler2D tNormal;
uniform sampler2D tx;
varying vec2 vUv;
varying vec3 vWorldPosition;
void main() {
float h = normalize( vWorldPosition + offset ).y;
gl_FragColor = texture2D(tx, vUv) +vec4( mix( bottomColor, topColor, max( pow( max( h , 0.0), exponent ), 0.0 ) ), 1.0 );
}
</script>
<script type="x-shader/x-vertex" id="vertexShader_obj">
varying vec3 vWorldPosition;
varying vec2 vUv;
varying float randomNum;
void main() {
vUv = uv;
vec4 worldPosition = modelMatrix * vec4( position, 1.0 );
vWorldPosition = worldPosition.xyz;
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
}
</script>
<script type="x-shader/x-fragment" id="fragmentShader_obj">
uniform vec3 topColor;
uniform vec3 bottomColor;
uniform float offset;
uniform float exponent;
uniform sampler2D tNormal;
uniform sampler2D tx;
varying vec2 vUv;
varying vec3 vWorldPosition;
void main() {
vec3 NormalMap = texture2D(tx, vUv).rgb;
vec3 N = normalize(NormalMap * 2.0 - 1.0);
N = mix(N, vec3(0), 0.5);
//float h = normalize( vWorldPosition + offset ).y;
gl_FragColor = texture2D(tx, vUv) + N.x;
//gl_FragColor = 0.*vec4( mix( bottomColor, topColor, max( pow( max( h , 0.0), exponent ), 0.0 ) ), 1.0 );
}
</script>
<script src="main.js">
</script>
</body>
</html>