alecjacobson / computer-graphics-shader-pipeline

Computer Graphics Assignment about the Shader Pipeline
14 stars 24 forks source link

Perlin noise odd output #43

Open Marina-t opened 5 years ago

Marina-t commented 5 years ago

My perlin values don't look very random perlin and I am not sure why. Any one encountered a similar issue?

Desmeister commented 5 years ago

I had a similar issue: Notice that within each of the cells, it's working properly.

For me, it was an off-by-one error. When I casted negative floats to an int, at actually rounds up since it's still just discarding the fractional part.

Marina-t commented 5 years ago

thanks @Desmeister I am not sure I understand what is the "off-by-one" error, though. For me the fix was to use the smooth function from the book which does add a "1" at the end but doesn't completely follow the description in the file, is that what you are referring to?

Desmeister commented 5 years ago

Ah no it was a separate problem where int(x) != floor(x) for negative x.

However, I did also run into the problem with the smooth function where multiplying it by -1 and then adding 1 fixes it. That seems to be the difference in inclusion of the absolute value brackets, which aren't present on the wikipedia implementation.