Last active
December 9, 2019 19:29
-
-
Save valler/ac7fdd9afd490cd2a08abc63739d77f1 to your computer and use it in GitHub Desktop.
WebGL2 Minimal Shaders
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
// both triangles CCW | |
vec3 quad (int x) | |
{ | |
vec3 p = step(vec3(1,2,3),vec3(x%3)); | |
return mix(p, vec3(p.x-p.y,p.x,0), step(3.,float(x%6))); | |
} |
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
// one triangle CW and one CCW | |
vec3 quad (int x) | |
{ | |
vec3 p = step(vec3(1,2,3),vec3(x%3)); | |
return mix(p,p.yxz,step(3.,float(x%6))); | |
} |
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
// one triangle CW and one CCW | |
#version 300 es | |
void main() | |
{ | |
vec4 p = step(vec4(1,2,3,0),vec4(x%3)); | |
return mix(p,p.yxzw,step(3.,float(x%6))); | |
} |
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
// one triangle CW and one CCW | |
#version 300 es | |
void main() | |
{ | |
ivec3 p = clamp(ivec3(1,2,0)%(gl_VertexID%3+1),0,1); | |
int a = clamp(gl_VertexID%6-2,0,1); | |
gl_Position = vec4(p*(1-a)+p.yxz*a,1); | |
} |
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 300 es | |
void main () { gl_Position = step(vec4(1,2,3,0),vec4(gl_VertexID%3)); } |
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
vec3 triangle (int x) { return step(vec3(1,2,3),vec3(x%3)); } |
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 300 es | |
void main() { gl_Position = vec4(clamp(ivec3(1,2,0)%(gl_VertexID%3+1),0,1),1); } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment