Last active
October 9, 2017 14:10
-
-
Save igalata/6a916fd095a13b1723e998371496873c to your computer and use it in GitHub Desktop.
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
// Author: | |
// Title: | |
#ifdef GL_ES | |
precision mediump float; | |
#endif | |
uniform vec2 u_resolution; | |
bool insideTriangle(vec2 uv) { | |
vec2 a = normalize(vec2(0.0, 0.0) - uv); | |
vec2 b = normalize(vec2(0.5, 1.0) - uv); | |
vec2 c = normalize(vec2(1.0, 0.0) - uv); | |
return dot(a, b) + dot(b, c) + dot(a, c) < -1.0; | |
} | |
void main() { | |
vec2 uv = gl_FragCoord.xy/u_resolution.xy; | |
float red = uv.y; | |
float green = (1.0 - uv.x) * (1.0 - uv.y); | |
float blue = uv.x * (1.0 - uv.y); | |
gl_FragColor = insideTriangle(uv) ? vec4(red, green, blue, 1.0) : vec4(1.0); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment