xxxxxxxxxx
37
precision mediump float;
uniform float time;
varying vec2 vTexCoord;
varying vec3 vNormal;
void main(){
//rotateZ is time. so i can multiply them with that
// fix: pass precomputed sin and cos as array from draw loop so it doesnt have to do them 4 times per pixel (doesnt seem to impact performance rn thooo)
mat3 rotate = mat3(
cos(time), sin(time), 0.0, // first column (not row!)
-sin(time),cos(time), 0.0, // second column
0.0, 0.0, 1.0 // third column
);
mat3 rotx = mat3( //this is just precomputed rotation of 1 rad
1.0, 0.0, 0.0,
0.0, 0.54, -0.84,
0.0, 0.84, 0.54
);
vec3 rotNormal = vNormal * rotate * rotx;
// vec3 color = vec3(vTexCoord, 1.0);
vec3 color = max(rotNormal,0.0);
vec3 cmy;
cmy.r = 1.0 - max(color.r-color.g-color.b, 0.0);
cmy.g = 1.0 - max(color.g-color.r-color.b, 0.0);
cmy.b = 1.0 - max(color.b-color.r-color.g, 0.0);
gl_FragColor = vec4(cmy, 1.0);
// gl_FragColor = vec4(1.0,0.0,0.0, 1.0);
}