-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtextureFromBuffer.html
42 lines (35 loc) · 1.42 KB
/
textureFromBuffer.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
<!DOCTYPE html>
<html>
<head>
<title>Uint16 Texture</title>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
<script type="text/javascript" src="glMatrix095.js"></script>
<script type="text/javascript" src="webGL-utils.js"></script>
<script type="text/javascript" src="gl-preview.js"></script>
<!--would be nice to import these, but that seems to make the browser very unhappy-->
<script id="shader-fs" type="text/x-fragment">
precision mediump float;
varying vec2 vTextureCoord;
uniform sampler2D uSampler;
void main(void) {
vec4 samples = texture2D(uSampler, vec2(vTextureCoord.t, vTextureCoord.s));
float sample = samples.a;
float adjusted = sample > .5 ? sample -.5 : .5+sample;
gl_FragColor = vec4(adjusted, 0.0, samples.r, 1.0);
}
</script>
<script id="shader-vs" type="text/x-vertex">
attribute vec2 aTextureCoord;
uniform mat4 uMVMatrix;
uniform mat4 uPMatrix;
varying vec2 vTextureCoord;
void main(void) {
gl_Position = uPMatrix * uMVMatrix * vec4(aTextureCoord,0.0,1.0);
vTextureCoord = aTextureCoord;
}
</script>
</head>
<body onload="webGLStart();">
<canvas width="1024" height="512" id="lesson05-canvas" style="top:0; left:0; position:absolute; border: none; width:100%; height:100%;"></canvas>
</body>
</html>