-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.html
222 lines (185 loc) · 7.35 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
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<!-- get the css in -->
<link rel="stylesheet" type="text/css" href="css/normalize.css" />
<link rel="stylesheet" type="text/css" href="css/webgl_app01.css" />
<script type="text/javascript">
// When the window has loaded, DOM is ready. init our main app
function init() {
mainInit();
}
window.onload = init;
</script>
<!-- just define the shaders here for now... ideally these need to be in separate files -->
<script id="vtxShader" type="x-shader/x-vertex">
// here's the calculated model-view-projection matrix
uniform mat4 u_MVPMatrix;
// here's the texture transform matrix
uniform mat4 u_TexMatrix;
// per-vertex position
attribute vec3 a_Position;
// per-vertex color
attribute vec4 a_Color;
// texture coordinate
attribute vec2 a_TexCoord;
// tex coord to pass to the frag shader
varying vec2 v_TexCoord;
// color passed to the frag shader
varying vec4 v_Color;
// main program
void main()
{
// vertex color passed into the varying (to be interpolated per fragment)
v_Color = a_Color;
// transform our vertex coords here
vec4 texTransformed = u_TexMatrix * vec4(a_TexCoord.x, a_TexCoord.y, 0.0, 1.0);
v_TexCoord = texTransformed.xy;
// transform our vertex here
gl_Position = u_MVPMatrix * vec4(a_Position, 1.0);
}
</script>
<script id="fragShader" type="x-shader/x-fragment">
// set medium precision on the frag shader
precision mediump float;
// here's the input shader
uniform sampler2D u_Texture;
uniform bool u_doVignette;
uniform float u_vigOuterBorder;
uniform float u_vigFade;
uniform float u_fStop;
uniform float u_texCenterU;
uniform float u_texCenterV;
// here's the interpolated vertex color for this fragment
varying vec4 v_Color;
// and the interpolated tex coord
varying vec2 v_TexCoord;
// user vars
float vigInnerBorder = 0.0;
float vignette()
{
if (!u_doVignette) {
return 1.0;
}
float dist = distance(v_TexCoord.xy, vec2(u_texCenterU, u_texCenterV));
dist = smoothstep(u_vigOuterBorder + (u_fStop / u_vigFade), vigInnerBorder + (u_fStop / u_vigFade), dist);
return clamp(dist, 0.0, 1.0);
}
// main program
void main()
{
// final color is the vertex color with the texture
gl_FragColor = vignette() * v_Color * texture2D(u_Texture, v_TexCoord);
gl_FragColor.a = 1.0;
}
</script>
<title>WebGL app 01</title>
</head>
<body class="unselectable">
<span>Select state: </span>
<select id="StateSelect" name="StateSelect">
<option value="SpinningImages">SpinningImages</option>
<option selected="selected" value="StaticImages">StaticImages</option>
<option value="FloatyImages">FloatyImages</option>
<option value="Slide">Slide</option>
<option value="Radial">Radial</option>
</select>
<button type="button" onclick="switchState();">Switch to State</button>
<span id="msgArea"></span>
<span style="position: relative">source: <a href="https://github.com/jchionh/webgl_app01">https://github.com/jchionh/webgl_app01</a></span>
<div id="renderArea" style="position: relative; left: 0px; top: 0px;">
<!--<div id="hudBeforeCanvas" style="position: absolute; left: 0px; top: 0px; width: 800px; height: 600px;"></div> -->
<canvas id="renderCanvas" style="width: 1024px; height: 768px; position: absolute; left: 0px; top: 0px;"></canvas>
</div>
<div id="controls" style="position: relative; left: 1024px; top: 0px;">
<table>
<tr>
<td> </td>
<td>Vignette</td>
<td> </td>
<td><input id="doVignette" type="checkbox" checked="checked" onchange="vignetteOnOff();"/></td>
<td> </td>
<td><div id="doVignetteText">On</div></td>
</tr>
<tr>
<td> </td>
<td>Border</td>
<td> </td>
<td><input id="vigOuterBorder" type="range" min="0.01" max="3.0" step="0.01" value="1.3" oninput="sliderChanged('vigOuterBorder');"/></td>
<td> </td>
<td><div id="vigOuterBorderText">1.3</div></td>
</tr>
<tr>
<td> </td>
<td>Fade</td>
<td> </td>
<td><input id="vigFade" type="range" min="10" max="70" step="1" value="22" oninput="sliderChanged('vigFade');"/></td>
<td> </td>
<td><div id="vigFadeText">22</div></td>
</tr>
<tr>
<td> </td>
<td>F-Stop</td>
<td> </td>
<td><input id="fStop" type="range" min="0.01" max="8.0" step="0.01" value="0.9" oninput="sliderChanged('fStop');"/></td>
<td> </td>
<td><div id="fStopText">0.9</div></td>
</tr>
</table>
<button onclick="defaultVignetteValues();">Default Vignette Values</button>
</div>
<!--
<div id="sysMessageArea" style="position: relative;">
</div>
-->
<!-- js sources -->
<script src="js/webgl_app01.js"></script>
<!-- utils -->
<script src="js/utils/extend.js"></script>
<script src="js/utils/webgl-utils.js"></script>
<script src="js/utils/ShaderUtils.js"></script>
<script src="js/utils/IntrusiveList.js"></script>
<script src="js/utils/IntrusiveListNode.js"></script>
<script src="js/utils/glMatrix.js"></script>
<script src="js/utils/ImageUtils.js"></script>
<script src="js/render/RenderConstants.js"></script>
<!-- texture -->
<script src="js/texture/Texture.js"></script>
<!-- cache -->
<script src="js/cache/QuadVertexBufferLibrary.js"></script>
<script src="js/cache/QuadVertexColorBufferLibrary.js"></script>
<script src="js/cache/QuadTexCoordBufferLibrary.js"></script>
<script src="js/cache/TextureLibrary.js"></script>
<!-- renderer -->
<script src="js/render/Viewpoint.js"></script>
<script src="js/render/FrustumViewpoint.js"></script>
<script src="js/render/Shape.js"></script>
<script src="js/render/QuadShape.js"></script>
<script src="js/render/SceneNode.js"></script>
<script src="js/render/Scene.js"></script>
<script src="js/render/ShaderHandleRefs.js"></script>
<script src="js/render/Renderer.js"></script>
<!-- entity -->
<script src="js/entity/Entity.js"></script>
<script src="js/entity/ImageEntityGlobals.js"></script>
<script src="js/entity/ImageEntity.js"></script>
<script src="js/entity/ImageEntityFactory.js"></script>
<!-- app data -->
<script src="js/data/ImageList.js"></script>
<!-- input -->
<script src="js/input/MouseInput.js"></script>
<script src="js/input/InputManager.js"></script>
<!-- run states -->
<script src="js/runstate/BaseRunState.js"></script>
<script src="js/runstate/GLRunState.js"></script>
<script src="js/runstate/StateRunner.js"></script>
<!-- app run states -->
<script src="js/states/InitialState.js"></script>
<script src="js/states/FloatyImages.js"></script>
<script src="js/states/SpinningImages.js"></script>
<script src="js/states/StaticImages.js"></script>
<!-- main -->
<script src="js/main.js"></script>
</body>
</html>