Last active
October 13, 2015 05:41
-
-
Save bhautikj/c63f35a7483e34304a52 to your computer and use it in GitHub Desktop.
glsl matrix scale/translation thingo
This file contains hidden or 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
0110 | |
1111 | |
0110 |
This file contains hidden or 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 u= vec3(-0.25,-0.25,1.0); | |
vec3 v= vec3(0.25,0.25,1.0); | |
vec3 vu = v-u; | |
mat3 aMat3 = mat3(1.0/vu.x, 0.0, 0.0, | |
0.0, 1.0/vu.y, 0.0, | |
-1.0*u.x/vu.x, -1.0*u.y/vu.y, 1.0); | |
void mainImage( out vec4 fragColor, in vec2 fragCoord ) | |
{ | |
vec2 _uv = fragCoord.xy / iResolution.xy; | |
vec3 uv3 = vec3( _uv, 1.0); | |
vec3 normCoord = uv3 - u; | |
if (normCoord.x<0.0) | |
normCoord.x = normCoord.x + 1.0; | |
if (normCoord.x>1.0) | |
normCoord.x = normCoord.x - 1.0; | |
if (normCoord.y<0.0) | |
normCoord.y = normCoord.y + 1.0; | |
if (normCoord.y>1.0) | |
normCoord.y = normCoord.y - 1.0; | |
normCoord.x = normCoord.x/vu.x; | |
normCoord.y = normCoord.y/vu.y; | |
if (normCoord.x<0.|| normCoord.y<0. || normCoord.x>1.0 || normCoord.y>1.0) | |
fragColor = vec4(1.0, 1.0, 1.0, 1.0); | |
else | |
fragColor = vec4(normCoord.x, normCoord.y, 0.0, 1.0); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment