-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.noasm
44 lines (44 loc) · 1.08 KB
/
main.noasm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
vec4 quatMult(vec4 q1, vec4 q2) {
vec4 r;
r.x = q1.x * q2.x - dot(q1.yzw,q2.yzw);
r.yzw = q2.yzw * q1.x + q1.yzw * q2.x + cross( q1.yzw, q2.yzw );
return r;
}
vec4 quatSq(vec4 q) {
vec4 r;
r.x = q.x * q.x - dot(q.yzw,q.yzw);
r.yzw = q.yzw * 2.0 * q.x;
return r;
}
void main(){
float f=dot(gl_Color.xyz,vec3(1,256,256*256))*0.3;
float f = time;
mat3 rotation = mat3(
vec3( cos(f), 0.0, sin(f) ),
vec3( 0.0, 1.0, 0.0 ),
vec3( -sin(f), 0.0, cos(f) )
);
vec3 r=normalize(vec3(3.0-0.005*gl_FragCoord.x,1.5-0.005*gl_FragCoord.y,1.0))*rotation;
vec3 p=vec3(0,0,-2)*rotation;
float u=300;
int c=0;
int jt = 0;
vec4 j = vec4( sin(time/2.0)/2.0, sin(time)/2.0, sin(time/4.0)/2.0, sin(time/8.0)/2.0 );
while(u>0.01&&c<255){
vec4 q = vec4(p,0);
vec4 qp = vec4(1,0,0,0);
for( int i = 0; i < 8; i++ ) {
qp = quatMult(q,qp) * 2.0;
q = quatSq(q) + j;
jt++;
if( dot(q,q) > 1000.0 ) {
break;
}
}
float l = length( q );
u = 0.5 * l * log( l ) / length( qp );
p=p+r*u;
c++;
}
gl_FragColor.rgb=vec3(c/(100.0),0,jt/400.0);
}