-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathglsl-quad.js
102 lines (84 loc) · 2.12 KB
/
glsl-quad.js
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
const verts = [
[-1.0, -1.0],
[+1.0, -1.0],
[-1.0, +1.0],
[-1.0, +1.0],
[+1.0, -1.0],
[+1.0, +1.0]
];
const uvs = [
[0.0, 0.0],
[1.0, 0.0],
[0.0, 1.0],
[0.0, 1.0],
[1.0, 0.0],
[1.0, 1.0]
];
const indices = [
[0, 1, 2],
[3, 4, 5]
];
const vshader = `
precision mediump float;
attribute vec2 a_position;
attribute vec2 a_uv;
uniform float u_clip_y;
varying vec2 v_uv;
void main() {
v_uv = a_uv;
gl_Position = vec4(a_position * vec2(1,u_clip_y), 0, 1);
}
`;
const fshader = `
precision mediump float;
varying vec2 v_uv;
uniform sampler2D u_tex;
void main () {
gl_FragColor = texture2D(u_tex,v_uv);
}
`;
const showUVsFshader = `
precision mediump float;
varying vec2 v_uv;
void main () {
gl_FragColor = vec4(v_uv,0,1);
}
`;
const showPositionsVshader = `
precision mediump float;
attribute vec2 a_position;
uniform float u_clip_y;
varying vec2 v_uv;
void main() {
gl_Position = vec4(a_position * vec2(1,u_clip_y), 0, 1);
v_uv = gl_Position.xy;
}
`;
const showPositionsFshader = `
precision mediump float;
varying vec2 v_uv;
void main () {
gl_FragColor = vec4(v_uv,0,1);
}
`;
const directionsDataUri = `
data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAA
BACAIAAAAlC+aJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQ
UAAAAJcEhZcwAAEnQAABJ0Ad5mH3gAAAEbSURBVGhD7dhRDsIgEI
RhjubNPHqlHUTAdjfRWRKa+UIirQnd376Z0vZZG1vQsfvB76WAa3
En3yug3GHD0HX6gIZCAaYaEGdSQM2g9yjApADfpIBhTzQvIIgCTA
rwKcCkAJ8CTArwKcCkAN/56Y/8XAZCwH7AsS6sEDBseisEYF1YIW
DY9Lq7eW6Mjk29/Bk/YD+vO7Bc/D/rKULAqSbj80tHrOehPC9mjY
/krhkBeBF4HvZE6CgXRJgeW3wAPYMf0IwO1NO/RL2BhgJMCvApwK
QAnwJMCvApwKQAnwJMCvApwNQGYE/vmRowbCgUYLpbQHvJMi8gSN
TpmLsGxGWsH9Aq90gwfW1gwv9zx+qUr0mWD8hCps/uE5DSC/pgVD
kvIARVAAAAAElFTkSuQmCC`.replace(/\s*/g, '');
const bitmaps = {
directions: {uri: directionsDataUri}
};
module.exports = {verts, indices, uvs, shader: {vert: vshader, frag: fshader},
show: {
uvs: {frag: showUVsFshader, vert: vshader},
positions: {frag: showPositionsFshader, vert: showPositionsVshader}
},
bitmaps};