Source files
This commit is contained in:
@@ -0,0 +1 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?><package><identifier v="Unsaved Package"/><formatVersion v="1.1.0.202001"/><updaterVersion v="1.1.0.202001"/><fileUID v="{1bf6091d-5ab2-43f3-9281-74d1430462c0}"/><versionUID v="0"/><dependencies/><content><graph><identifier v="lighning"/><uid v="1386008979"/><graphOutputs/><compNodes/><baseParameters/><options><option><name v="defaultParentSize"/><value v="11x11"/></option></options><root/></graph><graph><identifier v="cracks"/><uid v="1387702143"/><graphOutputs/><compNodes/><baseParameters/><options><option><name v="defaultParentSize"/><value v="11x11"/></option></options><root/></graph><graph><identifier v="plant"/><uid v="1387702154"/><graphOutputs/><compNodes/><baseParameters/><options><option><name v="defaultParentSize"/><value v="11x11"/></option></options><root/></graph><graph><identifier v="recursive_growth"/><uid v="1387702167"/><graphOutputs/><compNodes/><baseParameters/><options><option><name v="defaultParentSize"/><value v="11x11"/></option></options><root/></graph><graph><identifier v="path_tracer"/><uid v="1387702177"/><graphOutputs/><compNodes/><baseParameters/><options><option><name v="defaultParentSize"/><value v="11x11"/></option></options><root/></graph><graph><identifier v="leaks"/><uid v="1387702187"/><graphOutputs/><compNodes/><baseParameters/><options><option><name v="defaultParentSize"/><value v="11x11"/></option></options><root/></graph></content></package>
|
||||||
@@ -0,0 +1,150 @@
|
|||||||
|
:: import "macros.sex" as macros
|
||||||
|
|
||||||
|
:: if grayscale
|
||||||
|
declare_inputs("curve_area_splatter")
|
||||||
|
:: else
|
||||||
|
declare_inputs("curve_area_splatter_color")
|
||||||
|
:: endif
|
||||||
|
|
||||||
|
out_color = get_float4("out_color")
|
||||||
|
pattern_size_calc = get_float2("pattern_size_calc")
|
||||||
|
n = get_float("$number")
|
||||||
|
bridge_samples = get_int("bridge_samples_calc")
|
||||||
|
bridge_index = get_int("bridge_index")
|
||||||
|
bridge_start_carve = get_float("bridge_start_carve")
|
||||||
|
bridge_end_carve = get_float("bridge_end_carve")
|
||||||
|
pattern_rotation = get_float("pattern_rotation")
|
||||||
|
pattern_offset_calc = get_float2("pattern_offset_calc")
|
||||||
|
number = toint(n) + bridge_index
|
||||||
|
|
||||||
|
bridge_samples_num = bridge_samples - 1 if bridge_samples > 1 else bridge_samples
|
||||||
|
bridge_samples_num = bridge_samples if closed_area else bridge_samples_num
|
||||||
|
|
||||||
|
bridge_n = n / tofloat(bridge_samples_num)
|
||||||
|
bridge_n = bridge_start_carve + bridge_n * (bridge_end_carve - bridge_start_carve)
|
||||||
|
|
||||||
|
frag_size = 1.0 / get_float2("$size").x
|
||||||
|
carved_niter = n / tofloat(bridge_samples_num)
|
||||||
|
|
||||||
|
mod_sample_non_carved = frag_size / 2.0 + bridge_n * (1.0 - frag_size)
|
||||||
|
mod_sample_carved = frag_size / 2.0 + carved_niter * (1.0 - frag_size)
|
||||||
|
|
||||||
|
:: for i in range(1, 9)
|
||||||
|
modifier_op = modifier_{{ i }}_addmult
|
||||||
|
|
||||||
|
mod_sample = mod_sample_carved if modifier{{ i }}_carve else mod_sample_non_carved
|
||||||
|
|
||||||
|
bridge_modifier{{ i }} = samplelum(vector2(mod_sample, 0.5), {{ i + 23}}, 0)
|
||||||
|
bridge_modifier{{ i }} = bridge_modifier{{ i }} * modifier_op.x + modifier_op.y
|
||||||
|
:: endfor
|
||||||
|
|
||||||
|
:: for i in range(16)
|
||||||
|
bridge_pt{{ i }} = get_float2("bridge_pt{{ i }}")
|
||||||
|
:: endfor
|
||||||
|
|
||||||
|
{{ macros.get_bridge_modifier("size_mod", "bridge_size_mod") }}
|
||||||
|
{{ macros.get_bridge_modifier("size_mod_w", "br_size_modifier_idx_width") }}
|
||||||
|
{{ macros.get_bridge_modifier("size_mod_h", "br_size_modifier_idx_height") }}
|
||||||
|
{{ macros.get_bridge_modifier("size_var_mod", "bridge_size_var_mod") }}
|
||||||
|
{{ macros.get_bridge_modifier("rot_mod", "bridge_rotation_mod", "0.0") }}
|
||||||
|
{{ macros.get_bridge_modifier("rot_var_mod", "bridge_rotation_var_mod") }}
|
||||||
|
{{ macros.get_bridge_modifier("v_mod", "bridge_vertical_offset_mod", "0.0") }}
|
||||||
|
{{ macros.get_bridge_modifier("v_var_mod", "bridge_vertical_offset_var_mod") }}
|
||||||
|
{{ macros.get_bridge_modifier("h_mod", "bridge_horizontal_offset_mod", "0.0") }}
|
||||||
|
{{ macros.get_bridge_modifier("h_var_mod", "bridge_horizontal_offset_var_mod") }}
|
||||||
|
:: if grayscale
|
||||||
|
{{ macros.get_bridge_modifier("col_mod", "bridge_color_mod") }}
|
||||||
|
{{ macros.get_bridge_modifier("col_var_mod", "bridge_color_var_mod") }}
|
||||||
|
:: endif
|
||||||
|
{{ macros.get_bridge_modifier("remap", "bridge_remapping_mod") }}
|
||||||
|
{{ macros.get_bridge_modifier("mask_mod", "bridge_mask_mod") }}
|
||||||
|
{{ macros.get_bridge_modifier("idx_mod", "bridge_idx_distr_mod") }}
|
||||||
|
{{ macros.get_bridge_modifier("sym_mod", "bridge_symmetry_mod", "1.0") }}
|
||||||
|
|
||||||
|
bridge_n = (bridge_start_carve + remap * (bridge_end_carve - bridge_start_carve)) if bridge_remapping_mod > 0 else bridge_n
|
||||||
|
|
||||||
|
c_sample = {{ macros.sample_curve("bridge_n", "curves_num", "closed_area", "bridge_alpha", "bridge_tension", "bridge_pt") }}
|
||||||
|
|
||||||
|
point_calc = c_sample.xy
|
||||||
|
deriative = c_sample.zw
|
||||||
|
|
||||||
|
# get bridge direction
|
||||||
|
rot_calc = pattern_rotation
|
||||||
|
rot_calc = rot_calc + atan2(deriative) / _2pi() if is_orient else rot_calc
|
||||||
|
norm_dir = normalize_vec2(deriative)
|
||||||
|
dir_x_axis = rotate_vec2(norm_dir, -0.25, float2(0.0, 0.0))
|
||||||
|
|
||||||
|
# offset
|
||||||
|
v_offs_var = bridge_voffs_var * v_var_mod
|
||||||
|
v_offs = pattern_offset_calc.y + v_mod + uniform_ab(-v_offs_var, v_offs_var)
|
||||||
|
|
||||||
|
h_offs_var = bridge_hoffs_var * h_var_mod
|
||||||
|
h_offs = pattern_offset_calc.x + h_mod + uniform_ab(-h_offs_var, h_offs_var)
|
||||||
|
|
||||||
|
|
||||||
|
b_offs = norm_dir @ v_offs + dir_x_axis @ h_offs
|
||||||
|
|
||||||
|
# size
|
||||||
|
size_var = uniform_f2_ab(-bridge_size_var_nuniform, bridge_size_var_nuniform)
|
||||||
|
size_var_u = uniform_ab(-bridge_size_var, bridge_size_var)
|
||||||
|
size_var = vector2(size_var_u, size_var_u) if is_size_var_uniform else size_var
|
||||||
|
|
||||||
|
size_m = vector2(size_mod, size_mod) if is_size_var_uniform else vector2(size_mod_w, size_mod_h)
|
||||||
|
|
||||||
|
pattern_size_calc = (pattern_size_calc * size_m + size_var @ size_var_mod)
|
||||||
|
|
||||||
|
# rotation
|
||||||
|
rot_var = bridge_rotation_var * rot_var_mod
|
||||||
|
rot_calc = rot_calc + (rot_mod + uniform_ab(-rot_var, rot_var))
|
||||||
|
|
||||||
|
# pivot compensation
|
||||||
|
pivot_pos = pivot_pos * pattern_size_calc
|
||||||
|
|
||||||
|
pivot_rot_offset = rotate_vec2(pivot_pos, -rot_calc, float2(0.0, 0.0))
|
||||||
|
point_calc = point_calc - pivot_rot_offset + b_offs
|
||||||
|
|
||||||
|
# Calculate symmetry
|
||||||
|
|
||||||
|
sym_mult = get_float2("sym_mult")
|
||||||
|
{{ macros.symmetry_calculation("sym_mult_bridge") }}
|
||||||
|
|
||||||
|
sym_mult = sym_mult * sym_mult_bridge
|
||||||
|
|
||||||
|
bridge_pattern_size = pattern_size_calc * sym_mult
|
||||||
|
bridge_pattern_rotation = rot_calc
|
||||||
|
|
||||||
|
:: if grayscale
|
||||||
|
{{ macros.calculate_bridge_grayscale() }}
|
||||||
|
:: else
|
||||||
|
{{ macros.calculate_bridge_color(33) }}
|
||||||
|
:: endif
|
||||||
|
|
||||||
|
|
||||||
|
# Calculate pattern index
|
||||||
|
|
||||||
|
pattern_index = bridge_index
|
||||||
|
|
||||||
|
ping_pong = 2 * inputs_num - 2
|
||||||
|
ping_pong_loop = number % ping_pong
|
||||||
|
pattern_ping_pong = ping_pong_loop if ping_pong_loop < inputs_num else ping_pong - ping_pong_loop
|
||||||
|
pattern_ping_pong = 0 if inputs_num == 1 else pattern_ping_pong
|
||||||
|
|
||||||
|
pattern_random = uniform_ab(0.0, tofloat(inputs_num))
|
||||||
|
pattern_random = toint(pattern_random)
|
||||||
|
|
||||||
|
pattern_mod = idx_mod * tofloat(inputs_num)
|
||||||
|
pattern_mod = toint(pattern_mod)
|
||||||
|
pattern_mod = 0 if pattern_mod < 0 else pattern_mod
|
||||||
|
pattern_mod = (inputs_num - 1) if pattern_mod > (inputs_num - 1) else pattern_mod
|
||||||
|
|
||||||
|
pattern_index = number % inputs_num if pattern_bridge_distr_mode == 1 else pattern_index
|
||||||
|
pattern_index = pattern_ping_pong if pattern_bridge_distr_mode == 2 else pattern_index
|
||||||
|
pattern_index = pattern_random if pattern_bridge_distr_mode == 3 else pattern_index
|
||||||
|
pattern_index = pattern_mod if pattern_bridge_distr_mode == 4 else pattern_index
|
||||||
|
|
||||||
|
pattern_index = pattern_index + 16
|
||||||
|
|
||||||
|
export(pattern_index)
|
||||||
|
export(point_calc)
|
||||||
|
export(bridge_pattern_size)
|
||||||
|
export(bridge_pattern_rotation)
|
||||||
@@ -0,0 +1,192 @@
|
|||||||
|
:: import "macros.sex" as macros
|
||||||
|
|
||||||
|
:: if grayscale
|
||||||
|
declare_inputs("curve_area_splatter")
|
||||||
|
:: else
|
||||||
|
declare_inputs("curve_area_splatter_color")
|
||||||
|
:: endif
|
||||||
|
|
||||||
|
:: for ci in range(16)
|
||||||
|
:: for i in range(16)
|
||||||
|
curve{{ ci }}_pt{{ i }} = get_float2("curve{{ ci }}_pt{{ i }}")
|
||||||
|
:: endfor
|
||||||
|
is_closed{{ ci }} = get_bool("is_closed{{ ci }}")
|
||||||
|
alpha{{ ci }} = get_float("alpha{{ ci }}")
|
||||||
|
tension{{ ci }} = get_float("tension{{ ci }}")
|
||||||
|
npoints{{ ci }} = get_int("npoints{{ ci }}")
|
||||||
|
:: endfor
|
||||||
|
|
||||||
|
current_index = get_int("current_index")
|
||||||
|
even_index = get_int("even_index")
|
||||||
|
n = get_float("$number")
|
||||||
|
iters = get_int("total_samples")
|
||||||
|
|
||||||
|
prev_point = get_float2("prev_point")
|
||||||
|
acc_dist = get_float("acc_dist")
|
||||||
|
total_dist = get_float("total_dist")
|
||||||
|
|
||||||
|
iters_m1 = iters - 1 if iters > 1 else iters
|
||||||
|
iters_m1 = iters if is_closed0 and not is_resample else iters_m1
|
||||||
|
fiters = tofloat(iters_m1)
|
||||||
|
|
||||||
|
norm_iter = carving.x + n / fiters * (carving.y - carving.x)
|
||||||
|
|
||||||
|
|
||||||
|
frag_size = 1.0 / get_float2("$size").x
|
||||||
|
carved_niter = n / fiters
|
||||||
|
|
||||||
|
mod_sample_non_carved = frag_size / 2.0 + norm_iter * (1.0 - frag_size)
|
||||||
|
mod_sample_carved = frag_size / 2.0 + carved_niter * (1.0 - frag_size)
|
||||||
|
|
||||||
|
:: for i in range(1, 9)
|
||||||
|
|
||||||
|
modifier_op = modifier_{{ i }}_addmult
|
||||||
|
|
||||||
|
mod_sample = mod_sample_carved if modifier{{ i }}_carve else mod_sample_non_carved
|
||||||
|
|
||||||
|
modifier{{ i }} = samplelum(vector2(mod_sample, 0.5), {{ i + 23 }}, 0)
|
||||||
|
modifier{{ i }} = modifier{{ i }} * modifier_op.x + modifier_op.y
|
||||||
|
|
||||||
|
:: endfor
|
||||||
|
|
||||||
|
c0_sample = {{ macros.sample_curve("norm_iter", "npoints0", "is_closed0", "alpha0", "tension0", "curve0_pt") }}
|
||||||
|
|
||||||
|
point = c0_sample.xy
|
||||||
|
|
||||||
|
sample_dist = get_float("min_dist")
|
||||||
|
prev_point = point if n < 1.0 else prev_point
|
||||||
|
|
||||||
|
segment_vector = point - prev_point
|
||||||
|
segment_dist = length_vec2(segment_vector)
|
||||||
|
|
||||||
|
segment_dir = normalize_vec2(segment_vector) if segment_dist > 0.0000001 else float2(0.0, 1.0)
|
||||||
|
acc_dist = acc_dist + segment_dist
|
||||||
|
|
||||||
|
overshoot = (acc_dist > sample_dist)
|
||||||
|
overshoot_dist = acc_dist - sample_dist
|
||||||
|
acc_dist = acc_dist if not overshoot else 0.0
|
||||||
|
p_dst = segment_dist - overshoot_dist
|
||||||
|
|
||||||
|
out_point = prev_point + segment_dir @ p_dst if overshoot else float2(0.0, 0.0)
|
||||||
|
out_point = point if n < 1.0 or not is_resample else out_point
|
||||||
|
overshoot = True if n < 1.0 else overshoot
|
||||||
|
|
||||||
|
:: for i in range(1, 16)
|
||||||
|
c0_sample = {{ macros.sample_curve("norm_iter", "npoints%d" % i, "is_closed%d" % i, "alpha%d" % i, "tension%d" % i, "curve%d_pt" % i) }}
|
||||||
|
bridge_pt{{ i }} = c0_sample.xy
|
||||||
|
:: endfor
|
||||||
|
|
||||||
|
bridge_pt0 = out_point
|
||||||
|
|
||||||
|
## Color calculation
|
||||||
|
|
||||||
|
:: if grayscale
|
||||||
|
{{ macros.get_modifier("color_mod_m", "color_modifier_idx") }}
|
||||||
|
{{ macros.get_modifier("color_var_mod_m", "color_var_modifier_idx") }}
|
||||||
|
:: endif
|
||||||
|
{{ macros.get_modifier("mask_mod", "mask_modifier_idx") }}
|
||||||
|
{{ macros.get_modifier("rot_mod", "rotation_modifier_idx") }}
|
||||||
|
{{ macros.get_modifier("rot_var_mod", "rotation_var_modifier_idx") }}
|
||||||
|
{{ macros.get_modifier("size_mod", "size_modifier_idx") }}
|
||||||
|
{{ macros.get_modifier("size_var_mod", "size_var_modifier_idx") }}
|
||||||
|
{{ macros.get_modifier("size_mod_w", "size_modifier_idx_width") }}
|
||||||
|
{{ macros.get_modifier("size_mod_h", "size_modifier_idx_height") }}
|
||||||
|
{{ macros.get_modifier("offset_mod", "offset_modifier_idx") }}
|
||||||
|
{{ macros.get_modifier("offset_var_mod", "offset_var_modifier_idx") }}
|
||||||
|
|
||||||
|
# Size calculation
|
||||||
|
|
||||||
|
size_var = uniform_f2_ab(-pattern_size_var, pattern_size_var)
|
||||||
|
size_var_u = uniform_ab(-size_uniform_var, size_uniform_var)
|
||||||
|
|
||||||
|
size_var = vector2(size_var_u, size_var_u) if is_size_var_uniform else size_var
|
||||||
|
pattern_size = pattern_size if not is_size_var_uniform else vector2(pattern_size_uniform, pattern_size_uniform)
|
||||||
|
|
||||||
|
size_m = vector2(size_mod, size_mod) if is_size_var_uniform else vector2(size_mod_w, size_mod_h)
|
||||||
|
pattern_size_calc = pattern_size * size_m + size_var @ size_var_mod
|
||||||
|
|
||||||
|
# Offset calculation
|
||||||
|
|
||||||
|
offset_var = uniform_f2_ab(-offset_var, offset_var)
|
||||||
|
pattern_offset_calc = pattern_offset @ offset_mod + offset_var @ offset_var_mod
|
||||||
|
pat_offset_for_color = pattern_offset_calc
|
||||||
|
|
||||||
|
# Calculate rotation
|
||||||
|
|
||||||
|
rot_var = uniform_ab(-rotation_var, rotation_var)
|
||||||
|
pattern_rotation = rotation * rot_mod + rot_var * rot_var_mod + 0.25
|
||||||
|
rot_calc = pattern_rotation
|
||||||
|
|
||||||
|
# Color calculation
|
||||||
|
|
||||||
|
:: if grayscale
|
||||||
|
{{ macros.calculate_grayscale(false) }}
|
||||||
|
:: else
|
||||||
|
{{ macros.calculate_color(false, 32) }}
|
||||||
|
:: endif
|
||||||
|
|
||||||
|
# Calculate bridge samples
|
||||||
|
|
||||||
|
{{ macros.get_modifier("samples_mod", "bridge_samples_mod") }}
|
||||||
|
|
||||||
|
bridge_samples = toint( tofloat(bridge_samples) * samples_mod )
|
||||||
|
bridge_samples = 0 if not overshoot and is_resample else bridge_samples
|
||||||
|
bridge_samples = 0 if is_masked else bridge_samples
|
||||||
|
|
||||||
|
# Calculate index for bridge
|
||||||
|
|
||||||
|
{{ macros.bridge_index_calculation() }}
|
||||||
|
|
||||||
|
#####
|
||||||
|
|
||||||
|
_OUT_ = bridge_samples
|
||||||
|
|
||||||
|
bridge_samples_calc = bridge_samples
|
||||||
|
|
||||||
|
prev_point = prev_point + point - prev_point
|
||||||
|
total_dist = total_dist + segment_dist
|
||||||
|
|
||||||
|
even_index = -even_index if overshoot and is_resample else even_index
|
||||||
|
even_index = -even_index if not is_resample else even_index
|
||||||
|
|
||||||
|
current_index = current_index + 1 if overshoot and is_resample else current_index
|
||||||
|
current_index = current_index + 1 if not is_resample else current_index
|
||||||
|
|
||||||
|
# Calculate symmetry
|
||||||
|
|
||||||
|
{{ macros.get_modifier("sym_mod", "symmetry_modifier_idx", "1.0") }}
|
||||||
|
{{ macros.symmetry_calculation() }}
|
||||||
|
|
||||||
|
# Calculate bridge carving
|
||||||
|
|
||||||
|
{{ macros.get_modifier("start_carve_mod", "bridge_start_carving_mod", "0.0") }}
|
||||||
|
{{ macros.get_modifier("end_carve_mod", "bridge_end_carving_mod", "1.0") }}
|
||||||
|
|
||||||
|
bridge_start_carve = start_carve_mod if use_carving_mod else carving_src.x
|
||||||
|
bridge_end_carve = end_carve_mod if use_carving_mod else carving_src.y
|
||||||
|
|
||||||
|
:: if not grayscale
|
||||||
|
export(v_intencity)
|
||||||
|
export(v_add_rot)
|
||||||
|
:: endif
|
||||||
|
export(bridge_start_carve)
|
||||||
|
export(bridge_end_carve)
|
||||||
|
export(sym_mult)
|
||||||
|
export(bridge_index)
|
||||||
|
export(bridge_samples_calc)
|
||||||
|
export(out_color)
|
||||||
|
export(pattern_size_calc)
|
||||||
|
export(current_index)
|
||||||
|
export(even_index)
|
||||||
|
export(pattern_rotation)
|
||||||
|
export(pattern_offset_calc)
|
||||||
|
|
||||||
|
export(prev_point)
|
||||||
|
export(acc_dist)
|
||||||
|
export(total_dist)
|
||||||
|
|
||||||
|
:: for i in range(16)
|
||||||
|
|
||||||
|
export(bridge_pt{{ i }})
|
||||||
|
|
||||||
|
:: endfor
|
||||||
@@ -0,0 +1,128 @@
|
|||||||
|
:: import "macros.sex" as macros
|
||||||
|
|
||||||
|
:: if grayscale
|
||||||
|
declare_inputs("curve_bridge_splatter")
|
||||||
|
:: else
|
||||||
|
declare_inputs("curve_bridge_splatter_color")
|
||||||
|
:: endif
|
||||||
|
|
||||||
|
src_point = get_float2("src_point")
|
||||||
|
dst_point = get_float2("dst_point")
|
||||||
|
out_color = get_float4("out_color")
|
||||||
|
pattern_size_calc = get_float2("pattern_size_calc")
|
||||||
|
source_offset = get_float2("source_offset")
|
||||||
|
rot_calc = get_float("rot_calc")
|
||||||
|
n = get_float("$number")
|
||||||
|
bridge_samples = get_int("bridge_samples_calc")
|
||||||
|
bridge_index = get_int("bridge_index")
|
||||||
|
number = toint(n) + bridge_index
|
||||||
|
|
||||||
|
bridge_samples_num = bridge_samples - 1 if bridge_samples > 1 else 1
|
||||||
|
bridge_n = n / tofloat(bridge_samples_num)
|
||||||
|
|
||||||
|
frag_size = 1.0 / get_float2("$size").x
|
||||||
|
mod_sample = frag_size / 2.0 + bridge_n * (1.0 - frag_size)
|
||||||
|
:: for i in range(1, 9)
|
||||||
|
modifier_op = modifier_{{ i }}_addmult
|
||||||
|
bridge_modifier{{ i }} = samplelum(vector2(mod_sample, 0.5), {{ i + 9}}, 0)
|
||||||
|
bridge_modifier{{ i }} = bridge_modifier{{ i }} * modifier_op.x + modifier_op.y
|
||||||
|
:: endfor
|
||||||
|
|
||||||
|
{{ macros.get_bridge_modifier("size_mod", "bridge_size_mod") }}
|
||||||
|
{{ macros.get_bridge_modifier("size_mod_w", "br_size_modifier_idx_width") }}
|
||||||
|
{{ macros.get_bridge_modifier("size_mod_h", "br_size_modifier_idx_height") }}
|
||||||
|
{{ macros.get_bridge_modifier("size_var_mod", "bridge_size_var_mod") }}
|
||||||
|
{{ macros.get_bridge_modifier("rot_mod", "bridge_rotation_mod", "0.0") }}
|
||||||
|
{{ macros.get_bridge_modifier("rot_var_mod", "bridge_rotation_var_mod") }}
|
||||||
|
{{ macros.get_bridge_modifier("v_mod", "bridge_vertical_offset_mod", "0.0") }}
|
||||||
|
{{ macros.get_bridge_modifier("v_var_mod", "bridge_vertical_offset_var_mod") }}
|
||||||
|
{{ macros.get_bridge_modifier("h_mod", "bridge_horizontal_offset_mod", "0.0") }}
|
||||||
|
{{ macros.get_bridge_modifier("h_var_mod", "bridge_horizontal_offset_var_mod") }}
|
||||||
|
:: if grayscale
|
||||||
|
{{ macros.get_bridge_modifier("col_mod", "bridge_color_mod") }}
|
||||||
|
{{ macros.get_bridge_modifier("col_var_mod", "bridge_color_var_mod") }}
|
||||||
|
:: endif
|
||||||
|
{{ macros.get_bridge_modifier("remap", "bridge_remapping_mod") }}
|
||||||
|
{{ macros.get_bridge_modifier("mask_mod", "bridge_mask_mod") }}
|
||||||
|
{{ macros.get_bridge_modifier("idx_mod", "bridge_idx_distr_mod") }}
|
||||||
|
{{ macros.get_bridge_modifier("sym_mod", "bridge_symmetry_mod", "1.0") }}
|
||||||
|
|
||||||
|
bridge_n = remap if bridge_remapping_mod > 0 and bridge_type == 1 else bridge_n
|
||||||
|
|
||||||
|
norm_dir = get_float2("norm_dir")
|
||||||
|
dir_x_axis = get_float2("dir_x_axis")
|
||||||
|
bridge_length = get_float("bridge_length")
|
||||||
|
|
||||||
|
v_offs_var = bridge_voffs_var * v_var_mod
|
||||||
|
v_offs = v_mod + uniform_ab(-v_offs_var, v_offs_var)
|
||||||
|
|
||||||
|
h_offs_var = bridge_hoffs_var * h_var_mod
|
||||||
|
h_offs = h_mod + uniform_ab(-h_offs_var, h_offs_var)
|
||||||
|
|
||||||
|
|
||||||
|
b_offs = norm_dir @ (v_offs * bridge_length) + dir_x_axis @ (h_offs * bridge_length)
|
||||||
|
|
||||||
|
|
||||||
|
size_var = uniform_f2_ab(-bridge_size_var_nuniform, bridge_size_var_nuniform)
|
||||||
|
size_var_u = uniform_ab(-bridge_size_var, bridge_size_var)
|
||||||
|
size_var = vector2(size_var_u, size_var_u) if is_size_var_uniform and not is_size_relative else size_var
|
||||||
|
|
||||||
|
size_m = vector2(size_mod, size_mod) if is_size_var_uniform else vector2(size_mod_w, size_mod_h)
|
||||||
|
|
||||||
|
pattern_size_calc = (pattern_size_calc * size_m + size_var @ size_var_mod)
|
||||||
|
|
||||||
|
|
||||||
|
point_calc = lerp(src_point, dst_point, bridge_n) + source_offset
|
||||||
|
|
||||||
|
rot_var = bridge_rotation_var * rot_var_mod
|
||||||
|
rot_calc = rot_calc + (rot_mod + uniform_ab(-rot_var, rot_var))
|
||||||
|
|
||||||
|
pivot_pos = pivot_pos * pattern_size_calc
|
||||||
|
|
||||||
|
pivot_rot_offset = rotate_vec2(pivot_pos, -rot_calc, float2(0.0, 0.0))
|
||||||
|
point_calc = point_calc - pivot_rot_offset + b_offs
|
||||||
|
|
||||||
|
# Calculate symmetry
|
||||||
|
|
||||||
|
sym_mult = get_float2("sym_mult")
|
||||||
|
{{ macros.symmetry_calculation("sym_mult_bridge") }}
|
||||||
|
|
||||||
|
sym_mult = sym_mult * sym_mult_bridge
|
||||||
|
|
||||||
|
bridge_pattern_size = pattern_size_calc * sym_mult
|
||||||
|
bridge_pattern_rotation = rot_calc
|
||||||
|
|
||||||
|
:: if grayscale
|
||||||
|
{{ macros.calculate_bridge_grayscale() }}
|
||||||
|
:: else
|
||||||
|
{{ macros.calculate_bridge_color() }}
|
||||||
|
:: endif
|
||||||
|
|
||||||
|
# Calculate pattern index
|
||||||
|
|
||||||
|
pattern_index = bridge_index
|
||||||
|
|
||||||
|
ping_pong = 2 * inputs_num - 2
|
||||||
|
ping_pong_loop = number % ping_pong
|
||||||
|
pattern_ping_pong = ping_pong_loop if ping_pong_loop < inputs_num else ping_pong - ping_pong_loop
|
||||||
|
pattern_ping_pong = 0 if inputs_num == 1 else pattern_ping_pong
|
||||||
|
|
||||||
|
pattern_random = uniform_ab(0.0, tofloat(inputs_num))
|
||||||
|
pattern_random = toint(pattern_random)
|
||||||
|
|
||||||
|
pattern_mod = idx_mod * tofloat(inputs_num)
|
||||||
|
pattern_mod = toint(pattern_mod)
|
||||||
|
pattern_mod = 0 if pattern_mod < 0 else pattern_mod
|
||||||
|
pattern_mod = (inputs_num - 1) if pattern_mod > (inputs_num - 1) else pattern_mod
|
||||||
|
|
||||||
|
pattern_index = number % inputs_num if pattern_bridge_distr_mode == 1 else pattern_index
|
||||||
|
pattern_index = pattern_ping_pong if pattern_bridge_distr_mode == 2 else pattern_index
|
||||||
|
pattern_index = pattern_random if pattern_bridge_distr_mode == 3 else pattern_index
|
||||||
|
pattern_index = pattern_mod if pattern_bridge_distr_mode == 4 else pattern_index
|
||||||
|
|
||||||
|
pattern_index = pattern_index + 2
|
||||||
|
|
||||||
|
export(pattern_index)
|
||||||
|
export(point_calc)
|
||||||
|
export(bridge_pattern_size)
|
||||||
|
export(bridge_pattern_rotation)
|
||||||
@@ -0,0 +1,270 @@
|
|||||||
|
:: import "macros.sex" as macros
|
||||||
|
|
||||||
|
:: if grayscale
|
||||||
|
declare_inputs("curve_bridge_splatter")
|
||||||
|
:: else
|
||||||
|
declare_inputs("curve_bridge_splatter_color")
|
||||||
|
:: endif
|
||||||
|
|
||||||
|
|
||||||
|
:: for i in range(16)
|
||||||
|
pt{{ i }} = get_float2("pt{{ i }}")
|
||||||
|
spt{{ i }} = get_float2("spt{{ i }}")
|
||||||
|
:: endfor
|
||||||
|
|
||||||
|
current_index = get_int("current_index")
|
||||||
|
even_index = get_int("even_index")
|
||||||
|
alpha = get_float("alpha")
|
||||||
|
tension = get_float("tension")
|
||||||
|
npoints = get_int("npoints")
|
||||||
|
is_closed = get_bool("is_closed")
|
||||||
|
alpha_src = get_float("alpha_src")
|
||||||
|
tension_src = get_float("tension_src")
|
||||||
|
npoints_src = get_int("npoints_src")
|
||||||
|
is_closed_src = get_bool("is_closed_src")
|
||||||
|
|
||||||
|
prev_point = get_float2("prev_point")
|
||||||
|
acc_dist = get_float("acc_dist")
|
||||||
|
total_dist = get_float("total_dist")
|
||||||
|
|
||||||
|
n = get_float("$number")
|
||||||
|
iters = get_int("total_samples")
|
||||||
|
|
||||||
|
dest_carved = (carving.x > 0.0) or (carving.y < 1.0)
|
||||||
|
|
||||||
|
_iters_m1 = iters - 1 if iters > 1 else iters
|
||||||
|
iters_m1 = iters if (is_closed and not is_resample) and not dest_carved else _iters_m1
|
||||||
|
fiters = tofloat(iters_m1)
|
||||||
|
|
||||||
|
iters_m1_src = iters if (is_closed_src and not is_resample) else _iters_m1
|
||||||
|
fiters_src = tofloat(iters_m1_src)
|
||||||
|
|
||||||
|
norm_iter = carving.x + n / fiters * (carving.y - carving.x)
|
||||||
|
|
||||||
|
iter_ping_pong = n / fiters_src
|
||||||
|
iter_ping_pong = iter_ping_pong * 2.0 if iter_ping_pong < 0.5 else 1.0 - (iter_ping_pong - 0.5) * 2.0
|
||||||
|
src_iter = iter_ping_pong if source_ping_pong else n / fiters
|
||||||
|
|
||||||
|
norm_iter_src = carving_src.x + src_iter * (carving_src.y - carving_src.x)
|
||||||
|
|
||||||
|
frag_size = 1.0 / get_float2("$size").x
|
||||||
|
carved_niter = n / fiters
|
||||||
|
|
||||||
|
mod_sample_non_carved = frag_size / 2.0 + norm_iter * (1.0 - frag_size)
|
||||||
|
mod_sample_carved = frag_size / 2.0 + carved_niter * (1.0 - frag_size)
|
||||||
|
|
||||||
|
:: for i in range(1, 9)
|
||||||
|
modifier_op = modifier_{{ i }}_addmult
|
||||||
|
|
||||||
|
mod_sample = mod_sample_carved if modifier{{ i }}_carve else mod_sample_non_carved
|
||||||
|
|
||||||
|
modifier{{ i }} = samplelum(vector2(mod_sample, 0.5), {{ i + 9 }}, 0)
|
||||||
|
modifier{{ i }} = modifier{{ i }} * modifier_op.x + modifier_op.y
|
||||||
|
:: endfor
|
||||||
|
|
||||||
|
c_sample = {{ macros.sample_curve("norm_iter", "npoints", "is_closed", "alpha", "tension", "pt") }}
|
||||||
|
point = c_sample.xy
|
||||||
|
deriative = c_sample.zw
|
||||||
|
|
||||||
|
sample_dist = get_float("min_dist")
|
||||||
|
prev_point = point if n < 1.0 else prev_point
|
||||||
|
|
||||||
|
segment_vector = point - prev_point
|
||||||
|
segment_dist = length_vec2(segment_vector)
|
||||||
|
|
||||||
|
segment_dir = normalize_vec2(segment_vector) if segment_dist > 0.0000001 else float2(0.0, 1.0)
|
||||||
|
acc_dist = acc_dist + segment_dist
|
||||||
|
|
||||||
|
overshoot = (acc_dist > sample_dist)
|
||||||
|
overshoot_dist = acc_dist - sample_dist
|
||||||
|
acc_dist = acc_dist if not overshoot else 0.0
|
||||||
|
p_dst = segment_dist - overshoot_dist
|
||||||
|
|
||||||
|
out_point = prev_point + segment_dir @ p_dst if overshoot else float2(0.0, 0.0)
|
||||||
|
out_point = point if n < 1.0 or not is_resample else out_point
|
||||||
|
overshoot = True if n < 1.0 else overshoot
|
||||||
|
|
||||||
|
|
||||||
|
## Calculate src curve
|
||||||
|
|
||||||
|
c_sample = {{ macros.sample_curve("norm_iter_src", "npoints_src", "is_closed_src", "alpha_src", "tension_src", "spt") }}
|
||||||
|
src_point = c_sample.xy
|
||||||
|
|
||||||
|
##############
|
||||||
|
|
||||||
|
:: if grayscale
|
||||||
|
{{ macros.get_modifier("color_mod_m", "color_modifier_idx") }}
|
||||||
|
{{ macros.get_modifier("color_var_mod_m", "color_var_modifier_idx") }}
|
||||||
|
:: endif
|
||||||
|
{{ macros.get_modifier("offset_mod", "offset_modifier_idx") }}
|
||||||
|
{{ macros.get_modifier("offset_var_mod", "offset_var_modifier_idx") }}
|
||||||
|
{{ macros.get_modifier("mask_mod", "mask_modifier_idx") }}
|
||||||
|
{{ macros.get_modifier("rot_mod", "rotation_modifier_idx") }}
|
||||||
|
{{ macros.get_modifier("rot_var_mod", "rotation_var_modifier_idx") }}
|
||||||
|
{{ macros.get_modifier("size_mod", "size_modifier_idx") }}
|
||||||
|
{{ macros.get_modifier("size_mod_w", "size_modifier_idx_width") }}
|
||||||
|
{{ macros.get_modifier("size_mod_h", "size_modifier_idx_height") }}
|
||||||
|
{{ macros.get_modifier("size_var_mod", "size_var_modifier_idx") }}
|
||||||
|
{{ macros.get_modifier("src_offset_mod", "src_offset_modifier_idx") }}
|
||||||
|
{{ macros.get_modifier("src_offset_var_mod", "src_offset_var_modifier_idx") }}
|
||||||
|
{{ macros.get_modifier("dst_offset_mod", "dst_offset_modifier_idx") }}
|
||||||
|
{{ macros.get_modifier("dst_offset_var_mod", "dst_offset_var_modifier_idx") }}
|
||||||
|
|
||||||
|
|
||||||
|
offset_rand = uniform_f2_ab(-offset_var, offset_var) @ offset_var_mod
|
||||||
|
pat_offset = pattern_offset @ offset_mod + offset_rand @ offset_var_mod
|
||||||
|
pat_offset = pat_offset * vector2(1.0, -1.0)
|
||||||
|
pat_offset_for_color = pat_offset
|
||||||
|
|
||||||
|
angle_dir = atan2(deriative) / _2pi()
|
||||||
|
orient_angle = angle_dir
|
||||||
|
rot = rotation
|
||||||
|
rot_var = rotation_var
|
||||||
|
|
||||||
|
src_offset_v = src_offset @ src_offset_mod + uniform_f2_ab(-src_offset_var, src_offset_var) @ src_offset_var_mod
|
||||||
|
dst_offset_v = dst_offset @ dst_offset_mod + uniform_f2_ab(-dst_offset_var, dst_offset_var) @ dst_offset_var_mod
|
||||||
|
|
||||||
|
################
|
||||||
|
|
||||||
|
pattern_direction = out_point - src_point
|
||||||
|
norm_dir = normalize_vec2(pattern_direction)
|
||||||
|
dir_x_axis = rotate_vec2(norm_dir, -0.25, float2(0.0, 0.0))
|
||||||
|
|
||||||
|
direction_dist = distance_vec2(float2(0.0, 0.0), pattern_direction)
|
||||||
|
mapping_scale = 1.0 if offset_absolute_mode else direction_dist
|
||||||
|
|
||||||
|
src_point = src_point + norm_dir @ (src_offset_v.y * mapping_scale)
|
||||||
|
src_point = src_point + dir_x_axis @ (src_offset_v.x * mapping_scale)
|
||||||
|
|
||||||
|
out_point = out_point + norm_dir @ (dst_offset_v.y * mapping_scale)
|
||||||
|
out_point = out_point + dir_x_axis @ (dst_offset_v.x * mapping_scale)
|
||||||
|
|
||||||
|
dst_point = out_point
|
||||||
|
|
||||||
|
pattern_direction = out_point - src_point
|
||||||
|
|
||||||
|
direction_angle = atan2(pattern_direction) / _2pi() + 0.25
|
||||||
|
direction_dist = distance_vec2(float2(0.0, 0.0), pattern_direction)
|
||||||
|
direction_scale = vector2(direction_dist, direction_dist)
|
||||||
|
|
||||||
|
source_offset = norm_dir @ (-pat_offset.y * direction_dist) + dir_x_axis @ (pat_offset.x * direction_dist)
|
||||||
|
pattern_center = src_point + source_offset
|
||||||
|
|
||||||
|
add_rot = rot * rot_mod + uniform_ab(-rot_var, rot_var) * rot_var_mod
|
||||||
|
rot_calc = add_rot + direction_angle if is_orient else add_rot
|
||||||
|
|
||||||
|
# size
|
||||||
|
|
||||||
|
size_var = uniform_f2_ab(-pattern_size_var, pattern_size_var)
|
||||||
|
size_var_u = uniform_ab(-size_uniform_var, size_uniform_var)
|
||||||
|
|
||||||
|
size_var = vector2(size_var_u, size_var_u) if is_size_var_uniform and not is_size_relative else size_var
|
||||||
|
pattern_size = pattern_size if not is_size_var_uniform or is_size_relative else vector2(pattern_size_uniform, pattern_size_uniform)
|
||||||
|
|
||||||
|
size_m = vector2(size_mod, size_mod) if is_size_var_uniform else vector2(size_mod_w, size_mod_h)
|
||||||
|
|
||||||
|
pattern_size_calc = pattern_size * size_m + size_var @ size_var_mod
|
||||||
|
const_width = pattern_size_calc.x
|
||||||
|
|
||||||
|
pattern_size_calc = pattern_size_calc * direction_scale if is_size_relative else pattern_size_calc
|
||||||
|
pattern_size_calc = vector2(const_width, pattern_size_calc.y) if not is_size_var_uniform and is_width_constant else pattern_size_calc
|
||||||
|
|
||||||
|
pivot_pos = pivot_pos * pattern_size_calc
|
||||||
|
pivot_pos = rotate_vec2(pivot_pos, -direction_angle, float2(0.0, 0.0))
|
||||||
|
|
||||||
|
pivot_rot_offset = rotate_vec2(pivot_pos, -add_rot, float2(0.0, 0.0))
|
||||||
|
|
||||||
|
out_point = pattern_center - pivot_rot_offset
|
||||||
|
|
||||||
|
# Color
|
||||||
|
|
||||||
|
:: if grayscale
|
||||||
|
{{ macros.calculate_grayscale(false) }}
|
||||||
|
:: else
|
||||||
|
{{ macros.calculate_color(false, 18) }}
|
||||||
|
:: endif
|
||||||
|
|
||||||
|
# Calculate bridge samples
|
||||||
|
|
||||||
|
{{ macros.get_modifier("samples_mod", "bridge_samples_mod") }}
|
||||||
|
{{ macros.get_modifier("distance_mod", "bridge_distance_mod") }}
|
||||||
|
|
||||||
|
bridge_samples = toint( tofloat(bridge_samples) * samples_mod )
|
||||||
|
bridge_distance = bridge_distance * distance_mod
|
||||||
|
|
||||||
|
samples_by_dist = toint( direction_dist / bridge_distance )
|
||||||
|
bridge_length = tofloat(samples_by_dist) * bridge_distance
|
||||||
|
|
||||||
|
bridge_samples = 1 if bridge_type == 0 else bridge_samples
|
||||||
|
bridge_samples = (samples_by_dist + 1) if bridge_type == 2 else bridge_samples
|
||||||
|
dst_point = (src_point + norm_dir @ bridge_length) if bridge_type == 2 else dst_point
|
||||||
|
|
||||||
|
bridge_samples = 0 if not overshoot and is_resample else bridge_samples
|
||||||
|
bridge_samples = 0 if is_masked else bridge_samples
|
||||||
|
|
||||||
|
bridge_length = length_vec2(dst_point - src_point)
|
||||||
|
|
||||||
|
# Calculate index for bridge
|
||||||
|
|
||||||
|
{{ macros.bridge_index_calculation() }}
|
||||||
|
|
||||||
|
#####
|
||||||
|
|
||||||
|
_OUT_ = bridge_samples
|
||||||
|
|
||||||
|
bridge_samples_calc = bridge_samples
|
||||||
|
|
||||||
|
prev_point = prev_point + point - prev_point
|
||||||
|
total_dist = total_dist + segment_dist
|
||||||
|
|
||||||
|
even_index = -even_index if overshoot and is_resample else even_index
|
||||||
|
even_index = -even_index if not is_resample else even_index
|
||||||
|
|
||||||
|
current_index = current_index + 1 if overshoot and is_resample else current_index
|
||||||
|
current_index = current_index + 1 if not is_resample else current_index
|
||||||
|
|
||||||
|
# Calculate symmetry
|
||||||
|
|
||||||
|
{{ macros.get_modifier("sym_mod", "symmetry_modifier_idx", "1.0") }}
|
||||||
|
{{ macros.symmetry_calculation() }}
|
||||||
|
|
||||||
|
ping_pong_mirror = source_ping_pong and ((n / fiters_src) >= 0.5 )
|
||||||
|
sym_mult = sym_mult * vector2(-1.0, 1.0) if ping_pong_mirror else sym_mult
|
||||||
|
|
||||||
|
:: if not grayscale
|
||||||
|
export(v_intencity)
|
||||||
|
export(v_add_rot)
|
||||||
|
:: endif
|
||||||
|
export(sym_mult)
|
||||||
|
export(bridge_length)
|
||||||
|
export(bridge_index)
|
||||||
|
export(norm_dir)
|
||||||
|
export(dir_x_axis)
|
||||||
|
export(bridge_samples_calc)
|
||||||
|
export(direction_dist)
|
||||||
|
export(out_color)
|
||||||
|
export(source_offset)
|
||||||
|
export(direction_angle)
|
||||||
|
export(add_rot)
|
||||||
|
export(pat_offset)
|
||||||
|
export(pattern_size_calc)
|
||||||
|
export(rot_calc)
|
||||||
|
export(current_index)
|
||||||
|
export(even_index)
|
||||||
|
export(out_point)
|
||||||
|
export(src_point)
|
||||||
|
export(dst_point)
|
||||||
|
export(point)
|
||||||
|
export(prev_point)
|
||||||
|
export(acc_dist)
|
||||||
|
export(angle_dir)
|
||||||
|
export(total_dist)
|
||||||
|
export(norm_iter)
|
||||||
|
export(modifier1)
|
||||||
|
export(modifier2)
|
||||||
|
export(modifier3)
|
||||||
|
export(modifier4)
|
||||||
|
export(modifier5)
|
||||||
|
export(modifier6)
|
||||||
|
export(modifier7)
|
||||||
|
export(modifier8)
|
||||||
@@ -0,0 +1,249 @@
|
|||||||
|
:: import "macros.sex" as macros
|
||||||
|
|
||||||
|
:: if grayscale
|
||||||
|
declare_inputs("curve_polar_splatter")
|
||||||
|
:: else
|
||||||
|
declare_inputs("curve_polar_splatter_color")
|
||||||
|
:: endif
|
||||||
|
|
||||||
|
|
||||||
|
:: for i in range(16)
|
||||||
|
pt{{ i }} = get_float2("pt{{ i }}")
|
||||||
|
spt{{ i }} = get_float2("spt{{ i }}")
|
||||||
|
:: endfor
|
||||||
|
|
||||||
|
current_index = get_int("current_index")
|
||||||
|
even_index = get_int("even_index")
|
||||||
|
alpha = get_float("alpha")
|
||||||
|
tension = get_float("tension")
|
||||||
|
npoints = get_int("npoints")
|
||||||
|
is_closed = get_bool("is_closed")
|
||||||
|
alpha_src = get_float("alpha_src")
|
||||||
|
tension_src = get_float("tension_src")
|
||||||
|
npoints_src = get_int("npoints_src")
|
||||||
|
is_closed_src = get_bool("is_closed_src")
|
||||||
|
|
||||||
|
prev_point = get_float2("prev_point")
|
||||||
|
acc_dist = get_float("acc_dist")
|
||||||
|
total_dist = get_float("total_dist")
|
||||||
|
|
||||||
|
n = get_float("$number")
|
||||||
|
iters = get_int("total_samples")
|
||||||
|
|
||||||
|
bridge_current_distance = get_float("bridge_current_distance")
|
||||||
|
|
||||||
|
|
||||||
|
iters_m1 = iters - 1 if iters > 1 else iters
|
||||||
|
iters_m1 = iters if is_closed and not is_resample else iters_m1
|
||||||
|
fiters = tofloat(iters_m1)
|
||||||
|
|
||||||
|
norm_iter = n / fiters
|
||||||
|
bridge_n = norm_iter
|
||||||
|
norm_iter = (norm_iter * spins) % 1.0
|
||||||
|
norm_iter_src = norm_iter
|
||||||
|
|
||||||
|
frag_size = 1.0 / get_float2("$size").x
|
||||||
|
carved_niter = n / fiters
|
||||||
|
|
||||||
|
|
||||||
|
mod_sample_non_carved = frag_size / 2.0 + norm_iter * (1.0 - frag_size)
|
||||||
|
mod_sample_carved = frag_size / 2.0 + carved_niter * (1.0 - frag_size)
|
||||||
|
|
||||||
|
:: for i in range(1, 9)
|
||||||
|
|
||||||
|
modifier_op = modifier_{{ i }}_addmult
|
||||||
|
|
||||||
|
mod_sample = mod_sample_carved if modifier{{ i }}_carve else mod_sample_non_carved
|
||||||
|
|
||||||
|
modifier{{ i }} = samplelum(vector2(mod_sample, 0.5), {{ i + 9 }}, 0)
|
||||||
|
modifier{{ i }} = modifier{{ i }} * modifier_op.x + modifier_op.y
|
||||||
|
|
||||||
|
:: endfor
|
||||||
|
|
||||||
|
c_sample = {{ macros.sample_curve("norm_iter", "npoints", "is_closed", "alpha", "tension", "pt") }}
|
||||||
|
point = c_sample.xy
|
||||||
|
|
||||||
|
sample_dist = get_float("min_dist")
|
||||||
|
prev_point = point if n < 1.0 else prev_point
|
||||||
|
|
||||||
|
segment_vector = point - prev_point
|
||||||
|
segment_dist = length_vec2(segment_vector)
|
||||||
|
|
||||||
|
segment_dir = normalize_vec2(segment_vector) if segment_dist > 0.0000001 else float2(0.0, 1.0)
|
||||||
|
acc_dist = acc_dist + segment_dist
|
||||||
|
|
||||||
|
overshoot = (acc_dist > sample_dist)
|
||||||
|
overshoot_dist = acc_dist - sample_dist
|
||||||
|
acc_dist = acc_dist if not overshoot else 0.0
|
||||||
|
p_dst = segment_dist - overshoot_dist
|
||||||
|
|
||||||
|
out_point = prev_point + segment_dir @ p_dst if overshoot else float2(0.0, 0.0)
|
||||||
|
out_point = point if n < 1.0 or not is_resample else out_point
|
||||||
|
|
||||||
|
#################################################
|
||||||
|
|
||||||
|
## Calculate src curve
|
||||||
|
|
||||||
|
c_sample = {{ macros.sample_curve("norm_iter_src", "npoints_src", "is_closed_src", "alpha_src", "tension_src", "spt") }}
|
||||||
|
src_point = c_sample.xy
|
||||||
|
src_point = center_pos if center_mode == 1 else src_point
|
||||||
|
|
||||||
|
##############
|
||||||
|
|
||||||
|
:: if grayscale
|
||||||
|
{{ macros.get_modifier("color_mod_m", "color_modifier_idx") }}
|
||||||
|
{{ macros.get_modifier("color_var_mod_m", "color_var_modifier_idx") }}
|
||||||
|
:: endif
|
||||||
|
{{ macros.get_modifier("offset_mod", "offset_modifier_idx") }}
|
||||||
|
{{ macros.get_modifier("offset_var_mod", "offset_var_modifier_idx") }}
|
||||||
|
{{ macros.get_modifier("rot_mod", "rotation_modifier_idx") }}
|
||||||
|
{{ macros.get_modifier("rot_var_mod", "rotation_var_modifier_idx") }}
|
||||||
|
{{ macros.get_modifier("size_mod", "size_modifier_idx") }}
|
||||||
|
{{ macros.get_modifier("size_mod_height", "size_modifier_idx_height") }}
|
||||||
|
{{ macros.get_modifier("size_mod_width", "size_modifier_idx_width") }}
|
||||||
|
{{ macros.get_modifier("size_var_mod", "size_var_modifier_idx") }}
|
||||||
|
{{ macros.get_modifier("src_offset_mod", "src_offset_modifier_idx") }}
|
||||||
|
{{ macros.get_modifier("src_offset_var_mod", "src_offset_var_modifier_idx") }}
|
||||||
|
{{ macros.get_modifier("dst_offset_mod", "dst_offset_modifier_idx") }}
|
||||||
|
{{ macros.get_modifier("dst_offset_var_mod", "dst_offset_var_modifier_idx") }}
|
||||||
|
{{ macros.get_modifier("mask_mod", "mask_modifier_idx") }}
|
||||||
|
|
||||||
|
# pattern offser calculation
|
||||||
|
|
||||||
|
|
||||||
|
offset_rand = uniform_f2_ab(-offset_var, offset_var) @ offset_var_mod
|
||||||
|
pat_offset = pattern_offset @ offset_mod + offset_rand @ offset_var_mod
|
||||||
|
pat_offset = pat_offset * vector2(1.0, -1.0)
|
||||||
|
pat_offset_for_color = pat_offset
|
||||||
|
|
||||||
|
######################
|
||||||
|
|
||||||
|
rot = rotation
|
||||||
|
rot_var = rotation_var
|
||||||
|
|
||||||
|
src_offset_v = src_offset @ src_offset_mod + uniform_f2_ab(-src_offset_var, src_offset_var) @ src_offset_var_mod
|
||||||
|
dst_offset_v = dst_offset @ dst_offset_mod + uniform_f2_ab(-dst_offset_var, dst_offset_var) @ dst_offset_var_mod
|
||||||
|
|
||||||
|
################
|
||||||
|
|
||||||
|
pattern_direction = out_point - src_point
|
||||||
|
norm_dir = normalize_vec2(pattern_direction)
|
||||||
|
dir_x_axis = rotate_vec2(norm_dir, -0.25, float2(0.0, 0.0))
|
||||||
|
|
||||||
|
direction_dist = distance_vec2(float2(0.0, 0.0), pattern_direction)
|
||||||
|
mapping_scale = 1.0 if offset_absolute_mode else direction_dist
|
||||||
|
|
||||||
|
src_point = src_point + norm_dir @ (src_offset_v.y * mapping_scale)
|
||||||
|
src_point = src_point + dir_x_axis @ (src_offset_v.x * mapping_scale)
|
||||||
|
|
||||||
|
out_point = out_point + norm_dir @ (dst_offset_v.y * mapping_scale)
|
||||||
|
out_point = out_point + dir_x_axis @ (dst_offset_v.x * mapping_scale)
|
||||||
|
|
||||||
|
dst_point = out_point
|
||||||
|
|
||||||
|
pattern_direction = out_point - src_point
|
||||||
|
|
||||||
|
direction_angle = atan2(pattern_direction) / _2pi() + 0.25
|
||||||
|
direction_dist = distance_vec2(float2(0.0, 0.0), pattern_direction)
|
||||||
|
|
||||||
|
source_offset = norm_dir @ (-pat_offset.y * direction_dist) + dir_x_axis @ (pat_offset.x * direction_dist)
|
||||||
|
|
||||||
|
add_rot = rot * rot_mod + uniform_ab(-rot_var, rot_var) * rot_var_mod
|
||||||
|
rot_calc = add_rot + direction_angle if is_orient else add_rot
|
||||||
|
|
||||||
|
# pattern size
|
||||||
|
|
||||||
|
size_var = uniform_f2_ab(-pattern_size_var, pattern_size_var)
|
||||||
|
size_var_u = uniform_ab(-size_uniform_var, size_uniform_var)
|
||||||
|
|
||||||
|
size_var = vector2(size_var_u, size_var_u) if is_size_var_uniform else size_var
|
||||||
|
pattern_size = pattern_size if not is_size_var_uniform else vector2(pattern_size_uniform, pattern_size_uniform)
|
||||||
|
|
||||||
|
size_mod_m = vector2(size_mod, size_mod) if is_size_var_uniform else vector2(size_mod_width, size_mod_height)
|
||||||
|
|
||||||
|
pattern_size_calc = pattern_size * size_mod_m + size_var @ size_var_mod
|
||||||
|
|
||||||
|
|
||||||
|
# Color
|
||||||
|
:: if grayscale
|
||||||
|
{{ macros.calculate_grayscale(false) }}
|
||||||
|
:: else
|
||||||
|
{{ macros.calculate_color(false) }}
|
||||||
|
:: endif
|
||||||
|
|
||||||
|
|
||||||
|
prev_point = prev_point + point - prev_point
|
||||||
|
total_dist = total_dist + segment_dist
|
||||||
|
|
||||||
|
## calculate bridge sample
|
||||||
|
|
||||||
|
{{ macros.get_modifier("remap", "bridge_remapping_mod") }}
|
||||||
|
|
||||||
|
bridge_n = remap if bridge_remapping_mod > 0 and bridge_type == 0 else bridge_n
|
||||||
|
bridge_n = bridge_current_distance / direction_dist if bridge_type == 1 else bridge_n
|
||||||
|
|
||||||
|
|
||||||
|
point_calc = lerp(src_point, dst_point, bridge_n) + source_offset
|
||||||
|
|
||||||
|
pivot_pos = pivot_pos * pattern_size_calc
|
||||||
|
pivot_rot_offset = rotate_vec2(pivot_pos, -rot_calc, float2(0.0, 0.0))
|
||||||
|
|
||||||
|
point_calc = point_calc - pivot_rot_offset
|
||||||
|
|
||||||
|
# symmetry
|
||||||
|
|
||||||
|
{{ macros.get_modifier("sym_mod", "symmetry_modifier_idx", "1.0") }}
|
||||||
|
{{ macros.symmetry_calculation() }}
|
||||||
|
|
||||||
|
bridge_pattern_size = pattern_size_calc * sym_mult
|
||||||
|
bridge_pattern_rotation = rot_calc
|
||||||
|
|
||||||
|
col_range = 1.0
|
||||||
|
col_range = 0.0 if bridge_n > 1.0 and bridge_type == 1 else col_range
|
||||||
|
|
||||||
|
_OUT_ = out_color @ col_range
|
||||||
|
|
||||||
|
bridge_current_distance = bridge_current_distance + bridge_distance if not is_resample else bridge_current_distance
|
||||||
|
bridge_current_distance = bridge_current_distance + bridge_distance if overshoot and is_resample else bridge_current_distance
|
||||||
|
|
||||||
|
# Calculate pattern index
|
||||||
|
|
||||||
|
{{ macros.get_modifier("idx_mod", "idx_distr_mod", "0.0") }}
|
||||||
|
|
||||||
|
ping_pong = 2 * inputs_num - 2
|
||||||
|
ping_pong_loop = current_index % ping_pong
|
||||||
|
pattern_ping_pong = ping_pong_loop if ping_pong_loop < inputs_num else ping_pong - ping_pong_loop
|
||||||
|
pattern_ping_pong = 0 if inputs_num == 1 else pattern_ping_pong
|
||||||
|
|
||||||
|
pattern_random = uniform_ab(0.0, tofloat(inputs_num))
|
||||||
|
pattern_random = toint(pattern_random)
|
||||||
|
|
||||||
|
pattern_mod = idx_mod * tofloat(inputs_num)
|
||||||
|
pattern_mod = toint(pattern_mod)
|
||||||
|
pattern_mod = 0 if pattern_mod < 0 else pattern_mod
|
||||||
|
pattern_mod = (inputs_num - 1) if pattern_mod > (inputs_num - 1) else pattern_mod
|
||||||
|
|
||||||
|
pattern_index = pattern_random
|
||||||
|
pattern_index = current_index % inputs_num if pattern_distr_mode == 1 else pattern_index
|
||||||
|
pattern_index = pattern_ping_pong if pattern_distr_mode == 2 else pattern_index
|
||||||
|
pattern_index = pattern_mod if pattern_distr_mode == 3 else pattern_index
|
||||||
|
|
||||||
|
pattern_index = pattern_index + 2
|
||||||
|
|
||||||
|
even_index = -even_index if overshoot and is_resample else even_index
|
||||||
|
even_index = -even_index if not is_resample else even_index
|
||||||
|
|
||||||
|
current_index = current_index + 1 if overshoot and is_resample else current_index
|
||||||
|
current_index = current_index + 1 if not is_resample else current_index
|
||||||
|
|
||||||
|
export(pattern_index)
|
||||||
|
export(bridge_current_distance)
|
||||||
|
export(prev_point)
|
||||||
|
export(acc_dist)
|
||||||
|
export(current_index)
|
||||||
|
export(even_index)
|
||||||
|
export(total_dist)
|
||||||
|
|
||||||
|
export(point_calc)
|
||||||
|
export(bridge_pattern_size)
|
||||||
|
export(bridge_pattern_rotation)
|
||||||
@@ -0,0 +1,175 @@
|
|||||||
|
:: import "macros.sex" as macros
|
||||||
|
|
||||||
|
:: if grayscale
|
||||||
|
declare_inputs("curve_splatter")
|
||||||
|
:: else
|
||||||
|
declare_inputs("curve_splatter_color")
|
||||||
|
:: endif
|
||||||
|
|
||||||
|
:: for i in range(16)
|
||||||
|
pt{{ i }} = get_float2("pt{{ i }}")
|
||||||
|
:: endfor
|
||||||
|
|
||||||
|
current_index = get_int("current_index")
|
||||||
|
even_index = get_int("even_index")
|
||||||
|
prev_point = get_float2("prev_point")
|
||||||
|
acc_dist = get_float("acc_dist")
|
||||||
|
total_dist = get_float("total_dist")
|
||||||
|
n = get_float("$number")
|
||||||
|
iters = get_int("total_samples")
|
||||||
|
is_closed = get_bool("is_closed")
|
||||||
|
npoints = get_int("npoints")
|
||||||
|
alpha = get_float("alpha")
|
||||||
|
tension = get_float("tension")
|
||||||
|
|
||||||
|
iters_m1 = iters - 1 if iters > 1 else iters
|
||||||
|
iters_m1 = iters if is_closed and not is_resample else iters_m1
|
||||||
|
fiters = tofloat(iters_m1)
|
||||||
|
|
||||||
|
norm_iter = carving.x + n / fiters * (carving.y - carving.x)
|
||||||
|
frag_size = 1.0 / get_float2("$size").x
|
||||||
|
carved_niter = n / fiters
|
||||||
|
|
||||||
|
mod_sample_non_carved = frag_size / 2.0 + norm_iter * (1.0 - frag_size)
|
||||||
|
mod_sample_carved = frag_size / 2.0 + carved_niter * (1.0 - frag_size)
|
||||||
|
|
||||||
|
:: for i in range(1, 9)
|
||||||
|
modifier_op = modifier_{{ i }}_addmult
|
||||||
|
mod_sample = mod_sample_carved if modifier{{ i }}_carve else mod_sample_non_carved
|
||||||
|
modifier{{ i }} = samplelum(vector2(mod_sample, 0.5), {{ i + 8 }}, 0)
|
||||||
|
modifier{{ i }} = modifier{{ i }} * modifier_op.x + modifier_op.y
|
||||||
|
:: endfor
|
||||||
|
|
||||||
|
{{ macros.get_modifier("remap", "remapping_mod") }}
|
||||||
|
|
||||||
|
norm_iter = carving.x + remap * (carving.y - carving.x) if remapping_mod > 0 else norm_iter
|
||||||
|
|
||||||
|
c_sample = {{ macros.sample_curve("norm_iter", "npoints", "is_closed", "alpha", "tension", "pt") }}
|
||||||
|
point = c_sample.xy
|
||||||
|
deriative = c_sample.zw
|
||||||
|
orient_angle = atan2(deriative) / _2pi()
|
||||||
|
|
||||||
|
sample_dist = get_float("min_dist")
|
||||||
|
prev_point = point if n < 1.0 else prev_point
|
||||||
|
|
||||||
|
segment_vector = point - prev_point
|
||||||
|
segment_dist = length_vec2(segment_vector)
|
||||||
|
|
||||||
|
segment_dir = normalize_vec2(segment_vector) if segment_dist > 0.0000001 else float2(0.0, 1.0)
|
||||||
|
acc_dist = acc_dist + segment_dist
|
||||||
|
|
||||||
|
overshoot = (acc_dist > sample_dist)
|
||||||
|
overshoot_dist = acc_dist - sample_dist
|
||||||
|
acc_dist = acc_dist if not overshoot else 0.0
|
||||||
|
p_dst = segment_dist - overshoot_dist
|
||||||
|
|
||||||
|
out_point = prev_point + segment_dir @ p_dst if overshoot else float2(0.0, 0.0)
|
||||||
|
out_point = point if n < 1.0 else out_point
|
||||||
|
out_point = point if not is_resample else out_point
|
||||||
|
overshoot = True if n < 1.0 and is_resample else overshoot
|
||||||
|
|
||||||
|
# Get modifiers
|
||||||
|
:: if grayscale
|
||||||
|
{{ macros.get_modifier("color_mod_m", "color_modifier_idx") }}
|
||||||
|
{{ macros.get_modifier("color_var_mod_m", "color_var_modifier_idx") }}
|
||||||
|
:: endif
|
||||||
|
{{ macros.get_modifier("offset_mod", "offset_modifier_idx") }}
|
||||||
|
{{ macros.get_modifier("offset_var_mod", "offset_var_modifier_idx") }}
|
||||||
|
{{ macros.get_modifier("mask_mod", "mask_modifier_idx") }}
|
||||||
|
{{ macros.get_modifier("offset_mod", "offset_modifier_idx") }}
|
||||||
|
{{ macros.get_modifier("rot_mod", "rotation_modifier_idx") }}
|
||||||
|
{{ macros.get_modifier("rot_var_mod", "rotation_var_modifier_idx") }}
|
||||||
|
{{ macros.get_modifier("size_mod", "size_modifier_idx") }}
|
||||||
|
{{ macros.get_modifier("size_var_mod", "size_var_modifier_idx") }}
|
||||||
|
{{ macros.get_modifier("mirror_mod", "mirroring_modifier_idx", "0.0") }}
|
||||||
|
{{ macros.get_modifier("size_mod_w", "size_modifier_idx_width") }}
|
||||||
|
{{ macros.get_modifier("size_mod_h", "size_modifier_idx_height") }}
|
||||||
|
{{ macros.get_modifier("sym_mod", "symmetry_modifier_idx", "1.0") }}
|
||||||
|
|
||||||
|
# pattern rotation calculation
|
||||||
|
|
||||||
|
rot = rotation * rot_mod + uniform_ab(-rotation_var, rotation_var) * rot_var_mod
|
||||||
|
|
||||||
|
rot_calc = rot if not is_orient else orient_angle + rot + 0.25
|
||||||
|
mirror_chance = uniform_ab(0.0, 1.0) < 0.5
|
||||||
|
|
||||||
|
need_mirror = (mirroring == 1 and (is_orient and mirror_chance)) or (mirroring == 2 and (is_orient and even_index > 0))
|
||||||
|
need_mirror = need_mirror or (mirroring == 3 and (is_orient and mirror_mod > 0.5))
|
||||||
|
|
||||||
|
rot_calc = orient_angle - rot - 0.25 if need_mirror else rot_calc
|
||||||
|
|
||||||
|
# pattern size calculation
|
||||||
|
|
||||||
|
size_var = uniform_f2_ab(-pattern_size_var, pattern_size_var)
|
||||||
|
size_var_u = uniform_ab(-size_uniform_var, size_uniform_var)
|
||||||
|
|
||||||
|
size_var = size_var if not is_size_var_uniform else vector2(size_var_u, size_var_u)
|
||||||
|
pattern_size = pattern_size if not is_size_var_uniform else vector2(pattern_size_uniform, pattern_size_uniform)
|
||||||
|
|
||||||
|
size_m = vector2(size_mod, size_mod) if is_size_var_uniform else vector2(size_mod_w, size_mod_h)
|
||||||
|
pattern_size_calc = pattern_size * size_m + size_var @ size_var_mod
|
||||||
|
|
||||||
|
# symmetry
|
||||||
|
|
||||||
|
{{ macros.symmetry_calculation() }}
|
||||||
|
|
||||||
|
# pattern offset calculation
|
||||||
|
|
||||||
|
offset_rand = uniform_f2_ab(-offset_var, offset_var) @ offset_var_mod
|
||||||
|
pat_offset = pattern_offset @ offset_mod + offset_rand @ offset_var_mod
|
||||||
|
|
||||||
|
pat_offset_for_color = pat_offset
|
||||||
|
|
||||||
|
pat_offset = pat_offset * vector2(1.0, -1.0)
|
||||||
|
coord_angle = rot_calc if not offset_space_curve else orient_angle
|
||||||
|
|
||||||
|
local_up = rotate_vec2(vector2(0.0, 1.0), -coord_angle, float2(0.0, 0.0))
|
||||||
|
local_right = rotate_vec2(vector2(0.0, 1.0), -coord_angle-0.25, float2(0.0, 0.0))
|
||||||
|
|
||||||
|
pattern_size_calc = pattern_size_calc * vector2(1.0, -1.0) if need_mirror else pattern_size_calc
|
||||||
|
pat_offset = pat_offset if offset_absolute_mode else pat_offset * pattern_size_calc
|
||||||
|
|
||||||
|
out_point = out_point + local_up @ (pat_offset.y) + local_right @ (pat_offset.x)
|
||||||
|
|
||||||
|
local_up = rotate_vec2(vector2(0.0, 1.0), -rot_calc, float2(0.0, 0.0))
|
||||||
|
local_right = rotate_vec2(vector2(0.0, 1.0), -rot_calc-0.25, float2(0.0, 0.0))
|
||||||
|
|
||||||
|
pivot_pos = pivot_pos * pattern_size_calc
|
||||||
|
out_point = out_point + local_up @ (-pivot_pos.y) + local_right @ (pivot_pos.x)
|
||||||
|
|
||||||
|
# Color calculation
|
||||||
|
|
||||||
|
:: if grayscale
|
||||||
|
{{ macros.calculate_grayscale() }}
|
||||||
|
:: else
|
||||||
|
{{ macros.calculate_color() }}
|
||||||
|
:: endif
|
||||||
|
|
||||||
|
prev_point = prev_point + point - prev_point
|
||||||
|
total_dist = total_dist + segment_dist
|
||||||
|
|
||||||
|
even_index = -even_index if overshoot and is_resample else even_index
|
||||||
|
even_index = -even_index if not is_resample else even_index
|
||||||
|
|
||||||
|
current_index = current_index + 1 if overshoot and is_resample else current_index
|
||||||
|
current_index = current_index + 1 if not is_resample else current_index
|
||||||
|
|
||||||
|
pattern_size_calc = pattern_size_calc * sym_mult
|
||||||
|
|
||||||
|
export(current_index)
|
||||||
|
export(even_index)
|
||||||
|
export(out_point)
|
||||||
|
export(prev_point)
|
||||||
|
export(acc_dist)
|
||||||
|
export(total_dist)
|
||||||
|
export(norm_iter)
|
||||||
|
export(modifier1)
|
||||||
|
export(modifier2)
|
||||||
|
export(modifier3)
|
||||||
|
export(modifier4)
|
||||||
|
export(modifier5)
|
||||||
|
export(modifier6)
|
||||||
|
export(modifier7)
|
||||||
|
export(modifier8)
|
||||||
|
export(rot_calc)
|
||||||
|
export(pattern_size_calc)
|
||||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,244 @@
|
|||||||
|
#################################################################################################
|
||||||
|
|
||||||
|
:: macro sample_curve(factor, npoints, is_closed, alpha, tension, point_prefix, start_index = 0):
|
||||||
|
catmull_rom_16({{ factor }},
|
||||||
|
{{ npoints }},
|
||||||
|
{{ is_closed }},
|
||||||
|
{{ alpha }},
|
||||||
|
{{ tension }},
|
||||||
|
:: for p_i in range(start_index, start_index + 16):
|
||||||
|
{{ point_prefix }}{{ p_i }},
|
||||||
|
:: endfor
|
||||||
|
)
|
||||||
|
:: endmacro
|
||||||
|
|
||||||
|
#################################################################################################
|
||||||
|
|
||||||
|
:: macro get_modifier(modifier_var, modifier_index, def_value = "1.0")
|
||||||
|
{{ modifier_var }} = switch_float1_8_inputs(
|
||||||
|
{{ modifier_index }} - 1,
|
||||||
|
modifier1,
|
||||||
|
modifier2,
|
||||||
|
modifier3,
|
||||||
|
modifier4,
|
||||||
|
modifier5,
|
||||||
|
modifier6,
|
||||||
|
modifier7,
|
||||||
|
modifier8
|
||||||
|
)
|
||||||
|
{{ modifier_var }} = {{ def_value }} if {{ modifier_index }} < 1 else {{ modifier_var }}
|
||||||
|
:: endmacro
|
||||||
|
|
||||||
|
#################################################################################################
|
||||||
|
|
||||||
|
:: macro get_bridge_modifier(modifier_var, modifier_index, def_value = "1.0")
|
||||||
|
{{ modifier_var }} = switch_float1_8_inputs(
|
||||||
|
{{ modifier_index }} - 1,
|
||||||
|
bridge_modifier1,
|
||||||
|
bridge_modifier2,
|
||||||
|
bridge_modifier3,
|
||||||
|
bridge_modifier4,
|
||||||
|
bridge_modifier5,
|
||||||
|
bridge_modifier6,
|
||||||
|
bridge_modifier7,
|
||||||
|
bridge_modifier8
|
||||||
|
)
|
||||||
|
{{ modifier_var }} = {{ def_value }} if {{ modifier_index }} < 1 else {{ modifier_var }}
|
||||||
|
:: endmacro
|
||||||
|
|
||||||
|
#################################################################################################
|
||||||
|
|
||||||
|
## Masking macro
|
||||||
|
:: macro masking()
|
||||||
|
rnd01 = uniform_ab(0.0, 1.0)
|
||||||
|
mask_total = (1.0 - mask_random) * mask_mod
|
||||||
|
is_masked = rnd01 > mask_total
|
||||||
|
is_masked = (not is_masked) if mask_inverted else is_masked
|
||||||
|
out_alpha = 0.0 if is_masked else out_alpha
|
||||||
|
:: endmacro
|
||||||
|
|
||||||
|
#################################################################################################
|
||||||
|
|
||||||
|
:: macro symmetry_calculation(sym_var_name="sym_mult")
|
||||||
|
rnd01 = uniform_ab(0.0, 1.0)
|
||||||
|
mask_total = (1.0 - symmetry_random * sym_mod )
|
||||||
|
is_sym = rnd01 > mask_total
|
||||||
|
|
||||||
|
h_sym = 1.0
|
||||||
|
h_sym = -1.0 if is_sym and uniform_ab(0.0, 1.0) < 0.5 else h_sym
|
||||||
|
v_sym = 1.0
|
||||||
|
v_sym = -1.0 if is_sym and uniform_ab(0.0, 1.0) < 0.5 else v_sym
|
||||||
|
h_sym = 1.0 if symmetry_mode == 2 else h_sym
|
||||||
|
v_sym = 1.0 if symmetry_mode == 1 else v_sym
|
||||||
|
{{ sym_var_name }} = vector2(h_sym, v_sym)
|
||||||
|
:: endmacro
|
||||||
|
|
||||||
|
#################################################################################################
|
||||||
|
|
||||||
|
:: macro bridge_index_calculation()
|
||||||
|
{{ get_modifier("idx_mod", "idx_distr_mod") }}
|
||||||
|
|
||||||
|
bridge_index = uniform_ab(0.0, tofloat(inputs_num))
|
||||||
|
bridge_index = toint(bridge_index)
|
||||||
|
|
||||||
|
ping_pong = 2 * inputs_num - 2
|
||||||
|
ping_pong_loop = current_index % ping_pong
|
||||||
|
pattern_ping_pong = ping_pong_loop if ping_pong_loop < inputs_num else ping_pong - ping_pong_loop
|
||||||
|
pattern_ping_pong = 0 if inputs_num == 1 else pattern_ping_pong
|
||||||
|
|
||||||
|
pattern_mod = idx_mod * tofloat(inputs_num)
|
||||||
|
pattern_mod = toint(pattern_mod)
|
||||||
|
pattern_mod = 0 if pattern_mod < 0 else pattern_mod
|
||||||
|
pattern_mod = (inputs_num - 1) if pattern_mod > (inputs_num - 1) else pattern_mod
|
||||||
|
|
||||||
|
bridge_index = current_index % inputs_num if pattern_distr_mode == 1 else bridge_index
|
||||||
|
bridge_index = pattern_ping_pong if pattern_distr_mode == 2 else bridge_index
|
||||||
|
bridge_index = pattern_mod if pattern_distr_mode == 3 else bridge_index
|
||||||
|
:: endmacro
|
||||||
|
|
||||||
|
#################################################################################################
|
||||||
|
|
||||||
|
:: macro masking_and_fade_by_dist(include_overshoot_masking=true)
|
||||||
|
:: if include_overshoot_masking
|
||||||
|
out_alpha = 0.0 if not overshoot else alpha_calc
|
||||||
|
out_alpha = alpha_calc if n < 1.0 else out_alpha
|
||||||
|
out_alpha = alpha_calc if not is_resample else out_alpha
|
||||||
|
:: endif
|
||||||
|
|
||||||
|
offset_distance = distance_vec2(float2(0.0, 0.0), pat_offset_for_color)
|
||||||
|
distance_factor = offset_distance / fade_distance
|
||||||
|
out_alpha = lerp(out_alpha, 0.0, distance_factor) if fade_by_dist else out_alpha
|
||||||
|
{{ masking() }}
|
||||||
|
:: endmacro
|
||||||
|
|
||||||
|
#################################################################################################
|
||||||
|
|
||||||
|
# grayscale macro
|
||||||
|
:: macro calculate_grayscale(set_output=true):
|
||||||
|
alpha_base = pattern_color * color_mod_m
|
||||||
|
alpha_var = alpha_base - pattern_color_var * color_var_mod_m * alpha_base
|
||||||
|
alpha_calc = uniform_ab(alpha_var, alpha_base)
|
||||||
|
|
||||||
|
{{ masking_and_fade_by_dist() }}
|
||||||
|
|
||||||
|
out_color = merge_float4(out_alpha, out_alpha, out_alpha, out_alpha)
|
||||||
|
:: if set_output
|
||||||
|
_OUT_ = out_color
|
||||||
|
:: endif
|
||||||
|
:: endmacro
|
||||||
|
|
||||||
|
#################################################################################################
|
||||||
|
|
||||||
|
# color macro
|
||||||
|
:: macro calculate_color(set_output=true, color_modifier_index=17):
|
||||||
|
{{ get_modifier("hue_mod", "hue_var_modifier_idx") }}
|
||||||
|
{{ get_modifier("sat_mod", "sat_var_modifier_idx") }}
|
||||||
|
{{ get_modifier("lum_mod", "lum_var_modifier_idx") }}
|
||||||
|
{{ get_modifier("opa_mod", "opa_var_modifier_idx") }}
|
||||||
|
|
||||||
|
{{ get_modifier("intencity_mod", "vmap_intencity_mod") }}
|
||||||
|
{{ get_modifier("intencity_var_mod", "vmap_intencity_var_mod") }}
|
||||||
|
{{ get_modifier("add_rot_mod", "vmap_add_rot_mod") }}
|
||||||
|
{{ get_modifier("add_rot_var_mod", "vmap_add_rot_var_mod") }}
|
||||||
|
|
||||||
|
v_intencity = vmap_intencity * intencity_mod + uniform_ab(-vmap_intencity_var, vmap_intencity_var) * intencity_var_mod
|
||||||
|
v_add_rot = vmap_add_rot * add_rot_mod + uniform_ab(-vmap_add_rot_var, vmap_add_rot_var) * add_rot_var_mod
|
||||||
|
|
||||||
|
color_mod_sample = mod_sample_carved if color_modifier_carve else mod_sample
|
||||||
|
color_modifier = samplecol(vector2(color_mod_sample, 0.5), {{ color_modifier_index }}, 0)
|
||||||
|
|
||||||
|
hsl_mod = merge_float3(hue_mod, sat_mod, lum_mod)
|
||||||
|
pat_color = pattern_color * color_modifier if use_color_modifier else pattern_color
|
||||||
|
|
||||||
|
pat_color_hsl = rgbtohsv(pat_color.xyz)
|
||||||
|
pat_color_hsl_var = pattern_color_var.xyz * hsl_mod
|
||||||
|
|
||||||
|
pat_color_base = pat_color_hsl - pat_color_hsl_var * pat_color_hsl
|
||||||
|
pat_hsl_result = uniform_f3_ab(pat_color_base, pat_color_hsl)
|
||||||
|
pat_rgb_result = hsvtorgb(pat_hsl_result)
|
||||||
|
|
||||||
|
alpha_base = pat_color.w
|
||||||
|
alpha_var = alpha_base - pattern_color_var.w * opa_mod * alpha_base
|
||||||
|
alpha_calc = uniform_ab(alpha_var, alpha_base)
|
||||||
|
|
||||||
|
alpha_calc = v_intencity if color_mode == 1 else alpha_calc
|
||||||
|
|
||||||
|
{{ masking_and_fade_by_dist() }}
|
||||||
|
|
||||||
|
up_dir = vector2(0.0, -1.0)
|
||||||
|
up_dir = rotate_vec2(up_dir, -rot_calc - v_add_rot , float2(0.0, 0.0)) @ 0.5 + float2(0.5, 0.5)
|
||||||
|
pat_rgb_result = merge_float3(up_dir.x, up_dir.y, 0.0) if color_mode == 1 else pat_rgb_result
|
||||||
|
|
||||||
|
out_color = merge_float4(pat_rgb_result.x, pat_rgb_result.y, pat_rgb_result.z, out_alpha)
|
||||||
|
|
||||||
|
:: if set_output
|
||||||
|
_OUT_ = out_color
|
||||||
|
:: endif
|
||||||
|
:: endmacro
|
||||||
|
|
||||||
|
#################################################################################################
|
||||||
|
|
||||||
|
# grayscale macro for bridges
|
||||||
|
:: macro calculate_bridge_grayscale():
|
||||||
|
pat_offset_for_color = b_offs
|
||||||
|
out_alpha = out_color.x
|
||||||
|
{{ masking_and_fade_by_dist(false) }}
|
||||||
|
|
||||||
|
col_range = col_mod * uniform_ab(1.0-col_var_mod * bridge_color_var, 1.0)
|
||||||
|
out_color = out_color @ (col_range * out_alpha)
|
||||||
|
|
||||||
|
_OUT_ = out_color
|
||||||
|
:: endmacro
|
||||||
|
|
||||||
|
#################################################################################################
|
||||||
|
|
||||||
|
# color macro for bridges
|
||||||
|
:: macro calculate_bridge_color(color_modifier_index=19):
|
||||||
|
pat_offset_for_color = b_offs
|
||||||
|
{{ get_bridge_modifier("hue_mod", "bridge_hue_var_mod") }}
|
||||||
|
{{ get_bridge_modifier("sat_mod", "bridge_sat_var_mod") }}
|
||||||
|
{{ get_bridge_modifier("lum_mod", "bridge_lum_var_mod") }}
|
||||||
|
{{ get_bridge_modifier("opa_mod", "bridge_opa_var_mod") }}
|
||||||
|
|
||||||
|
{{ get_bridge_modifier("intencity_mod", "bridge_vm_intencity_mod") }}
|
||||||
|
{{ get_bridge_modifier("intencity_var_mod", "bridge_vm_intencity_var_mod") }}
|
||||||
|
{{ get_bridge_modifier("add_rot_mod", "bridge_vm_add_rot_mod") }}
|
||||||
|
{{ get_bridge_modifier("add_rot_var_mod", "bridge_vm_add_rot_var_mod") }}
|
||||||
|
|
||||||
|
color_modifier = samplecol(vector2(mod_sample, 0.5), {{ color_modifier_index }}, 0)
|
||||||
|
|
||||||
|
v_intencity = get_float("v_intencity")
|
||||||
|
v_add_rot = get_float("v_add_rot")
|
||||||
|
|
||||||
|
b_v_intencity = v_intencity * intencity_mod + uniform_ab(-bridge_vm_intencity_var, bridge_vm_intencity_var) * intencity_var_mod
|
||||||
|
b_v_add_rot = v_add_rot + add_rot_mod + uniform_ab(-bridge_vm_add_rot_var, bridge_vm_add_rot_var) * add_rot_var_mod
|
||||||
|
|
||||||
|
hsl_mod = merge_float3(hue_mod, sat_mod, lum_mod)
|
||||||
|
pat_color = out_color * color_modifier if bridge_use_color_mod else out_color
|
||||||
|
|
||||||
|
pat_color_hsl = rgbtohsv(pat_color.xyz)
|
||||||
|
pat_color_hsl_var = bridge_color_var.xyz * hsl_mod
|
||||||
|
|
||||||
|
pat_color_base = pat_color_hsl - pat_color_hsl_var * pat_color_hsl
|
||||||
|
pat_hsl_result = uniform_f3_ab(pat_color_base, pat_color_hsl)
|
||||||
|
pat_rgb_result = hsvtorgb(pat_hsl_result)
|
||||||
|
|
||||||
|
alpha_base = pat_color.w
|
||||||
|
alpha_var = alpha_base - bridge_color_var.w * opa_mod * alpha_base
|
||||||
|
alpha_calc = uniform_ab(alpha_var, alpha_base)
|
||||||
|
|
||||||
|
out_alpha = alpha_calc if color_mode == 0 else b_v_intencity
|
||||||
|
|
||||||
|
{{ masking_and_fade_by_dist(false) }}
|
||||||
|
|
||||||
|
up_dir = vector2(0.0, -1.0)
|
||||||
|
up_dir = rotate_vec2(up_dir, -rot_calc - b_v_add_rot , float2(0.0, 0.0)) @ 0.5 + float2(0.5, 0.5)
|
||||||
|
pat_rgb_result = merge_float3(up_dir.x, up_dir.y, 0.0) if color_mode == 1 else pat_rgb_result
|
||||||
|
|
||||||
|
out_color = merge_float4(pat_rgb_result.x, pat_rgb_result.y, pat_rgb_result.z, out_alpha)
|
||||||
|
|
||||||
|
_OUT_ = out_color
|
||||||
|
|
||||||
|
:: endmacro
|
||||||
|
|
||||||
|
#################################################################################################
|
||||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,86 @@
|
|||||||
|
#############################################################################################
|
||||||
|
:: macro init_parameter_random(param_name, input_offset, additive = false, no_export = false)
|
||||||
|
|
||||||
|
p_{{ param_name }} = uniform_ab({{ param_name }} - {{ param_name }} * {{ param_name }}_random, {{ param_name }})
|
||||||
|
|
||||||
|
:: if input_offset > -1
|
||||||
|
|
||||||
|
map_sample = samplelum(p_position, {{ input_offset }}, 1)
|
||||||
|
:: if not additive
|
||||||
|
p_{{ param_name }} = p_{{ param_name }} * map_sample if use_{{ param_name }}_map and not dynamic_{{ param_name }}_map else p_{{ param_name }}
|
||||||
|
:: else
|
||||||
|
p_{{ param_name }} = p_{{ param_name }} + map_sample if use_{{ param_name }}_map and not dynamic_{{ param_name }}_map else p_{{ param_name }}
|
||||||
|
::endif
|
||||||
|
|
||||||
|
:: if not no_export
|
||||||
|
export(p_{{ param_name }})
|
||||||
|
:: endif
|
||||||
|
|
||||||
|
:: endif
|
||||||
|
|
||||||
|
:: endmacro
|
||||||
|
|
||||||
|
#############################################################################################
|
||||||
|
:: macro init_parameter_var(param_name, input_offset, additive = false, no_export = false)
|
||||||
|
p_{{ param_name }} = uniform_ab({{ param_name }} - {{ param_name }}_var, {{ param_name }} + {{ param_name }}_var)
|
||||||
|
|
||||||
|
:: if input_offset > -1
|
||||||
|
|
||||||
|
map_sample = samplelum(p_position, {{ input_offset }}, 1)
|
||||||
|
:: if not additive
|
||||||
|
p_{{ param_name }} = p_{{ param_name }} * map_sample if use_{{ param_name }}_map and not dynamic_{{ param_name }}_map else p_{{ param_name }}
|
||||||
|
:: else
|
||||||
|
p_{{ param_name }} = p_{{ param_name }} + map_sample if use_{{ param_name }}_map and not dynamic_{{ param_name }}_map else p_{{ param_name }}
|
||||||
|
::endif
|
||||||
|
|
||||||
|
:: if not no_export
|
||||||
|
export(p_{{ param_name }})
|
||||||
|
:: endif
|
||||||
|
|
||||||
|
:: endif
|
||||||
|
|
||||||
|
:: endmacro
|
||||||
|
|
||||||
|
#############################################################################################
|
||||||
|
:: macro calculate_modifier_sample()
|
||||||
|
outp_size = get_float2("$size")
|
||||||
|
frag_size = 1.0 / outp_size.x
|
||||||
|
modifier_sample = vector2(frag_size / 2.0 + norm_life * (1.0 - frag_size), 0.5)
|
||||||
|
glob_lifetime = get_int("lifetime")
|
||||||
|
glob_life = n / (tofloat(glob_lifetime) - 1.0) if glob_lifetime > 1 else 0.0
|
||||||
|
modifier_sample_global = vector2(frag_size / 2.0 + glob_life * (1.0 - frag_size), 0.5)
|
||||||
|
:: endmacro
|
||||||
|
|
||||||
|
#############################################################################################
|
||||||
|
:: macro apply_modifiers(param_name, input_offset, additive = false)
|
||||||
|
|
||||||
|
param_mod_sample = modifier_sample_global if {{ param_name }}_modifier_mode else modifier_sample
|
||||||
|
modifier = samplelum(param_mod_sample, {{ 16 + input_offset }}, 0)
|
||||||
|
|
||||||
|
:: if not additive
|
||||||
|
p_{{ param_name }} = p_{{ param_name }} * modifier if use_{{ param_name }}_modifier else p_{{ param_name }}
|
||||||
|
:: else
|
||||||
|
p_{{ param_name }} = p_{{ param_name }} + modifier if use_{{ param_name }}_modifier else p_{{ param_name }}
|
||||||
|
:: endif
|
||||||
|
|
||||||
|
map_sample = samplelum(p_position, {{ 9 + input_offset }}, 1)
|
||||||
|
:: if not additive
|
||||||
|
p_{{ param_name }} = p_{{ param_name }} * map_sample if use_{{ param_name }}_map and dynamic_{{ param_name }}_map else p_{{ param_name }}
|
||||||
|
:: else
|
||||||
|
p_{{ param_name }} = p_{{ param_name }} + map_sample if use_{{ param_name }}_map and dynamic_{{ param_name }}_map else p_{{ param_name }}
|
||||||
|
:: endif
|
||||||
|
|
||||||
|
:: endmacro
|
||||||
|
|
||||||
|
#############################################################################################
|
||||||
|
:: macro sample_curve(factor, npoints, is_closed, alpha, tension, point_prefix, start_index = 0):
|
||||||
|
catmull_rom_16({{ factor }},
|
||||||
|
{{ npoints }},
|
||||||
|
{{ is_closed }},
|
||||||
|
{{ alpha }},
|
||||||
|
{{ tension }},
|
||||||
|
:: for p_i in range(start_index, start_index + 16):
|
||||||
|
{{ point_prefix }}{{ p_i }},
|
||||||
|
:: endfor
|
||||||
|
)
|
||||||
|
:: endmacro
|
||||||
@@ -0,0 +1,71 @@
|
|||||||
|
:: macro init_pcloud(cloud_name)
|
||||||
|
{{ cloud_name }}_meta = get_float3("#{{ cloud_name }}_meta")
|
||||||
|
|
||||||
|
{{ cloud_name }}_frag_size = float2(1.0, 1.0) / {{ cloud_name }}_meta.yz
|
||||||
|
{{ cloud_name }}_size_half = {{ cloud_name }}_frag_size / float2(2.0, 2.0)
|
||||||
|
:: endmacro
|
||||||
|
|
||||||
|
:: macro get_pcloud_point(cloud_name, sample_idx, sample_name, cloud_input = 0)
|
||||||
|
row = ({{ sample_idx }} * 2) / toint({{ cloud_name }}_meta.y)
|
||||||
|
column = ({{ sample_idx }} * 2) % toint({{ cloud_name }}_meta.y)
|
||||||
|
|
||||||
|
rc = vector2(tofloat(column), tofloat(row))
|
||||||
|
sample_uv = {{ cloud_name }}_size_half + rc * {{ cloud_name }}_frag_size
|
||||||
|
|
||||||
|
{{ sample_name }} = samplecol(sample_uv, {{ cloud_input }}, 0)
|
||||||
|
{{ sample_name }}_attrib = samplecol(sample_uv + vector2({{ cloud_name }}_frag_size.x, 0.0), {{ cloud_input }}, 0)
|
||||||
|
:: endmacro
|
||||||
|
|
||||||
|
:: macro get_pcloud_point_noattr(cloud_name, sample_idx, sample_name, cloud_input = 0)
|
||||||
|
row = ({{ sample_idx }} * 2) / toint({{ cloud_name }}_meta.y)
|
||||||
|
column = ({{ sample_idx }} * 2) % toint({{ cloud_name }}_meta.y)
|
||||||
|
|
||||||
|
rc = vector2(tofloat(column), tofloat(row))
|
||||||
|
sample_uv = {{ cloud_name }}_size_half + rc * {{ cloud_name }}_frag_size
|
||||||
|
|
||||||
|
{{ sample_name }} = samplecol(sample_uv, {{ cloud_input }}, 0)
|
||||||
|
:: endmacro
|
||||||
|
|
||||||
|
:: macro pcloud_index_uv(uv_name, cloud_name, index)
|
||||||
|
|
||||||
|
pc_row = ({{ index }} * 2) / toint({{ cloud_name }}_meta.y)
|
||||||
|
pc_column = ({{ index }} * 2) % toint({{ cloud_name }}_meta.y)
|
||||||
|
pc_rc = vector2(tofloat(pc_column), tofloat(pc_row))
|
||||||
|
f2_one = float2(1.0, 1.0)
|
||||||
|
|
||||||
|
{{ uv_name }} = {{ cloud_name }}_size_half + pc_rc / ( {{ cloud_name }}_meta.yz - f2_one ) * (f2_one - {{ cloud_name }}_frag_size )
|
||||||
|
|
||||||
|
:: endmacro
|
||||||
|
|
||||||
|
:: macro pp_init()
|
||||||
|
size = get_float2("$size")
|
||||||
|
pos = get_float2("$pos")
|
||||||
|
frag_size = float2(1.0, 1.0) / size
|
||||||
|
frag_size_half = frag_size / float2(2.0, 2.0)
|
||||||
|
pixel_coord = size * (pos - frag_size_half)
|
||||||
|
pixel_index = pixel_coord.y * size.x + pixel_coord.x
|
||||||
|
pixel_index = toint(pixel_index)
|
||||||
|
is_attrib = pixel_index % 2 > 0
|
||||||
|
|
||||||
|
sample = samplecol(pos, 0, 0)
|
||||||
|
attr_offset = vector2(-frag_size.x, 0.0) if is_attrib else vector2(frag_size.x, 0.0)
|
||||||
|
neigh_sample = samplecol(pos + attr_offset, 0, 0)
|
||||||
|
|
||||||
|
point = neigh_sample if is_attrib else sample
|
||||||
|
point_attrib = sample if is_attrib else neigh_sample
|
||||||
|
:: endmacro
|
||||||
|
|
||||||
|
:: macro sample_curve(factor, npoints, is_closed, alpha, tension, point_prefix, start_index = 0):
|
||||||
|
catmull_rom_16({{ factor }},
|
||||||
|
{{ npoints }},
|
||||||
|
{{ is_closed }},
|
||||||
|
{{ alpha }},
|
||||||
|
{{ tension }},
|
||||||
|
:: for p_i in range(start_index, start_index + 16):
|
||||||
|
{{ point_prefix }}{{ p_i }},
|
||||||
|
:: endfor
|
||||||
|
)
|
||||||
|
:: endmacro
|
||||||
|
|
||||||
|
:: set attrib_map = {1:"point.z", 2:"point_attrib.x", 3:"point_attrib.y", 4:"point_attrib.z"}
|
||||||
|
:: set tile_offset = ["0.0, 0.0", "0.0, -1.0", "0.0, 1.0", "-1.0, 0.0", "1.0, 0.0", "1.0, -1.0", "1.0, 1.0", "-1.0, -1.0", "-1.0, 1.0"]
|
||||||
@@ -0,0 +1,102 @@
|
|||||||
|
:: import "particle_system.sex" as ps
|
||||||
|
:: import "point_cloud.sex" as pc
|
||||||
|
|
||||||
|
declare_inputs("particle_system")
|
||||||
|
|
||||||
|
{{ pc.init_pcloud("pcloud") }}
|
||||||
|
|
||||||
|
lifetime_rand = tofloat(lifetime) * (1.0 - lifetime_random)
|
||||||
|
p_lifetime = toint(uniform_ab(lifetime_rand, tofloat(lifetime)))
|
||||||
|
stop_simulation = 0
|
||||||
|
|
||||||
|
# calculate start position
|
||||||
|
|
||||||
|
emitter_direction = 0.0
|
||||||
|
p_position = start_position
|
||||||
|
|
||||||
|
# calculate line position
|
||||||
|
|
||||||
|
line_vec = end_position - start_position
|
||||||
|
line_pos = start_position + line_vec @ uniform_ab(0.0, 1.0)
|
||||||
|
line_direction = atan2(line_vec) / _2pi()
|
||||||
|
|
||||||
|
# calculate circle position
|
||||||
|
|
||||||
|
circle_rad = uniform_ab(emitter_radius.x, emitter_radius.y)
|
||||||
|
circle_arc = uniform_ab(emitter_arc.x, emitter_arc.y)
|
||||||
|
|
||||||
|
circle_vec = vector2(-circle_rad, 0.0)
|
||||||
|
circle_vec = rotate_vec2(circle_vec, -circle_arc, float2(0.0, 0.0))
|
||||||
|
|
||||||
|
circle_pos = start_position + circle_vec
|
||||||
|
circle_direction = circle_arc
|
||||||
|
|
||||||
|
# sample point cloud
|
||||||
|
|
||||||
|
sample_idx = toint(uniform_ab(0.0, pcloud_meta.x ))
|
||||||
|
sample_idx = toint(get_float("$number")) if emitter_type == 3 and pcloud_random else sample_idx
|
||||||
|
|
||||||
|
{{ pc.get_pcloud_point("pcloud", "sample_idx", "point", 23) }}
|
||||||
|
|
||||||
|
cloud_direction = point.z
|
||||||
|
|
||||||
|
# set start position
|
||||||
|
|
||||||
|
p_position = line_pos if emitter_type == 1 else p_position
|
||||||
|
p_position = circle_pos if emitter_type == 2 else p_position
|
||||||
|
p_position = point.xy if emitter_type == 3 else p_position
|
||||||
|
|
||||||
|
emitter_direction = line_direction if emitter_type == 1 else emitter_direction
|
||||||
|
emitter_direction = circle_direction if emitter_type == 2 else emitter_direction
|
||||||
|
emitter_direction = cloud_direction if emitter_type == 3 else emitter_direction
|
||||||
|
|
||||||
|
# offset start position by random offset
|
||||||
|
unit_rand = rotate_vec2(float2(1.0, 0.0), uniform_ab(0.0, 1.0), float2(0.0, 0.0))
|
||||||
|
pos_offset = uniform_ab(0.0, offset_random)
|
||||||
|
p_position = p_position + unit_rand @ pos_offset
|
||||||
|
|
||||||
|
# inititalize parameters
|
||||||
|
{{ ps.init_parameter_random("mass", 0, false, true) }}
|
||||||
|
{{ ps.init_parameter_random("drag", 1, false, true) }}
|
||||||
|
{{ ps.init_parameter_random("color", 2, false, true) }}
|
||||||
|
{{ ps.init_parameter_var("ang_velocity", 3) }}
|
||||||
|
{{ ps.init_parameter_random("size", 4, false, true) }}
|
||||||
|
{{ ps.init_parameter_var("orientation", 5, true) }}
|
||||||
|
{{ ps.init_parameter_random("masking", 6) }}
|
||||||
|
|
||||||
|
{{ ps.init_parameter_var("direction_angle", -1, false, true) }}
|
||||||
|
{{ ps.init_parameter_random("velocity", -1, false, true) }}
|
||||||
|
|
||||||
|
|
||||||
|
p_direction_angle = p_direction_angle + emitter_direction if inherit_direction else p_direction_angle
|
||||||
|
p_color = p_color * point_attrib.y if emitter_type == 3 else p_color
|
||||||
|
p_size = p_size * point_attrib.x if emitter_type == 3 else p_size
|
||||||
|
|
||||||
|
p_mass = p_mass * p_size if mass_mult == 1 else p_mass
|
||||||
|
p_mass = p_mass * p_size * p_size if mass_mult == 1 else p_mass
|
||||||
|
|
||||||
|
p_drag = p_drag * p_size if drag_mult == 1 else p_drag
|
||||||
|
p_drag = p_drag * p_size * p_size if drag_mult == 1 else p_drag
|
||||||
|
|
||||||
|
export(p_mass)
|
||||||
|
export(p_drag)
|
||||||
|
export(p_color)
|
||||||
|
export(p_direction_angle)
|
||||||
|
export(p_size)
|
||||||
|
|
||||||
|
p_velocity_vec = vector2(-1.0, 0.0) @ (p_velocity * 0.001)
|
||||||
|
p_velocity_vec = rotate_vec2(p_velocity_vec, -p_direction_angle, float2(0.0, 0.0))
|
||||||
|
|
||||||
|
:: if pcloud_write
|
||||||
|
n = get_float("$number")
|
||||||
|
particle_index = toint(n)
|
||||||
|
_OUT_ = p_lifetime if particle_index < get_int("total_particles") else 1
|
||||||
|
export(particle_index)
|
||||||
|
:: else
|
||||||
|
_OUT_ = p_lifetime
|
||||||
|
:: endif
|
||||||
|
|
||||||
|
export(stop_simulation)
|
||||||
|
export(p_lifetime)
|
||||||
|
export(p_velocity_vec)
|
||||||
|
export(p_position)
|
||||||
@@ -0,0 +1,175 @@
|
|||||||
|
:: import "particle_system.sex" as ps
|
||||||
|
|
||||||
|
declare_inputs("particle_system")
|
||||||
|
|
||||||
|
n = get_float("$number")
|
||||||
|
ni = toint(n)
|
||||||
|
lifetime = get_int("p_lifetime")
|
||||||
|
lifetime = tofloat(lifetime)
|
||||||
|
glob_lifetime = get_int("lifetime")
|
||||||
|
step_limit = tofloat(glob_lifetime) * particle_step
|
||||||
|
step_limit = toint(step_limit)
|
||||||
|
|
||||||
|
|
||||||
|
total_lifetime = (lifetime - 1.0) if lifetime > 1.0 else 0.0
|
||||||
|
itotal_lifetime = toint(total_lifetime)
|
||||||
|
|
||||||
|
:: if pcloud_write
|
||||||
|
cloud_index = get_int("cloud_index")
|
||||||
|
particle_index = get_int("particle_index")
|
||||||
|
:: endif
|
||||||
|
|
||||||
|
norm_life = n / total_lifetime
|
||||||
|
|
||||||
|
p_velocity_vec = get_float2("p_velocity_vec")
|
||||||
|
gravity_vec = get_float2("gravity_vec")
|
||||||
|
p_position = get_float2("p_position")
|
||||||
|
p_size = get_float("p_size")
|
||||||
|
p_color = get_float("p_color")
|
||||||
|
p_mass = get_float("p_mass")
|
||||||
|
p_drag = get_float("p_drag")
|
||||||
|
p_orientation = get_float("p_orientation")
|
||||||
|
p_ang_velocity = get_float("p_ang_velocity")
|
||||||
|
p_masking = get_float("p_masking")
|
||||||
|
stop_simulation = get_int("stop_simulation")
|
||||||
|
|
||||||
|
{{ ps.calculate_modifier_sample() }}
|
||||||
|
|
||||||
|
{{ ps.apply_modifiers("mass", 0) }}
|
||||||
|
{{ ps.apply_modifiers("drag", 1) }}
|
||||||
|
{{ ps.apply_modifiers("color", 2) }}
|
||||||
|
{{ ps.apply_modifiers("ang_velocity", 3) }}
|
||||||
|
{{ ps.apply_modifiers("size", 4) }}
|
||||||
|
{{ ps.apply_modifiers("orientation", 5, true) }}
|
||||||
|
{{ ps.apply_modifiers("masking", 6) }}
|
||||||
|
|
||||||
|
# calculate velocity coeffs
|
||||||
|
#p_velocity_vec = rotate_vec2(p_velocity_vec, p_ang_velocity * 0.001, float2(0.0, 0.0))
|
||||||
|
p_velocity_norm = normalize_vec2(p_velocity_vec)
|
||||||
|
p_direction = atan2(p_velocity_vec) / _2pi()
|
||||||
|
p_v = length_vec2(p_velocity_vec)
|
||||||
|
|
||||||
|
# update position (excluding first frame)
|
||||||
|
p_position = p_position + p_velocity_vec if n > 0.0 else p_position
|
||||||
|
|
||||||
|
# calculate forces
|
||||||
|
force = samplecol(p_position, 8, 1)
|
||||||
|
force = force.xy @ 2.0 - float2(1.0, 1.0) if use_force_map else float2(0.0, 0.0)
|
||||||
|
force = float2(0.0, 0.0) if length_vec2(force) < 0.00001 else force
|
||||||
|
|
||||||
|
# drag force
|
||||||
|
drag_force = p_velocity_norm @ (-1.0 * p_v * p_v * p_drag)
|
||||||
|
force = force + drag_force
|
||||||
|
|
||||||
|
gravity_from_map = samplecol(p_position, 25, 1)
|
||||||
|
gravity_from_map = gravity_from_map.xy @ 2.0 - float2(1.0, 1.0) if use_gravity_map else float2(0.0, 0.0)
|
||||||
|
total_gravity = gravity_from_map @ gravity_scalar if use_gravity_map else gravity_vec
|
||||||
|
|
||||||
|
# apply forces
|
||||||
|
p_velocity_vec = p_velocity_vec + force @ ( 1.0 / p_mass) + total_gravity
|
||||||
|
|
||||||
|
# clamp velocity
|
||||||
|
max_velocity = max_velocity * 0.001
|
||||||
|
p_velocity_norm = normalize_vec2(p_velocity_vec)
|
||||||
|
p_v = length_vec2(p_velocity_vec)
|
||||||
|
p_v = p_v if p_v < max_velocity else max_velocity
|
||||||
|
p_velocity_vec = p_velocity_vec + p_velocity_norm @ p_v - p_velocity_vec if clamp_velocity else p_velocity_vec
|
||||||
|
|
||||||
|
p_velocity_vec = rotate_vec2(p_velocity_vec, p_ang_velocity * 0.001, float2(0.0, 0.0))
|
||||||
|
|
||||||
|
p_size_out = vector2(p_size, p_size)
|
||||||
|
|
||||||
|
stop_mask = samplelum(p_position, 24, 0)
|
||||||
|
stop_simulation = stop_simulation + 1 if stop_mask > stop_threshold and stop_sim_at_black else stop_simulation
|
||||||
|
simulation_halted = stop_simulation > 1
|
||||||
|
simulation_halted = True if stop_simulation > 0 and ni == 0 else simulation_halted
|
||||||
|
|
||||||
|
masked = uniform_ab(0.0, 1.0) > p_masking
|
||||||
|
masked = False if output_mode == 1 else masked
|
||||||
|
|
||||||
|
p_color = 0.0 if masked else p_color
|
||||||
|
p_color = 0.0 if output_mode == 0 and ni > step_limit else p_color
|
||||||
|
p_color = 0.0 if ni % trail_quantize > 0 and not output_mode == 1 else p_color
|
||||||
|
|
||||||
|
color_before_trim = p_color
|
||||||
|
|
||||||
|
last_integration = (ni == itotal_lifetime)
|
||||||
|
last_step = ((ni + 1) > step_limit and ni <= step_limit) or (itotal_lifetime <= step_limit and last_integration )
|
||||||
|
simulation_first_stop = stop_simulation == 1 and ni <= step_limit
|
||||||
|
last_step = simulation_first_stop or (last_step and stop_simulation < 1)
|
||||||
|
|
||||||
|
:: if not pcloud_write
|
||||||
|
p_color = 0.0 if simulation_halted else p_color
|
||||||
|
p_color = 0.0 if output_mode == 1 and not last_step else p_color
|
||||||
|
:: endif
|
||||||
|
|
||||||
|
p_orientation_out = p_orientation + p_direction if velocity_orient else p_orientation
|
||||||
|
|
||||||
|
# write simulation to pcloud
|
||||||
|
|
||||||
|
:: if pcloud_write
|
||||||
|
|
||||||
|
cloud_img_size = get_int2("cloud_img_size")
|
||||||
|
fsize = get_float2("fsize")
|
||||||
|
out_fragment_size = get_float2("out_fragment_size")
|
||||||
|
|
||||||
|
p_orientation_out = 0.0
|
||||||
|
|
||||||
|
# current frame
|
||||||
|
cloud_masked = uniform_ab(0.0, 1.0) < pc_mask
|
||||||
|
cloud_mask_sample = modifier_sample if point_cloud_type == 1 else modifier_sample_global
|
||||||
|
cloud_mask = samplelum(cloud_mask_sample, 25, 0)
|
||||||
|
cloud_masked = cloud_masked or uniform_ab(0.0, 1.0) >= cloud_mask
|
||||||
|
|
||||||
|
write_to_cloud = True
|
||||||
|
write_to_cloud = write_to_cloud and not cloud_masked
|
||||||
|
pcloud_quant = True if last_step else ni % pcloud_quantize == 0
|
||||||
|
write_to_cloud = write_to_cloud and pcloud_quant
|
||||||
|
write_to_cloud = write_to_cloud and not simulation_halted
|
||||||
|
|
||||||
|
# check capacity
|
||||||
|
write_to_cloud = write_to_cloud and cloud_index <= (cloud_img_size.a * cloud_img_size.b / 2 - 1)
|
||||||
|
alpha = 1.0 if write_to_cloud else 0.0
|
||||||
|
pos_color = merge_float4(p_position.x, p_position.y, p_direction + 0.5, alpha)
|
||||||
|
p_flag = 1.0 if last_step else 0.0
|
||||||
|
p_flag = 2.0 if last_step and stop_simulation > 0 else p_flag
|
||||||
|
p_attribs = merge_float4(p_size, color_before_trim, p_flag, alpha)
|
||||||
|
|
||||||
|
output_row = tofloat((cloud_index * 2) / cloud_img_size.a)
|
||||||
|
output_column = tofloat((cloud_index * 2) % cloud_img_size.a)
|
||||||
|
|
||||||
|
fcloud_index = tofloat(cloud_index)
|
||||||
|
write_index = (particle_index == get_int("total_particles"))
|
||||||
|
|
||||||
|
p_size_out = out_fragment_size
|
||||||
|
p_position_out = out_fragment_size / float2(2.0, 2.0) + vector2(output_column, output_row) / (fsize - float2(1.0, 1.0)) * (float2(1.0, 1.0) - out_fragment_size)
|
||||||
|
|
||||||
|
#pos_color = merge_float4(0.5, 0.5, 0.0, alpha)
|
||||||
|
p_color_out = merge_float4(fcloud_index, fsize.x, fsize.y, 1.0) if write_index else pos_color
|
||||||
|
p_position_out = float2(1.0, 1.0) - out_fragment_size / float2(2.0, 2.0) if write_index else p_position_out
|
||||||
|
|
||||||
|
cloud_index = cloud_index + 1 if write_to_cloud else cloud_index
|
||||||
|
|
||||||
|
export(p_attribs)
|
||||||
|
export(p_color_out)
|
||||||
|
export(cloud_index)
|
||||||
|
|
||||||
|
_OUT_ = 1 if write_index else 2
|
||||||
|
|
||||||
|
:: else
|
||||||
|
|
||||||
|
p_position_out = p_position
|
||||||
|
p_color_out = merge_float4(p_color, p_color, p_color, p_color)
|
||||||
|
export(p_color_out)
|
||||||
|
|
||||||
|
_OUT_ = 0 if simulation_halted else 1
|
||||||
|
|
||||||
|
:: endif
|
||||||
|
|
||||||
|
stop_simulation = stop_simulation + 1 if stop_mask > stop_threshold and stop_sim_at_black else stop_simulation
|
||||||
|
export(stop_simulation)
|
||||||
|
export(p_size_out)
|
||||||
|
export(p_orientation_out)
|
||||||
|
export(p_position)
|
||||||
|
export(p_position_out)
|
||||||
|
export(p_velocity_vec)
|
||||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,49 @@
|
|||||||
|
:: import "point_cloud.sex" as pc
|
||||||
|
|
||||||
|
pc_index = get_int("pc_index")
|
||||||
|
min_distance = get_float("min_distance")
|
||||||
|
|
||||||
|
n = toint(get_float("$number"))
|
||||||
|
|
||||||
|
{{ pc.init_pcloud("pcloud") }}
|
||||||
|
|
||||||
|
last_iteration = (n == toint(pcloud_meta.x))
|
||||||
|
self_check = (n == pc_index)
|
||||||
|
|
||||||
|
sample_idx = n
|
||||||
|
|
||||||
|
{{ pc.get_pcloud_point_noattr("pcloud", "sample_idx", "sample_cloud") }}
|
||||||
|
{{ pc.get_pcloud_point_noattr("pcloud", "pc_index", "sample_origin") }}
|
||||||
|
|
||||||
|
pos_origin = sample_origin.xy
|
||||||
|
|
||||||
|
:: if tiled
|
||||||
|
pos_origin = pos_origin % float2(1.0, 1.0)
|
||||||
|
:: endif
|
||||||
|
|
||||||
|
skip_iteration = self_check or last_iteration
|
||||||
|
|
||||||
|
:: set checks = 9 if tiled else 1
|
||||||
|
|
||||||
|
:: for i in range(checks)
|
||||||
|
|
||||||
|
pos_comp = sample_cloud.xy + vector2({{ pc.tile_offset[i] }})
|
||||||
|
|
||||||
|
dist_vec = pos_origin - pos_comp
|
||||||
|
dist = length_vec2(dist_vec)
|
||||||
|
mdist = dist if dist < min_distance and not skip_iteration else min_distance
|
||||||
|
|
||||||
|
min_distance = mdist
|
||||||
|
|
||||||
|
:: endfor
|
||||||
|
|
||||||
|
color_out = merge_float4(pos_origin.x, pos_origin.y, min_distance , 1.0)
|
||||||
|
pos_out = sample_uv
|
||||||
|
size_out = pcloud_frag_size
|
||||||
|
|
||||||
|
_OUT_ = last_iteration
|
||||||
|
|
||||||
|
export(color_out)
|
||||||
|
export(pos_out)
|
||||||
|
export(size_out)
|
||||||
|
export(min_distance)
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
:: import "point_cloud.sex" as pc
|
||||||
|
|
||||||
|
pc_index = get_int("pc_index")
|
||||||
|
max_dist = get_float("#max_dist")
|
||||||
|
|
||||||
|
pcloud_meta = get_float3("#pcloud_meta")
|
||||||
|
pcloud_frag_size = get_float2("pcloud_frag_size")
|
||||||
|
pcloud_size_half = get_float2("pcloud_size_half")
|
||||||
|
sample_origin = get_float4("sample_origin")
|
||||||
|
|
||||||
|
n = toint(get_float("$number"))
|
||||||
|
|
||||||
|
last_iteration = (n == toint(pcloud_meta.x))
|
||||||
|
self_check = (n == pc_index)
|
||||||
|
|
||||||
|
{{ pc.get_pcloud_point_noattr("pcloud", "n", "sample_cloud") }}
|
||||||
|
|
||||||
|
pos_origin = sample_origin.xy
|
||||||
|
|
||||||
|
:: if tiled
|
||||||
|
pos_origin = pos_origin % float2(1.0, 1.0)
|
||||||
|
:: endif
|
||||||
|
|
||||||
|
need_check = False
|
||||||
|
|
||||||
|
:: set checks = 9 if tiled else 1
|
||||||
|
:: for i in range(checks)
|
||||||
|
pos_comp = sample_cloud.xy + vector2({{ pc.tile_offset[i] }})
|
||||||
|
need_check = need_check or abs(pos_comp.x - pos_origin.x) < max_dist and abs(pos_comp.y - pos_origin.y) < max_dist
|
||||||
|
:: endfor
|
||||||
|
|
||||||
|
need_check = need_check or last_iteration
|
||||||
|
need_check = need_check and not self_check
|
||||||
|
|
||||||
|
_OUT_ = need_check
|
||||||
|
|
||||||
|
export(sample_cloud)
|
||||||
@@ -0,0 +1,65 @@
|
|||||||
|
:: import "point_cloud.sex" as pc
|
||||||
|
|
||||||
|
pc_index = get_int("pc_index")
|
||||||
|
total_distance = get_float2("total_distance")
|
||||||
|
total_overlap = get_int("total_overlap")
|
||||||
|
n = toint(get_float("$number"))
|
||||||
|
|
||||||
|
pcloud_meta = get_float3("#pcloud_meta")
|
||||||
|
pcloud_frag_size = get_float2("pcloud_frag_size")
|
||||||
|
sample_origin = get_float4("sample_origin")
|
||||||
|
sample_cloud = get_float4("sample_cloud")
|
||||||
|
origin_uv = get_float2("origin_uv")
|
||||||
|
gap = get_float("gap")
|
||||||
|
|
||||||
|
last_iteration = (n == toint(pcloud_meta.x))
|
||||||
|
self_check = (n == pc_index)
|
||||||
|
|
||||||
|
sample_idx = n
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
pos_origin = sample_origin.xy
|
||||||
|
:: if tiled
|
||||||
|
pos_origin = pos_origin % float2(1.0, 1.0)
|
||||||
|
:: endif
|
||||||
|
size_origin = sample_origin.z
|
||||||
|
size_comp = sample_cloud.z
|
||||||
|
size_sum = 0.5 * (size_comp + size_origin) + gap
|
||||||
|
size_ratio = size_comp / (size_comp + size_origin)
|
||||||
|
|
||||||
|
:: set checks = 9 if tiled else 1
|
||||||
|
|
||||||
|
:: for i in range(checks)
|
||||||
|
pos_comp = sample_cloud.xy + vector2({{ pc.tile_offset[i] }})
|
||||||
|
|
||||||
|
dist_vec = pos_origin - pos_comp
|
||||||
|
dist = length_vec2(dist_vec)
|
||||||
|
|
||||||
|
is_overlapped = (dist < size_sum)
|
||||||
|
overlapping_length = size_sum - dist
|
||||||
|
|
||||||
|
push_vec = normalize_vec2(dist_vec)
|
||||||
|
push_vec = push_vec @ (overlapping_length * size_ratio)
|
||||||
|
|
||||||
|
is_overlapped = is_overlapped and not self_check
|
||||||
|
total_distance = total_distance + push_vec if is_overlapped and not last_iteration else total_distance
|
||||||
|
total_overlap = total_overlap + 1 if is_overlapped and not last_iteration else total_overlap
|
||||||
|
:: endfor
|
||||||
|
|
||||||
|
new_pos = pos_origin + total_distance @ (1.0 / tofloat(total_overlap)) if total_overlap > 0 else pos_origin
|
||||||
|
:: if tiled
|
||||||
|
new_pos = new_pos % float2(1.0, 1.0)
|
||||||
|
:: endif
|
||||||
|
|
||||||
|
color_out = merge_float4(new_pos.x, new_pos.y, size_origin, 1.0)
|
||||||
|
pos_out = origin_uv
|
||||||
|
size_out = pcloud_frag_size
|
||||||
|
|
||||||
|
_OUT_ = last_iteration
|
||||||
|
|
||||||
|
export(color_out)
|
||||||
|
export(pos_out)
|
||||||
|
export(size_out)
|
||||||
|
export(total_distance)
|
||||||
|
export(total_overlap)
|
||||||
@@ -0,0 +1,71 @@
|
|||||||
|
:: macro init_pcloud(cloud_name)
|
||||||
|
{{ cloud_name }}_meta = get_float3("#{{ cloud_name }}_meta")
|
||||||
|
|
||||||
|
{{ cloud_name }}_frag_size = float2(1.0, 1.0) / {{ cloud_name }}_meta.yz
|
||||||
|
{{ cloud_name }}_size_half = {{ cloud_name }}_frag_size / float2(2.0, 2.0)
|
||||||
|
:: endmacro
|
||||||
|
|
||||||
|
:: macro get_pcloud_point(cloud_name, sample_idx, sample_name, cloud_input = 0)
|
||||||
|
row = ({{ sample_idx }} * 2) / toint({{ cloud_name }}_meta.y)
|
||||||
|
column = ({{ sample_idx }} * 2) % toint({{ cloud_name }}_meta.y)
|
||||||
|
|
||||||
|
rc = vector2(tofloat(column), tofloat(row))
|
||||||
|
sample_uv = {{ cloud_name }}_size_half + rc * {{ cloud_name }}_frag_size
|
||||||
|
|
||||||
|
{{ sample_name }} = samplecol(sample_uv, {{ cloud_input }}, 0)
|
||||||
|
{{ sample_name }}_attrib = samplecol(sample_uv + vector2({{ cloud_name }}_frag_size.x, 0.0), {{ cloud_input }}, 0)
|
||||||
|
:: endmacro
|
||||||
|
|
||||||
|
:: macro get_pcloud_point_noattr(cloud_name, sample_idx, sample_name, cloud_input = 0)
|
||||||
|
row = ({{ sample_idx }} * 2) / toint({{ cloud_name }}_meta.y)
|
||||||
|
column = ({{ sample_idx }} * 2) % toint({{ cloud_name }}_meta.y)
|
||||||
|
|
||||||
|
rc = vector2(tofloat(column), tofloat(row))
|
||||||
|
sample_uv = {{ cloud_name }}_size_half + rc * {{ cloud_name }}_frag_size
|
||||||
|
|
||||||
|
{{ sample_name }} = samplecol(sample_uv, {{ cloud_input }}, 0)
|
||||||
|
:: endmacro
|
||||||
|
|
||||||
|
:: macro pcloud_index_uv(uv_name, cloud_name, index)
|
||||||
|
|
||||||
|
pc_row = ({{ index }} * 2) / toint({{ cloud_name }}_meta.y)
|
||||||
|
pc_column = ({{ index }} * 2) % toint({{ cloud_name }}_meta.y)
|
||||||
|
pc_rc = vector2(tofloat(pc_column), tofloat(pc_row))
|
||||||
|
f2_one = float2(1.0, 1.0)
|
||||||
|
|
||||||
|
{{ uv_name }} = {{ cloud_name }}_size_half + pc_rc / ( {{ cloud_name }}_meta.yz - f2_one ) * (f2_one - {{ cloud_name }}_frag_size )
|
||||||
|
|
||||||
|
:: endmacro
|
||||||
|
|
||||||
|
:: macro pp_init()
|
||||||
|
size = get_float2("$size")
|
||||||
|
pos = get_float2("$pos")
|
||||||
|
frag_size = float2(1.0, 1.0) / size
|
||||||
|
frag_size_half = frag_size / float2(2.0, 2.0)
|
||||||
|
pixel_coord = size * (pos - frag_size_half)
|
||||||
|
pixel_index = pixel_coord.y * size.x + pixel_coord.x
|
||||||
|
pixel_index = toint(pixel_index)
|
||||||
|
is_attrib = pixel_index % 2 > 0
|
||||||
|
|
||||||
|
sample = samplecol(pos, 0, 0)
|
||||||
|
attr_offset = vector2(-frag_size.x, 0.0) if is_attrib else vector2(frag_size.x, 0.0)
|
||||||
|
neigh_sample = samplecol(pos + attr_offset, 0, 0)
|
||||||
|
|
||||||
|
point = neigh_sample if is_attrib else sample
|
||||||
|
point_attrib = sample if is_attrib else neigh_sample
|
||||||
|
:: endmacro
|
||||||
|
|
||||||
|
:: macro sample_curve(factor, npoints, is_closed, alpha, tension, point_prefix, start_index = 0):
|
||||||
|
catmull_rom_16({{ factor }},
|
||||||
|
{{ npoints }},
|
||||||
|
{{ is_closed }},
|
||||||
|
{{ alpha }},
|
||||||
|
{{ tension }},
|
||||||
|
:: for p_i in range(start_index, start_index + 16):
|
||||||
|
{{ point_prefix }}{{ p_i }},
|
||||||
|
:: endfor
|
||||||
|
)
|
||||||
|
:: endmacro
|
||||||
|
|
||||||
|
:: set attrib_map = {1:"point.z", 2:"point_attrib.x", 3:"point_attrib.y", 4:"point_attrib.z"}
|
||||||
|
:: set tile_offset = ["0.0, 0.0", "0.0, -1.0", "0.0, 1.0", "-1.0, 0.0", "1.0, 0.0", "1.0, -1.0", "1.0, 1.0", "-1.0, -1.0", "-1.0, 1.0"]
|
||||||
Reference in New Issue
Block a user