Created
February 23, 2015 04:40
-
-
Save humbletim/848e9069c943dd110d5d to your computer and use it in GitHub Desktop.
GLM Example - GLSL
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
mat4 rotationMatrix(vec3 axis, float angle); | |
void main(void) | |
{ | |
mat4 mrot = rotationMatrix(vec3(0.0,1.0,0.0), radians(45.0)); | |
mat4 m1 = mat4(1.0); | |
mat4 m2 = mat4(2.0); | |
mat4 m3 = m1 * m2; | |
m3 *= mrot; | |
vec2 uv = gl_FragCoord.xy / iResolution.xy; | |
gl_FragColor = m3 * vec4(uv,0.5+0.5*sin(iGlobalTime),1.0); | |
} | |
mat4 rotationMatrix(vec3 axis, float angle) | |
{ | |
axis = normalize(axis); | |
float s = sin(angle); | |
float c = cos(angle); | |
float oc = 1.0 - c; | |
return mat4(oc * axis.x * axis.x + c, oc * axis.x * axis.y - axis.z * s, oc * axis.z * axis.x + axis.y * s, 0.0, | |
oc * axis.x * axis.y + axis.z * s, oc * axis.y * axis.y + c, oc * axis.y * axis.z - axis.x * s, 0.0, | |
oc * axis.z * axis.x - axis.y * s, oc * axis.y * axis.z + axis.x * s, oc * axis.z * axis.z + c, 0.0, | |
0.0, 0.0, 0.0, 1.0); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment