Skip to content

Commit

Permalink
swap out noise w vnoise
Browse files Browse the repository at this point in the history
  • Loading branch information
Jack Parmer authored and Jack Parmer committed Jun 18, 2024
1 parent 56e0a79 commit 164dbb7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ version = "0.0.1"
readme = "README.md"
requires-python = ">=3.7"
dependencies = [
"noise",
"vnoise",
"numpy",
"pillow",
"matplotlib"
Expand Down
7 changes: 3 additions & 4 deletions src/voxel_world.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import io
import matplotlib.pyplot as plt
from IPython.display import display, Image as IPImage
from noise import pnoise3
import vnoise

def calculate_ambient_occlusion(world, size, x, y, z):
directions = [
Expand Down Expand Up @@ -38,10 +38,9 @@ def __init__(self, noise_type='perlin', scale=10.0, octaves=4, persistence=0.5,
self.lacunarity = lacunarity

def generate_noise(self, x, y, z):
noise = vnoise.Noise()
if self.noise_type == 'perlin':
return pnoise3(x / self.scale, y / self.scale, z / self.scale, octaves=self.octaves, persistence=self.persistence, lacunarity=self.lacunarity)
elif self.noise_type == 'simplex':
return snoise3(x / self.scale, y / self.scale, z / self.scale, octaves=self.octaves, persistence=self.persistence, lacunarity=self.lacunarity)
return noise.noise3(x / self.scale, y / self.scale, z / self.scale, octaves=self.octaves, persistence=self.persistence, lacunarity=self.lacunarity)
else:
raise ValueError("Unsupported noise type")

Expand Down

0 comments on commit 164dbb7

Please sign in to comment.