New noise: dirty perlin

This commit is contained in:
Dominik Moritz Roth 2023-07-12 22:32:35 +02:00
parent ee39fab49a
commit fd1d96eea3
2 changed files with 20 additions and 2 deletions

View File

@ -146,3 +146,20 @@ class Harmonic_Perlin_Noise():
self.noises = []
for octave, amplitude in enumerate(self.octaves):
self.noises += [Perlin_Noise(known_shape=self.known_shape, scale=self.scale, octave=(octave+1))]
class Dirty_Perlin_Noise():
def __init__(self, known_shape=None, scale=0.1, dirty_ratio=1/3):
self.known_shape = known_shape
self.scale = scale
self.dirty_ratio = dirty_ratio
self.reset()
def __call__(self, shape=None):
if shape == None:
shape = self.known_shape
return self.perlin(shape)*(1-self.dirty_ratio) + self.white(shape)*self.dirty_ratio
def reset(self):
self.perlin = Perlin_Noise(known_shape=self.known_shape, scale=self.scale, octave=1)
self.white = White_Noise(known_shape=self.known_shape)

View File

@ -51,11 +51,12 @@ class Avaible_Noise_Funcs(Enum):
COLOR = 2
PERLIN = 3
HARMONICPERLIN = 4
SDE = 5
DIRTYPERLIN = 5
SDE = 6
def get_func(self):
# stil aaaaaaaa
return [noise.White_Noise, noise.Pink_Noise, noise.Colored_Noise, noise.Perlin_Noise, noise.Harmonic_Perlin_Noise, noise.SDE_Noise][self.value]
return [noise.White_Noise, noise.Pink_Noise, noise.Colored_Noise, noise.Perlin_Noise, noise.Harmonic_Perlin_Noise, noise.Dirty_Perlin_Noise, noise.SDE_Noise][self.value]
def cast_to_enum(inp, Class):