pcloud update
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -8,10 +8,14 @@ declare_inputs("particle_system")
|
||||
lifetime_rand = tofloat(lifetime) * (1.0 - lifetime_random)
|
||||
p_lifetime = toint(uniform_ab(lifetime_rand, tofloat(lifetime)))
|
||||
stop_simulation = 0
|
||||
n = get_float("$number")
|
||||
total_particles = get_int("total_particles")
|
||||
|
||||
# calculate start position
|
||||
|
||||
emitter_direction = 0.0
|
||||
norm_particle = n / tofloat(total_particles)
|
||||
emitter_direction = norm_particle if uniform_direction else emitter_direction
|
||||
p_position = start_position
|
||||
|
||||
# calculate line position
|
||||
@@ -24,6 +28,7 @@ line_direction = atan2(line_vec) / _2pi()
|
||||
|
||||
circle_rad = uniform_ab(emitter_radius.x, emitter_radius.y)
|
||||
circle_arc = uniform_ab(emitter_arc.x, emitter_arc.y)
|
||||
circle_arc = norm_particle if uniform_direction else circle_arc
|
||||
|
||||
circle_vec = vector2(-circle_rad, 0.0)
|
||||
circle_vec = rotate_vec2(circle_vec, -circle_arc, float2(0.0, 0.0))
|
||||
@@ -68,15 +73,17 @@ p_position = p_position + unit_rand @ pos_offset
|
||||
{{ 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_direction_angle = p_direction_angle + emitter_direction if pc_inherit_direction else p_direction_angle
|
||||
p_color = p_color * point_attrib.y if emitter_type == 3 and pc_inherit_color else p_color
|
||||
p_size = p_size * point_attrib.x if emitter_type == 3 and pc_inherit_size 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_mass = p_mass * p_size * p_size if mass_mult == 2 else p_mass
|
||||
p_mass = p_mass * 1000.0
|
||||
|
||||
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
|
||||
p_drag = p_drag * p_size * p_size if drag_mult == 2 else p_drag
|
||||
p_drag = p_drag * 1000.0
|
||||
|
||||
export(p_mass)
|
||||
export(p_drag)
|
||||
@@ -84,14 +91,14 @@ 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))
|
||||
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))
|
||||
|
||||
particle_index = toint(n)
|
||||
export(particle_index)
|
||||
|
||||
:: 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)
|
||||
_OUT_ = p_lifetime if particle_index < total_particles else 1
|
||||
:: else
|
||||
_OUT_ = p_lifetime
|
||||
:: endif
|
||||
|
||||
@@ -14,10 +14,8 @@ 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
|
||||
|
||||
@@ -44,10 +42,11 @@ stop_simulation = get_int("stop_simulation")
|
||||
{{ 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)
|
||||
p_velocity_norm = normalize_vec2(p_velocity_vec) if p_v > 0.0 else float2(0.0, 1.0)
|
||||
p_direction = atan2(p_velocity_vec) / _2pi()
|
||||
|
||||
|
||||
# update position (excluding first frame)
|
||||
p_position = p_position + p_velocity_vec if n > 0.0 else p_position
|
||||
@@ -63,7 +62,7 @@ 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
|
||||
total_gravity = gravity_from_map @ (gravity_scalar * 0.00001) if use_gravity_map else gravity_vec
|
||||
|
||||
# apply forces
|
||||
p_velocity_vec = p_velocity_vec + force @ ( 1.0 / p_mass) + total_gravity
|
||||
@@ -77,6 +76,16 @@ p_velocity_vec = p_velocity_vec + p_velocity_norm @ p_v - p_velocity_vec if clam
|
||||
|
||||
p_velocity_vec = rotate_vec2(p_velocity_vec, p_ang_velocity * 0.001, float2(0.0, 0.0))
|
||||
|
||||
need_jitter = uniform_ab(0.0, 1.0) < direction_jitter_prob
|
||||
need_jitter = need_jitter and direction_jitter
|
||||
need_jitter = need_jitter and ni % direction_jitter_quant == 0
|
||||
need_jitter = need_jitter and ni > 0
|
||||
jitter = uniform_ab(direction_jitter_amount.x, direction_jitter_amount.y)
|
||||
jitter = -jitter if uniform_ab(0.0, 1.0) < 0.5 else jitter
|
||||
|
||||
p_velocity_vec = rotate_vec2(p_velocity_vec, jitter, float2(0.0, 0.0)) if need_jitter else p_velocity_vec
|
||||
|
||||
|
||||
p_size_out = vector2(p_size, p_size)
|
||||
|
||||
stop_mask = samplelum(p_position, 24, 0)
|
||||
@@ -107,19 +116,19 @@ p_orientation_out = p_orientation + p_direction if velocity_orient else p_orient
|
||||
|
||||
# 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
|
||||
cloud_mask = samplelum(cloud_mask_sample, 27, 0)
|
||||
map_masked = uniform_ab(0.0, 1.0) >= cloud_mask if point_cloud_type > 0 else False
|
||||
cloud_masked = cloud_masked or map_masked
|
||||
|
||||
write_to_cloud = True
|
||||
write_to_cloud = write_to_cloud and not cloud_masked
|
||||
@@ -127,12 +136,16 @@ 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
|
||||
|
||||
write_to_cloud = True if last_step else write_to_cloud
|
||||
write_to_cloud = True if need_jitter and force_jitter else write_to_cloud
|
||||
|
||||
# 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_flag = 1.0 if need_jitter else 0.0
|
||||
p_flag = 2.0 if last_step else p_flag
|
||||
p_flag = 3.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)
|
||||
@@ -141,32 +154,34 @@ 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)
|
||||
|
||||
:: if pcloud_write
|
||||
|
||||
p_orientation_out = 0.0
|
||||
p_size_out = out_fragment_size
|
||||
p_color_out = merge_float4(fcloud_index, fsize.x, fsize.y, 1.0) if write_index else pos_color
|
||||
|
||||
_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(p_color_out)
|
||||
export(stop_simulation)
|
||||
export(p_size_out)
|
||||
export(p_orientation_out)
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,64 @@
|
||||
declare_inputs("denoise")
|
||||
|
||||
INV_SQRT_OF_2PI = 0.39894228040143267793994605993439
|
||||
INV_PI = 0.31830988618379067153776752674503
|
||||
|
||||
:: set MRAD = 8
|
||||
:: set MRADQ = MRAD * MRAD
|
||||
|
||||
tolerance = 0.01
|
||||
|
||||
radius = floor(sigma * kSigma + 0.5)
|
||||
radQ = radius * radius
|
||||
|
||||
invSigmaQx2 = 0.5 / (sigma * sigma)
|
||||
invSigmaQx2PI = INV_PI * invSigmaQx2
|
||||
|
||||
invThresholdSqx2 = 0.5 / (threshold * threshold)
|
||||
invThresholdSqrt2PI = INV_SQRT_OF_2PI / threshold
|
||||
|
||||
uv = get_float2("$pos")
|
||||
size = get_float2("$size")
|
||||
|
||||
centrPx = samplelum(uv, 0, 0)
|
||||
|
||||
zBuff = 0.0
|
||||
aBuff = 0.0
|
||||
|
||||
radius_ceil = -radius - tolerance
|
||||
radius_floor = radius + tolerance
|
||||
|
||||
:: for dx in range(-MRAD, MRAD + 1)
|
||||
|
||||
pt = sqrt(radQ - {{ dx * dx | float }})
|
||||
pt = ceil(pt)
|
||||
|
||||
use_iteration_dx = {{ dx | float }} > radius_ceil and {{ dx | float }} < radius_floor
|
||||
|
||||
pt_ceil = -pt - tolerance
|
||||
pt_floor = pt + tolerance
|
||||
|
||||
:: for dy in range(-MRAD, MRAD + 1)
|
||||
|
||||
use_iteration_dy = {{ dy | float }} > pt_ceil and {{ dy | float }} < pt_floor
|
||||
use_iteration = use_iteration_dx and use_iteration_dy
|
||||
|
||||
|
||||
d = vector2({{ dx | float }}, {{ dy | float}})
|
||||
blurFactor = exp( -(d ^ d) * invSigmaQx2 ) * invSigmaQx2PI
|
||||
|
||||
walkPx = samplelum(uv + d / size, 0, 0)
|
||||
|
||||
dc = walkPx - centrPx
|
||||
deltaFactor = exp( - dc * dc * invThresholdSqx2) * invThresholdSqrt2PI * blurFactor
|
||||
|
||||
zBuff = zBuff + deltaFactor if use_iteration else zBuff
|
||||
aBuff = aBuff + deltaFactor * walkPx if use_iteration else aBuff
|
||||
|
||||
:: endfor
|
||||
|
||||
:: endfor
|
||||
|
||||
res = aBuff / zBuff
|
||||
|
||||
_OUT_ = merge_float4(res, res, res, res)
|
||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user