Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
#version 330 core
layout(triangles) in;
layout(line_strip, max_vertices = 2) out;
uniform mat4 transform;
vec3 getFaceMiddle(in vec4 v0, in vec4 v1, in vec4 v2) {
return ( + + / 3.f;
vec3 getFaceNormal(in vec4 v0, in vec4 v1, in vec4 v2) {
return normalize(cross(,;
void main() {
vec3 middle = getFaceMiddle(gl_in[0].gl_Position, gl_in[1].gl_Position, gl_in[2].gl_Position);
vec3 normal = getFaceNormal(gl_in[0].gl_Position, gl_in[1].gl_Position, gl_in[2].gl_Position);
gl_Position = transform * vec4(middle, 1);
gl_Position = transform * vec4(middle + normal, 1);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.