File size: 560 Bytes
b4c8bc3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
#version 330 core

layout (points) in;

layout (line_strip, max_vertices = 2) out;

in VS_OUT {
    vec3 position;
    vec3 normal;
    mat4 mvp;
} gs_in[];

uniform float normal_magnitude;

void GenerateVertNormal(int index)
{
    vec4 p0 = gs_in[index].mvp * vec4(gs_in[index].position, 1.0);
    vec4 p1 = gs_in[index].mvp * vec4(normal_magnitude * normalize(gs_in[index].normal) + gs_in[index].position, 1.0);
    gl_Position = p0;
    EmitVertex();
    gl_Position = p1;
    EmitVertex();
    EndPrimitive();
}

void main()
{
    GenerateVertNormal(0);
}