Created
August 26, 2015 15:23
-
-
Save rikusalminen/87a012e6a687f0550d27 to your computer and use it in GitHub Desktop.
Wireframe cube in GLSL (usage: glDrawArrays(0, 24))
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#version 420 | |
uniform mat4 projection_matrix; | |
uniform mat4 model_matrix; | |
void main() { | |
vec4 pos = vec4(0.0, 0.0, 0.0, 1.0); | |
int axis = gl_VertexID >> 3; | |
pos[(axis+0)%3] = (gl_VertexID & 1) >> 0; | |
pos[(axis+1)%3] = (gl_VertexID & 2) >> 1; | |
pos[(axis+2)%3] = (gl_VertexID & 4) >> 2; | |
gl_Position = projection_matrix * model_matrix * | |
(vec4(-1.0) + 2.0*pos); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks for showing a very interesting approach. However, when I slightly modified the shader using" varying vec4 pos" and applied it to an example in www.openglsuperbible.com (linesmooth) only a quad is shown. Could you provide a complete source code example or explain the logic of your shader code?