-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.asasm
44 lines (44 loc) · 1.21 KB
/
main.asasm
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
db "vec4 quatMult(vec4 q1, vec4 q2) {"
db "vec4 r;"
db "r.x = q1.x * q2.x - dot(q1.yzw,q2.yzw);"
db "r.yzw = q2.yzw * q1.x + q1.yzw * q2.x + cross( q1.yzw, q2.yzw );"
db "return r;"
db "}"
db "vec4 quatSq(vec4 q) {"
db "vec4 r;"
db "r.x = q.x * q.x - dot(q.yzw,q.yzw);"
db "r.yzw = q.yzw * 2.0 * q.x;"
db "return r;"
db "}"
db "void main(){"
db "float f=dot(gl_Color.xyz,vec3(1,256,256*256))*0.3;"
db "float f = time;"
db "mat3 rotation = mat3("
db "vec3( cos(f), 0.0, sin(f) ),"
db "vec3( 0.0, 1.0, 0.0 ),"
db "vec3( -sin(f), 0.0, cos(f) )"
db ");"
db "vec3 r=normalize(vec3(3.0-0.005*gl_FragCoord.x,1.5-0.005*gl_FragCoord.y,1.0))*rotation;"
db "vec3 p=vec3(0,0,-2)*rotation;"
db "float u=300;"
db "int c=0;"
db "int jt = 0;"
db "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 );"
db "while(u>0.01&&c<255){"
db "vec4 q = vec4(p,0);"
db "vec4 qp = vec4(1,0,0,0);"
db "for( int i = 0; i < 8; i++ ) {"
db "qp = quatMult(q,qp) * 2.0;"
db "q = quatSq(q) + j;"
db "jt++;"
db "if( dot(q,q) > 1000.0 ) {"
db "break;"
db "}"
db "}"
db "float l = length( q );"
db "u = 0.5 * l * log( l ) / length( qp );"
db "p=p+r*u;"
db "c++;"
db "}"
db "gl_FragColor.rgb=vec3(c/(100.0),0,jt/400.0);"
db "}"