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
|
#version 330
#if defined VERTEX_SHADER
in vec3 in_position;
in vec3 in_normal;
out vec2 uv;
out vec3 normal;
void main() {
gl_Position = vec4(in_position, 1.0);
normal = in_normal;
}
#elif defined GEOMETRY_SHADER
layout(points) in;
layout(points, max_vertices = 1) out;
uniform mat4 projection;
uniform mat4 modelview;
in vec3 normal[1];
void main() {
mat3 normalMatrix = inverse(transpose(mat3(modelview)));
vec3 normalTransformed = normalMatrix * normalize(normal[0]);
vec4 positionTransformed = modelview * gl_in[0].gl_Position;
if (dot(normalTransformed, -normalize(positionTransformed.xyz)) > 0.1) {
gl_Position = projection * positionTransformed;
EmitVertex();
EndPrimitive();
}
}
#elif defined FRAGMENT_SHADER
out vec4 out_color;
uniform vec4 color;
void main() {
out_color = color;
}
#endif
|