learnopengl/shaders/normal_geo.glsl

35 lines
590 B
GLSL

#version 330 core
#define MAGNITUDE 0.1
layout (triangles) in;
layout (line_strip, max_vertices = 6) out;
uniform float time;
in VS_OUT {
vec3 vert_normal;
} gs_in[];
layout (std140) uniform Common {
mat4 projection;
mat4 view;
vec3 camera_position;
};
void generate_line(int index) {
gl_Position = projection * gl_in[index].gl_Position;
EmitVertex();
gl_Position = projection * (gl_in[index].gl_Position + vec4(gs_in[index].vert_normal, 1.0) * MAGNITUDE);
EmitVertex();
EndPrimitive();
}
void main() {
for (int i = 0; i < 3; ++i) {
generate_line(i);
}
}