-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.html
88 lines (76 loc) · 2.46 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
<!DOCTYPE html>
<html>
<head>
<title>Extending the Built-in Phong Material Shader in Three.js</title>
<link rel="stylesheet" href="css/styles.css">
<meta name="viewport" content="width=device-width,minimum-scale=1,initial-scale=1">
</head>
<body>
<div class="canvas-wrapper">
<div>
Standard
</div>
<canvas id="js-canvas-default"></canvas>
</div>
<div class="canvas-wrapper">
<div>
Custom
</div>
<canvas id="js-canvas-custom"></canvas>
</div>
<script id="js-custom-vertex-shader" type="x-shader/x-fragment">
#define PHONG
uniform float time;
attribute float offset;
varying vec3 vViewPosition;
#ifndef FLAT_SHADED
varying vec3 vNormal;
#endif
#include <common>
#include <uv_pars_vertex>
#include <uv2_pars_vertex>
#include <displacementmap_pars_vertex>
#include <envmap_pars_vertex>
#include <color_pars_vertex>
#include <fog_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <shadowmap_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
#include <uv_vertex>
#include <uv2_vertex>
#include <color_vertex>
#include <beginnormal_vertex>
#include <morphnormal_vertex>
#include <skinbase_vertex>
#include <skinnormal_vertex>
#include <defaultnormal_vertex>
#ifndef FLAT_SHADED // Normal computed with derivatives when FLAT_SHADED
vNormal = normalize( transformedNormal );
#endif
#include <begin_vertex>
#include <morphtarget_vertex>
#include <skinning_vertex>
#include <displacementmap_vertex>
#include <project_vertex>
// Here starts the custom part of the shader
float warp = time / 3000.0;
gl_Position.x *= abs(sin(warp + offset));
gl_Position.y *= abs(sin(warp + offset));
gl_Position.z *= abs(sin(warp + offset));
// Here ends the custom part of the shader
#include <logdepthbuf_vertex>
#include <clipping_planes_vertex>
vViewPosition = - mvPosition.xyz;
#include <worldpos_vertex>
#include <envmap_vertex>
#include <shadowmap_vertex>
#include <fog_vertex>
}
</script>
<script src="js/three.js"></script>
<script src="js/main.js"></script>
</body>
</html>