xforms for Chaotica
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

56 lines
1.8 KiB

<?xml version="1.0" encoding="utf-8"?>
<user_transforms>
<transform_def name="quaternion_strip">
<node name="input_params">
<real name="quaternion">1</real>
<real name="quaternion_rotate">0</real>
<real name="quaternion_terp1" minval="0" maxval="1">0</real>
<real name="quaternion_terp2" minval="0" maxval="1">0</real>
</node>
<node name="internal_params">
<real name="weight" />
<real name="ro" />
<real name="terp1" />
<real name="terp2" />
</node>
<int name="num_unit_randoms">1</int>
<string name="winter_init_function">
<![CDATA[
quaternion_strip_init_result(quaternion * invpi(), quaternion_rotate * halfpi(), quaternion_terp1, quaternion_terp2)
]]>
</string>
<string name="winter_eval_function">
<![CDATA[
let
rmat = mat2x2(cos(ro), -sin(ro),
sin(ro), cos(ro))
a = rmat * vec2(p_in.x, p_in.x + sin(p_in.y))
b = rmat * vec2(p_in.y, p_in.y - cos(p_in.x))
zw = complex(dot(a, p_in), dot(p_in, b))
quat = vec4(a.x * b.x - a.y * b.y - zw.re * zw.im - zw.re * zw.im,
a.x * b.y + a.y * b.x + zw.re * zw.im - zw.re * zw.im,
a.x * zw.im - a.y * zw.im + zw.re * b.x + zw.re * b.y,
a.x * zw.im + a.y * zw.im - zw.re * b.y + zw.re * b.x)
x = tan(e0(quat))
y = tan(e1(quat))
w = tanh(e2(quat))
z = tanh(e3(quat))
q = complex(w*x - (z), z*y + (w))
m1 = clamp(x, -2.0, 2.0)*2.0
m2 = clamp(y, -2.0, 2.0)*2.0
m3 = clamp(w, -2.0, 2.0)*2.0
m4 = clamp(z, -2.0, 2.0)*2.0
cxy = complex(x * x - y * y, 2.0 * x * y)
result = weight * log((q * m1) + (q * m2))
result2 = weight * log((cxy - m3) * (cxy - m4))
in
vec2(lerp(result2.im, result.im, terp1), lerp(result2.re, result.re, terp1))
]]>
</string>
</transform_def>
</user_transforms>