def rocks_noise(coords, depth, hardnoise, nbasis, distortion): x,y,z = coords p = turbulence((x, y, z), 4, 0, 0) * 0.125 * distortion xx, yy, zz = x, y, z a = turbulence((xx + p, yy + p, zz), 2, 0, 7) pa = a * 0.1875 * distortion b = turbulence((x, y, z + pa), depth, hardnoise, nbasis) return ((a + 0.5 * (b - a)) * 0.5 + 0.5)
def rocks_noise(coords, depth, hardnoise, nbasis, distortion): x, y, z = coords p = turbulence((x, y, z), 4, 0, noise_basis='BLENDER') * 0.125 * distortion xx, yy, zz = x, y, z a = turbulence((xx + p, yy + p, zz), 2, 0, noise_basis='VORONOI_F2F1') pa = a * 0.1875 * distortion b = turbulence((x, y, z + pa), depth, hardnoise, noise_basis=nbasis) return ((a + 0.5 * (b - a)) * 0.5 + 0.5)
def rocks_noise(coords, depth, hardnoise, nbasis, distortion): x, y, z = coords p = turbulence((x, y, z), 4, 0, 0) * 0.125 * distortion xx, yy, zz = x, y, z a = turbulence((xx + p, yy + p, zz), 2, 0, 7) pa = a * 0.1875 * distortion b = turbulence((x, y, z + pa), depth, hardnoise, nbasis) return ((a + 0.5 * (b - a)) * 0.5 + 0.5)
def rocks_noise(coords, depth, hardnoise, nbasis, distortion): x,y,z = coords p = turbulence((x, y, z), 4, 0, noise_basis='BLENDER') * 0.125 * distortion xx, yy, zz = x, y, z a = turbulence((xx + p, yy + p, zz), 2, 0, noise_basis='VORONOI_F2F1') pa = a * 0.1875 * distortion b = turbulence((x, y, z + pa), depth, hardnoise, noise_basis=nbasis) return ((a + 0.5 * (b - a)) * 0.5 + 0.5)
def sv_main( verts=[], octaves=3, hard=1, noise_basis=1, amp=0.5, freq=2.0 ): data = [] in_sockets = [ ['v','Vector', verts], ['s', 'octaves', octaves], ['s', 'Hard ', hard], ['s', 'Noise Basis', noise_basis], ['s', 'Amplitude', amp], ['s', 'Frequency', freq] ] out_sockets = [ ['s', 'Float Data', [data]] ] if verts and verts[0]: for v in verts[0]: out = noise.turbulence(v, octaves, hard, noise_basis, amp, freq ) data.append(out) print(data) return in_sockets, out_sockets
def planet_noise(coords, oct=6, hard=0, noisebasis=1, nabla=0.001): x, y, z = coords d = 0.001 offset = nabla * 1000 x = turbulence((x, y, z), oct, hard, noisebasis) y = turbulence((x + offset, y, z), oct, hard, noisebasis) z = turbulence((x, y + offset, z), oct, hard, noisebasis) xdy = x - turbulence((x, y + d, z), oct, hard, noisebasis) xdz = x - turbulence((x, y, z + d), oct, hard, noisebasis) ydx = y - turbulence((x + d, y, z), oct, hard, noisebasis) ydz = y - turbulence((x, y, z + d), oct, hard, noisebasis) zdx = z - turbulence((x + d, y, z), oct, hard, noisebasis) zdy = z - turbulence((x, y + d, z), oct, hard, noisebasis) return (zdy - ydz), (zdx - xdz), (ydx - xdy)
def ant_turbulence(coords, depth, hardnoise, nbasis, amp, freq, distortion): x, y, z = coords t = turbulence_vector((x / 2, y / 2, z / 2), depth, 0, noise_basis=nbasis, amplitude_scale=amp, frequency_scale=freq) * 0.5 * distortion return turbulence( (t[0], t[1], t[2]), 2, hardnoise, noise_basis="VORONOI_F1") * 0.5 + 0.5
def Effect_Function(coords, type, bias, turb, depth, frequency, amplitude): x, y, z = coords ## turbulence: if turb > 0.0: t = turb * ( 0.5 + 0.5 * turbulence(coords, 6, 0, 0)) x = x + t y = y + t z = z + t result = Effect_Basis_Function((x, y, z), type, bias) * amplitude ## fractalize: if depth != 0: i=0 for i in range(depth): i+=1 x *= frequency y *= frequency result += Effect_Basis_Function((x, y, z), type, bias) * amplitude / i return result
def Effect_Function(coords, type, bias, turb, depth, frequency, amplitude): x, y, z = coords ## turbulence: if turb > 0.0: t = turb * ( 0.5 + 0.5 * turbulence(coords, 6, 0, noise_basis="BLENDER")) x = x + t y = y + t z = z + t result = Effect_Basis_Function((x, y, z), type, bias) * amplitude ## fractalize: if depth != 0: i=0 for i in range(depth): i+=1 x *= frequency y *= frequency result += Effect_Basis_Function((x, y, z), type, bias) * amplitude / i return result
def Effect_Basis_Function(coords, type, bias): bias = int(bias) type = int(type) x, y, z = coords iscale = 1.0 offset = 0.0 ## gradient: if type == 1: effect = offset + iscale * (Bias_Types[bias](x + y)) ## waves / bumps: elif type == 2: effect = offset + iscale * 0.5 * (Bias_Types[bias] (x * pi) + Bias_Types[bias](y * pi)) ## zigzag: elif type == 3: effect = offset + iscale * Bias_Types[bias](offset + iscale * sin(x * pi + sin(y * pi))) ## wavy: elif type == 4: effect = offset + iscale * (Bias_Types[bias]( cos(x) + sin(y) + cos(x * 2 + y * 2) - sin(-x * 4 + y * 4))) ## sine bump: elif type == 5: effect = offset + iscale * 1 - Bias_Types[bias]( (sin(x * pi) + sin(y * pi))) ## dots: elif type == 6: effect = offset + iscale * (Bias_Types[bias](x * pi * 2) * Bias_Types[bias](y * pi * 2)) - 0.5 ## rings: elif type == 7: effect = offset + iscale * (Bias_Types[bias](1.0 - (x * x + y * y))) ## spiral: elif type == 8: effect = offset + iscale * Bias_Types[bias]( (x * sin(x * x + y * y) + y * cos(x * x + y * y)) / (x**2 + y**2 + 0.5)) * 2 ## square / piramide: elif type == 9: effect = offset + iscale * Bias_Types[bias](1.0 - sqrt( (x * x)**10 + (y * y)**10)**0.1) ## blocks: elif type == 10: effect = (0.5 - max(Bias_Types[bias](x * pi), Bias_Types[bias](y * pi))) if effect > 0.0: effect = 1.0 effect = offset + iscale * effect ## grid: elif type == 11: effect = (0.025 - min(Bias_Types[bias](x * pi), Bias_Types[bias](y * pi))) if effect > 0.0: effect = 1.0 effect = offset + iscale * effect ## tech: elif type == 12: a = max(Bias_Types[bias](x * pi), Bias_Types[bias](y * pi)) b = max(Bias_Types[bias](x * pi * 2 + 2), Bias_Types[bias](y * pi * 2 + 2)) effect = min(Bias_Types[bias](a), Bias_Types[bias](b)) * 3.0 - 2.0 if effect > 0.5: effect = 1.0 effect = offset + iscale * effect ## crackle: elif type == 13: t = turbulence((x, y, 0), 6, 0, noise_basis="BLENDER") * 0.25 effect = variable_lacunarity((x, y, t), 0.25, noise_type2='VORONOI_CRACKLE') if effect > 0.5: effect = 0.5 effect = offset + iscale * effect ## sparse cracks noise: elif type == 14: effect = 2.5 * abs(noise( (x, y, 0), noise_basis="PERLIN_ORIGINAL")) - 0.1 if effect > 0.25: effect = 0.25 effect = offset + iscale * (effect * 2.5) ## shattered rock noise: elif type == 15: effect = 0.5 + noise((x, y, 0), noise_basis="VORONOI_F2F1") if effect > 0.75: effect = 0.75 effect = offset + iscale * effect ## lunar noise: elif type == 16: effect = 0.25 + 1.5 * voronoi( (x, y, 0), distance_metric='DISTANCE_SQUARED')[0][0] if effect > 0.5: effect = 0.5 effect = offset + iscale * effect * 2 ## cosine noise: elif type == 17: effect = cos(5 * noise((x, y, 0), noise_basis="BLENDER")) effect = offset + iscale * (effect * 0.5) ## spikey noise: elif type == 18: n = 0.5 + 0.5 * turbulence( (x * 5, y * 5, 0), 8, 0, noise_basis="BLENDER") effect = ((n * n)**5) effect = offset + iscale * effect ## stone noise: elif type == 19: effect = offset + iscale * (noise( (x * 2, y * 2, 0), noise_basis="BLENDER") * 1.5 - 0.75) ## Flat Turb: elif type == 20: t = turbulence((x, y, 0), 6, 0, noise_basis="BLENDER") effect = t * 2.0 if effect > 0.25: effect = 0.25 effect = offset + iscale * effect ## Flat Voronoi: elif type == 21: t = 1 - voronoi((x, y, 0), distance_metric='DISTANCE_SQUARED')[0][0] effect = t * 2 - 1.5 if effect > 0.25: effect = 0.25 effect = offset + iscale * effect else: effect = 0.0 if effect < 0.0: effect = 0.0 return effect
def marble(pnt): pnt = Vector(pnt) y = pnt.y + turb * noise.turbulence(pnt, octaves, hard_on, noise_type, amp, freq) y = math.sin (y * math.pi/2) return marble_color(y)
def ant_turbulence(coords, depth, hardnoise, nbasis, amp, freq, distortion): x, y, z = coords t = turbulence_vector( (x / 2, y / 2, z / 2), depth, 0, nbasis, amp, freq) * 0.5 * distortion return turbulence((t[0], t[1], t[2]), 2, hardnoise, 3) * 0.5 + 0.5
def Effect_Basis_Function(coords, type, bias): bias = int(bias) type = int(type) x, y, z = coords iscale = 1.0 offset = 0.0 ## gradient: if type == 1: effect = offset + iscale * (Bias_Types[bias](x + y)) ## waves / bumps: elif type == 2: effect = offset + iscale * 0.5 * (Bias_Types[bias](x * pi) + Bias_Types[bias](y * pi)) ## zigzag: elif type == 3: effect = offset + iscale * Bias_Types[bias](offset + iscale * sin(x * pi + sin(y * pi))) ## wavy: elif type == 4: effect = offset + iscale * (Bias_Types[bias](cos(x) + sin(y) + cos(x * 2 + y * 2) - sin(-x * 4 + y * 4))) ## sine bump: elif type == 5: effect = offset + iscale * 1 - Bias_Types[bias]((sin(x * pi) + sin(y * pi))) ## dots: elif type == 6: effect = offset + iscale * (Bias_Types[bias](x * pi * 2) * Bias_Types[bias](y * pi * 2)) - 0.5 ## rings: elif type == 7: effect = offset + iscale * (Bias_Types[bias ](1.0 - (x * x + y * y))) ## spiral: elif type == 8: effect = offset + iscale * Bias_Types[bias]( (x * sin(x * x + y * y) + y * cos(x * x + y * y)) / (x**2 + y**2 + 0.5)) * 2 ## square / piramide: elif type == 9: effect = offset + iscale * Bias_Types[bias](1.0 - sqrt((x * x)**10 + (y * y)**10)**0.1) ## blocks: elif type == 10: effect = (0.5 - max(Bias_Types[bias](x * pi) , Bias_Types[bias](y * pi))) if effect > 0.0: effect = 1.0 effect = offset + iscale * effect ## grid: elif type == 11: effect = (0.025 - min(Bias_Types[bias](x * pi), Bias_Types[bias](y * pi))) if effect > 0.0: effect = 1.0 effect = offset + iscale * effect ## tech: elif type == 12: a = max(Bias_Types[bias](x * pi), Bias_Types[bias](y * pi)) b = max(Bias_Types[bias](x * pi * 2 + 2), Bias_Types[bias](y * pi * 2 + 2)) effect = min(Bias_Types[bias](a), Bias_Types[bias](b)) * 3.0 - 2.0 if effect > 0.5: effect = 1.0 effect = offset + iscale * effect ## crackle: elif type == 13: t = turbulence((x, y, 0), 6, 0, 0) * 0.25 effect = variable_lacunarity((x, y, t), 0.25, 0, 8) if effect > 0.5: effect = 0.5 effect = offset + iscale * effect ## sparse cracks noise: elif type == 14: effect = 2.5 * abs(noise((x, y, 0), 1)) - 0.1 if effect > 0.25: effect = 0.25 effect = offset + iscale * (effect * 2.5) ## shattered rock noise: elif type == 15: effect = 0.5 + noise((x, y, 0), 7) if effect > 0.75: effect = 0.75 effect = offset + iscale * effect ## lunar noise: elif type == 16: effect = 0.25 + 1.5 * voronoi((x, y, 0), 1)[0][0] if effect > 0.5: effect = 0.5 effect = offset + iscale * effect * 2 ## cosine noise: elif type == 17: effect = cos(5 * noise((x, y, 0), 0)) effect = offset + iscale * (effect * 0.5) ## spikey noise: elif type == 18: n = 0.5 + 0.5 * turbulence((x * 5, y * 5, 0), 8, 0, 0) effect = ((n * n)**5) effect = offset + iscale * effect ## stone noise: elif type == 19: effect = offset + iscale * (noise((x * 2, y * 2, 0), 0) * 1.5 - 0.75) ## Flat Turb: elif type == 20: t = turbulence((x, y, 0), 6, 0, 0) effect = t * 2.0 if effect > 0.25: effect = 0.25 effect = offset + iscale * effect ## Flat Voronoi: elif type == 21: t = 1 - voronoi((x, y, 0), 1)[0][0] effect = t * 2 - 1.5 if effect > 0.25: effect = 0.25 effect = offset + iscale * effect else: effect = 0.0 if effect < 0.0: effect = 0.0 return effect
def ant_turbulence(coords, depth, hardnoise, nbasis, amp, freq, distortion): x, y, z = coords t = turbulence_vector((x/2, y/2, z/2), depth, 0, nbasis, amp, freq) * 0.5 * distortion return turbulence((t[0], t[1], t[2]), 2, hardnoise, 3) * 0.5 + 0.5
def ant_turbulence(coords, depth, hardnoise, nbasis, amp, freq, distortion): x, y, z = coords t = turbulence_vector((x/2, y/2, z/2), depth, 0, noise_basis=nbasis, amplitude_scale=amp, frequency_scale=freq) * 0.5 * distortion return turbulence((t[0], t[1], t[2]), 2, hardnoise, noise_basis="VORONOI_F1") * 0.5 + 0.5