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.

44 lines
1.3 KiB

<?xml version="1.0" encoding="utf-8"?>
<user_transforms>
<transform_def name="linkA_split_interest">
<node name="input_params">
<real name="split_interest" minval="0.0">1</real>
<real name="split_interest_split">0</real>
<real name="split_interest_spread">0</real>
</node>
<node name="internal_params">
<real name="weight" />
<real name="split" />
<real name="spread" />
</node>
<int name="num_unit_randoms">2</int>
<string name="winter_init_function">
<![CDATA[
linkA_split_interest_init_result(split_interest, split_interest_split, split_interest * (split_interest_spread + 2))
]]>
</string>
<string name="winter_eval_function">
<![CDATA[
let
x_plus_weight = p_in.x + weight
x_less_weight = p_in.x - weight
num = x_plus_weight * x_plus_weight + p_in.y * p_in.y
den = x_less_weight * x_less_weight + p_in.y * p_in.y
a = (atan2(p_in.y, x_less_weight) - atan2(p_in.y, x_plus_weight)) * 0.5
r = spread * sqrt(sqrt(num / den))
fluxa = vec2(cos(a), sin(a)) * r
fluxb = vec2(-cos(a), sin(a)) * r
rflux = lerp(fluxa, fluxb, if unit_rnd_0 >= 0.5 then 1.0 else 0.0)
x_offset = if rflux.x >= 0 then split else -split
in
rflux + vec2(x_offset, 0.0)
]]>
</string>
</transform_def>
</user_transforms>