-
Notifications
You must be signed in to change notification settings - Fork 233
/
mesh-vertex.glsl
51 lines (41 loc) · 1.33 KB
/
mesh-vertex.glsl
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
// for animation, all between 0 and 1
uniform float animation_time_x;
uniform float animation_time_y;
uniform float animation_time_z;
uniform float animation_time_u;
uniform float animation_time_v;
uniform float animation_time_color;
uniform vec2 xlim;
uniform vec2 ylim;
uniform vec2 zlim;
varying vec3 vertex_color;
varying vec3 vertex_position;
attribute vec3 position_previous;
#ifdef USE_TEXTURE
attribute float u;
attribute float v;
attribute float u_previous;
attribute float v_previous;
varying vec2 vertex_uv;
#endif
attribute vec3 color;
attribute vec3 color_previous;
void main(void) {
vec3 origin = vec3(xlim.x, ylim.x, zlim.x);
vec3 size_viewport = vec3(xlim.y, ylim.y, zlim.y) - origin;
vec3 pos = (mix(position_previous, position, vec3(animation_time_x, animation_time_y, animation_time_z))
- origin) / size_viewport - 0.5;
gl_Position = projectionMatrix *
modelViewMatrix *
vec4(pos,1.0);
vec3 positionEye = ( modelViewMatrix * vec4( pos, 1.0 ) ).xyz;
vertex_position = positionEye;
#ifdef USE_TEXTURE
vertex_uv = vec2(mix(u_previous, u, animation_time_u), mix(v_previous, v, animation_time_v));
#endif
#ifdef USE_RGB
vertex_color = vec3(pos + vec3(0.5, 0.5, 0.5));
#else
vertex_color = mix(color_previous, color, animation_time_color);
#endif
}