blob: e70859190ee40de8a20c5b5e184f25d6528526a9 (
plain)
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
|
#version 330 core
layout(triangles) in;
layout(triangle_strip, max_vertices = 3) out;
in VS_OUT {
vec2 gtex_coords;
} gs_in[];
out vec2 ftex_coords;
uniform float time;
vec3 get_normal(void)
{
vec3 a = vec3(gl_in[0].gl_Position)-vec3(gl_in[1].gl_Position);
vec3 b = vec3(gl_in[2].gl_Position)-vec3(gl_in[1].gl_Position);
return(normalize(cross(a, b)));
}
vec4 explode(vec4 position, vec3 normal)
{
float magnitude = 0.2;
vec3 direction = normal*magnitude*((sin(time)+1.0)/2.0);
vec4 result = position+vec4(direction, 0.0);
return(result);
}
void main(void)
{
vec3 normal = get_normal();
gl_Position = explode(gl_in[0].gl_Position, normal);
ftex_coords = gs_in[0].gtex_coords;
EmitVertex();
gl_Position = explode(gl_in[1].gl_Position, normal);
ftex_coords = gs_in[1].gtex_coords;
EmitVertex();
gl_Position = explode(gl_in[2].gl_Position, normal);
ftex_coords = gs_in[2].gtex_coords;
EmitVertex();
EndPrimitive();
}
|