Created
November 30, 2020 17:20
-
-
Save ulyssesdotcodes/78eb9d337150010fafad067e448a2edf to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
vector center = point(1, 'P', 0); | |
float scale = chf('scale'); | |
float scale_expand_limit = 2; | |
float scale_expand = min((scale - 1) * 4, scale_expand_limit) * scale_expand_limit; | |
scale_expand = smooth(0, scale_expand_limit, scale_expand) * scale_expand_limit; | |
vector centroid = prim(0, "centroid", @primnum); | |
vector offset = centroid - center; | |
float noise_val = noise(centroid * 10); | |
vector offset_with_noise = offset * noise_val; | |
float off_len = length(offset) * scale_expand; | |
float initial_rot = atan2(offset.z, offset.x); | |
// Rotate around center | |
vector point_offset = @P - centroid; | |
float cent_init_rot = atan2(point_offset.z, point_offset.x); | |
float cent_off_len = length(point_offset); | |
@P.x = centroid.x + cent_off_len * cos(cent_init_rot + (scale - 1) * -2 * noise_val); | |
@P.z = centroid.z + cent_off_len * sin(cent_init_rot + (scale - 1) * -2 * noise_val); | |
@P.x += off_len * cos(initial_rot + (noise_val * scale))* (scale - 1); | |
@P.z += off_len * sin(initial_rot + (noise_val * scale)) * (scale - 1); | |
@P.y += offset_with_noise.y * (scale - 1) * 2; | |
// Other attributes | |
vector color = rgbtohsv(rand(@piece)); | |
color.y = 1; | |
color = hsvtorgb(color); | |
@Cd = color; | |
v@emitcolor = color; | |
v@transcolor = color; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment