-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathindex.html
357 lines (282 loc) · 10.9 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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
<html>
<head>
<title>Realistic Rendering Techniques on Parametric Surfaces</title>
<meta content='width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0, shrink-to-fit=no' name='viewport' />
<!-- Fonts and icons -->
<link href="https://fonts.googleapis.com/css?family=Montserrat:400,700,200" rel="stylesheet" />
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/latest/css/font-awesome.min.css" />
<!-- CSS Files -->
<link href="./assets/css/bootstrap.min.css" rel="stylesheet" />
<link href="./assets/css/now-ui-kit.css?v=1.1.0" rel="stylesheet" />
<!-- Simple Tweaks in template -->
<style>
.bg-success {
background: #1D4350; /* fallback for old browsers */
background: -webkit-linear-gradient(to left, #A43931, #1D4350); /* Chrome 10-25, Safari 5.1-6 */
background: linear-gradient(to left, #A43931, #1D4350); /* W3C, IE 10+/ Edge, Firefox 16+, Chrome 26+, Opera 12+, Safari 7+ */
}
body {
background-color: black;
}
.btn-warning {
background: #1D4350; /* fallback for old browsers */
background: -webkit-linear-gradient(to left, #A43931, #1D4350); /* Chrome 10-25, Safari 5.1-6 */
background: linear-gradient(to left, #A43931, #1D4350); /* W3C, IE 10+/ Edge, Firefox 16+, Chrome 26+, Opera 12+, Safari 7+ */
}
.nav-link {
cursor: pointer;
}
</style>
<script id="primitive-vshader" type="x-shader/x-vertex">
attribute vec4 aVertexPosition_ms;
uniform mat4 M;
uniform mat4 V;
uniform mat4 P;
void main() {
gl_Position = P*V*M*aVertexPosition_ms;
}
</script>
<script id="primitive-fshader" type="x-shader/x-fragment">
precision mediump float;
uniform vec4 uColor;
void main(){
gl_FragColor = uColor;
}
</script>
<script id="wireframe-vshader" type="x-shader/x-vertex">
precision mediump float;
attribute vec3 aNormal_ms;
attribute vec4 aVertexPosition_ms;
attribute vec2 aTexcoord;
//varying vec3 vColor;
varying vec3 vDiffuse;
varying vec3 vSpecular;
varying vec2 vTexcoord;
uniform vec3 uLightPosition_ws;
uniform mat4 M;
uniform mat4 V;
uniform mat4 P;
uniform mat3 N;
void main() {
gl_Position = P * V * M * aVertexPosition_ms;
vec3 LightColor = vec3(1, 1, 1);
vec3 n = normalize( vec3(10,1,0) * aNormal_ms);
float cosTheta = clamp(dot(n, vec3(1.0,1.0,1.0)), 0.0, 1.0);
vDiffuse = LightColor * cosTheta;
}</script>
<script id="wireframe-fshader" type="x-shader/x-fragment">
precision mediump float;
void main() {
gl_FragColor.rgb = vec3(1.0,1.0,1.0);
gl_FragColor.a = 1.0;
}
</script>
<script id="gouraud-vshader" type="x-shader/x-vertex">
precision mediump float;
attribute vec3 aNormal_ms;
attribute vec4 aVertexPosition_ms;
attribute vec2 aTexcoord;
//varying vec3 vColor;
varying vec3 vDiffuse;
varying vec3 vSpecular;
varying vec2 vTexcoord;
varying vec3 vLight;
varying vec3 vNorm;
uniform vec3 uLightPosition_ws;
uniform vec2 timeShifter;
uniform mat4 M;
uniform mat4 V;
uniform mat4 P;
uniform mat3 N;
void main() {
gl_Position = P * V * M * aVertexPosition_ms;
vec3 lightPosition_cs = (V * vec4(uLightPosition_ws, 1)).xyz;
vec3 vertexPosition_cs = (V * M * aVertexPosition_ms).xyz;
vec3 LightColor = vec3(1, 1, 1);
vec3 MaterialSpecularColor = vec3(0.3, 0.3, 0.3);
float distance = length(uLightPosition_ws - (M * aVertexPosition_ms).xyz);
vec3 n = normalize(N * aNormal_ms);
vec3 l = normalize(lightPosition_cs - vertexPosition_cs);
vec3 e = normalize(vec3(0, 0, 0) - vertexPosition_cs);
vec3 r = reflect(-l, n);
float cosTheta = clamp(dot(n, l), 0.0, 1.0);
float cosAlpha = clamp(dot(e, r), 0.0, 1.0);
float LightPower = 4000.0 / (distance * distance);
vTexcoord = aTexcoord;
float shininess = 35.0;
vLight = l;
vNorm = N * aNormal_ms;
vDiffuse = LightColor * LightPower;// * cosTheta;
vSpecular = LightColor * LightPower * pow(cosAlpha, shininess);
}</script>
<script id="gouraud-fshader" type="x-shader/x-fragment">
precision mediump float;
//varying vec3 vColor;
varying vec3 vDiffuse;
varying vec3 vSpecular;
varying vec2 vTexcoord;
varying vec3 vLight;
varying vec3 vNorm;
uniform sampler2D uDiffuseTexture;
uniform sampler2D uSpecularTexture;
uniform sampler2D uNormalTexture;
uniform vec2 timeShifter;
uniform vec3 uLightPosition_ws;
void main() {
vec3 normalMap = normalize( texture2D( uNormalTexture, vTexcoord + timeShifter ).rgb * 2. - 1.0);
float cosTheta = clamp(dot(normalize(vNorm*normalMap), vLight), 0.0, 1.0);
vec3 MaterialDiffuseColor = texture2D(uDiffuseTexture, vTexcoord + timeShifter).rgb;
vec3 MaterialAmbientColor = 0.9 * MaterialDiffuseColor;
vec3 vDiffuseTex = MaterialDiffuseColor * vDiffuse * cosTheta ;
gl_FragColor.rgb = vDiffuseTex + MaterialAmbientColor + (vSpecular * texture2D(uSpecularTexture, vTexcoord + timeShifter).rgb);
gl_FragColor.a = 1.0;
}
</script>
<script id="phong-vshader" type="x-shader/x-vertex">
precision mediump float;
// Attribs
attribute vec3 aNormal_ms;
attribute vec4 aVertexPosition_ms;
attribute vec2 aTexcoord;
// Varyings
varying vec2 vTexcoord;
varying vec3 vVertexPosition_ws;
varying vec3 vNormal_cs;
varying vec3 vLightDirection_cs;
varying vec3 vEyeDirection_cs;
uniform vec3 uLightPosition_ws;
uniform mat4 M;
uniform mat4 V;
uniform mat4 P;
uniform mat3 N;
void main()
{
gl_Position = P*V*M*aVertexPosition_ms;
vVertexPosition_ws = (M*aVertexPosition_ms).xyz;
vec3 lightPosition_cs = ( V * vec4(uLightPosition_ws,1)).xyz;
vec3 vertexPosition_cs = (V * M * aVertexPosition_ms).xyz;
vEyeDirection_cs = vec3(0,0,0) - vertexPosition_cs;
vLightDirection_cs = lightPosition_cs - vertexPosition_cs;
vNormal_cs = N*aNormal_ms;
vTexcoord = aTexcoord;
}
</script>
<script id="phong-fshader" type="x-shader/x-fragment">
precision mediump float;
varying vec2 vTexcoord;
varying vec3 vVertexPosition_ws;
varying vec3 vNormal_cs;
varying vec3 vLightDirection_cs;
varying vec3 vEyeDirection_cs;
uniform sampler2D uDiffuseTexture;
uniform sampler2D uSpecularTexture;
uniform sampler2D uNormalTexture;
uniform vec2 timeShifter;
uniform vec3 uLightPosition_ws;
void main() {
vec3 LightColor = vec3(1,1,1);
vec3 MaterialDiffuseColor = texture2D( uDiffuseTexture, vTexcoord + timeShifter ).rgb;
vec3 MaterialAmbientColor = 0.9 * MaterialDiffuseColor;
vec3 MaterialSpecularColor = vec3(0.3,0.3,0.3);
float distance = length(uLightPosition_ws - vVertexPosition_ws);
// Retrieve the normal from the normal map
vec3 normalMap = normalize( texture2D( uNormalTexture, vTexcoord + timeShifter ).rgb * 1.5 - 1.0);
vec3 n = normalize(vNormal_cs*normalMap);
vec3 l = normalize(vLightDirection_cs);
vec3 e = normalize(vEyeDirection_cs);
vec3 r = reflect(-l,n);
float cosTheta = clamp(dot(n,l), 0.0,1.0);
float cosAlpha = clamp( dot( e,r ), 0.0,1.0 );
float LightPower = 4000.0/(distance*distance);
float shininess = 35.0;
gl_FragColor.rgb =
MaterialAmbientColor +
MaterialDiffuseColor * LightColor * LightPower * cosTheta +
LightColor * LightPower * (pow(cosAlpha, shininess) * texture2D(uSpecularTexture, vTexcoord + timeShifter).rgb);
gl_FragColor.a = 1.0;
}
</script>
<script src="resources/jquery.3.2.1.min.js"></script>
<script src="resources/underscore.js"></script>
<script type="text/javascript" src="Common/webgl-utils.js"></script>
<script type="text/javascript" src="Common/initShaders.js"></script>
<script type="text/javascript" src="Common/MV.js"></script>
<script type="text/javascript" src="Common/numeric-1.2.6.min.js"></script>
<script type="text/javascript" src="shaderProgram.js"></script>
<script type="text/javascript" src="mathUtils.js"></script>
<script type="text/javascript" src="BezierSurface.js"></script>
<script type="text/javascript" src="SurfaceModel.js"></script>
<script type="text/javascript" src="models.js"></script>
<script type="text/javascript" src="camera.js"></script>
<script type="text/javascript" src="draggablePoints.js"></script>
<script type="text/javascript" src="mouseStateMachine.js"></script>
<script type="text/javascript" src="eventHandling.js"></script>
<script type="text/javascript" src="main.js"></script>
</head>
<body>
<div class="row">
<div class="col">
<canvas id="gl-canvas" width="1150" height="700"></canvas>
</div>
<div class="col" style="margin-left: -2%; margin-right:0px;">
<div class="container">
<div class="row" class="margin: 0px;">
<div class="card card-signup" data-background-color="red" style="margin-top: 100px; margin-right: 5px; margin-left: -25px">
<form class="form" method="" action="">
<div class="header text-center">
<h4 class="title title-up">Settings</h4>
</div>
<div class="card-body">
<div class="input-group form-group-no-border">
<span class="input-group-addon">
<i class="now-ui-icons design_vector"></i>
</span>
<input type="text" class="form-control" id="contPointX" placeholder="Control Point Count X" value="5">
</div>
<div class="input-group form-group-no-border">
<span class="input-group-addon">
<i class="now-ui-icons design_vector"></i>
</span>
<input type="text" class="form-control" id="contPointY" placeholder="Control Point Count Y" value="5">
</div>
<div class="checkbox">
<input id="preserveCheck" type="checkbox">
<label for="preserveCheck">
Preserve Resolution?
</label>
</div>
<div class="radio">
<input type="radio" name="radio1" id="phongShadingRadio" checked="">
<label for="phongShadingRadio">
Phong Shader
</label>
</div>
<div class="radio">
<input type="radio" name="radio1" id="gouraudShadingRadio"checked="">
<label for="gouraudShadingRadio">
Gouraud Shading
</label>
</div>
<div class="radio">
<input type="radio" name="radio1" id="wireShadingRadio" checked="">
<label for="wireShadingRadio">
Wireframe Shading
</label>
</div>
<div class="footer text-center">
<a id="recreateButton" onclick="init()" class="btn btn-neutral btn-round btn-lg" style="color:red;">Create</a>
</div>
</form>
</div>
</div>
</div>
<br>
<div>
<a class="btn btn-danger" onclick="switchTexture()" style="color:white; margin-left: 22%">
Switch Texture
</a>
</div>
</div>
</div>
</body>
</html>