lmas / opensimplex

This repo has been migrated to https://code.larus.se/lmas/opensimplex
MIT License
241 stars 29 forks source link

How to replicate tests using noiseXarray? #34

Closed jpvt closed 2 years ago

jpvt commented 2 years ago

How do I replicate the 3d noise test using the noise3array function?

I'm trying to do this, but the result is not the same.

rng = np.random.default_rng(seed=12)
ix, iy, iz = rng.random(X), rng.random(Y), rng.random(Z)
noise = simplex.noise3array(ix, iy, iz)
noise = np.int32((noise + 1) * 128)
lmas commented 2 years ago

Hi, what result were you expecting and what did you get instead? What python version and what opensimplex version are you running?

And your code isn't complete so I can't replicate your problem. Instead I ran this:

import numpy as np
import opensimplex as simplex

rng = np.random.default_rng(seed=12)
ix, iy, iz = rng.random(11), rng.random(7), rng.random(5)
noise = simplex.noise3array(ix, iy, iz)
print(noise)

Which produced (only showing first line):

[[[ 0.53398093  0.27829111  0.52068324  0.51807738  0.54515908

Which matches the type of output from the tests:

[[[ 0.22979216  0.30807644  0.20983908  0.19436407  0.10017948
jpvt commented 2 years ago

Problem solved! I was able to replicate the code by doing the following:

DIMS = 50
FEATURE_SIZE = 8
def generate_simplex_array():
    rng = np.random.default_rng(seed=12)
    ix, iy, iz = np.arange(DIMS)/FEATURE_SIZE, np.arange(DIMS)/FEATURE_SIZE, np.arange(DIMS)/FEATURE_SIZE
    noise = simplex.noise3array(ix, iy, iz)
    noise = (noise+1)*128

    return noise