CGII/framework/shader/plot/glsl/plot2d_face.glgs

24 lines
527 B
Text
Raw Normal View History

2018-05-17 14:01:02 +00:00
#version 150 compatibility
#extension GL_EXT_geometry_shader4 : enable
out vec3 eye_position;
out vec3 normal;
void main()
{
vec3 p0 = gl_PositionIn[0].xyz;
vec3 p1 = gl_PositionIn[1].xyz;
vec3 p2 = gl_PositionIn[2].xyz;
normal = normalize(gl_NormalMatrix * cross(p2-p0,p1-p0));
for (int i=0; i<3; ++i) {
vec4 heye_position = gl_ModelViewMatrix * gl_PositionIn[i];
eye_position = heye_position.xyz / heye_position.w;
gl_Position = gl_ProjectionMatrix * heye_position;
EmitVertex();
}
EndPrimitive();
}