
Post by vorpal on Dec 9, 2018 0:48:43 GMT
I'm looking into Perlin noise, and something is unclear to me from the book. The book seems to imply that the call to a Perlin noise function returns three values: one each for x, y, and z; however, all the implementations I've seen only return a single value, including Perlin's original implementation: mrl.nyu.edu/~perlin/noiseWhat should I do with the single value returned with regards to the three coordinates? I'm not clear.



Post by Jamis on Dec 9, 2018 5:34:51 GMT
Yeah, I didn't explain that well in the book. I wonder if I have time to change any of that still...
Anyway, here's what is meant. If you have some point (x,y,z), you can use the Perlin noise function to return a value that corresponds to those coordinates. However, by transforming those coordinates in some way, you can generate additional numbers that can still be related back to the original point. In this case, we want to be able to jitter a vector or a point, so we need to be able to add or subtract something from each element of the vector or point. Something like this works fine:
# given some point that we want to jitter new_x = point.x + noise(point.x, point.y, point.z) * scale_value new_y = point.y + noise(point.x, point.y, point.z + 1) * scale_value new_z = point.z + noise(point.x, point.y, point.z + 2) * scale_value In other words, by incrementing z by 0, 1, or 2, we are able to generate values that are dependent on the coordinates of the given point. (The scale_value is used to scale the jitter to something more meaningful to the scale we're working at. It's specific value will depend on what you're trying to accomplish, but I often stick with something in the neighborhood of 0.01.)



Post by vorpal on Dec 9, 2018 6:04:08 GMT
Excellent. That's very helpful! I love the look of the effect in the book and I'm looking forward to implementing this tomorrow.
(I got through cylinders and cones today, finally.)



Post by bajena on May 12, 2020 7:03:28 GMT
Hey, I loved the "painty" effect that Jamis presented in his book, so I tried recreating it in my ray tracer. It seems that Perlin noise is being applied correctly, but I still can't make it look anything like in the book, no matter what set of params I pick. Here's my pattern_at_shape method: def pattern_at_shape(pattern, object, position) do scale = 0.3 pscale = 0.7 x = RTuple.x(position) * pscale y = RTuple.y(position) * pscale z = RTuple.z(position) * pscale
noisex = PerlinNoise.noise(x, y,z) * scale
noisey = PerlinNoise.noise(x, y, z + 1) * scale
noisez = PerlinNoise.noise(x, y, z + 2) * scale
npoint = RTuple.point(noisex, noisey, noisez) Pattern.pattern_at_shape(pattern.perturbed_pattern, object, position > RTuple.add(npoint)) end
and the result looks like this. Do you have any tips on what I could change here to make it a bit more "painty"? Thanks!


fremag
Junior Member
Posts: 64

Post by fremag on May 16, 2020 16:18:02 GMT
Hi, Have you tried with a lower value for scale (0.1) and a higher value for pscale (0.9) for instance ? Otherwise, have you tried to add octaves / frequency / persistence to your Perlin noise. Look at this page: flafla2.github.io/2014/08/09/perlinnoise.htmlThe code looks like this: public double OctavePerlin(double x, double y, double z, int octaves, double persistence) { double total = 0; double frequency = 1; double amplitude = 1; double maxValue = 0; // Used for normalizing result to 0.0  1.0 for(int i=0;i<octaves;i++) { total += perlin(x * frequency, y * frequency, z * frequency) * amplitude;
maxValue += amplitude;
amplitude *= persistence; frequency *= 2; }
return total/maxValue; }

