Open yunhaom94 opened 4 years ago
Here is the same Perlin noise I wrote in Python, just using 2D input instead of 3D.
Check that the interpolation parameter passed to smooth_step
lies between 0 and 1. You should verify that the basic case (no input scaling, no function composition) looks smooth before trying different effects.
I tried vec3(sin(sphere_fs_in.x), sin(sphere_fs_in.x), sin(sphere_fs_in.z))
as input, it looked like above
Is this your input to Perlin noise? You shouldn't be making the input periodic like this because it makes it tricky to ensure that the output is smooth across grid cubes. If you want to use sin and cos to create turbulence, you apply it to the output of Perlin noise.
This is what I got from using sphere's 3d coordinate as direct input into Perlin noise, sin() the result got similar effect
These discontinuities are caused by your input parameter to smooth_step
not reaching 0 and 1 at the edges of the cubes. The simplest way to ensure this is that you are using unit cubes; then, you can simply use the fractional component to pass to smooth_step
.
I generated the unit cube by taking floor and ceiling of the point, and I passed in the fractional part of the vertices only, it does look smoother, however there is still some strange misalignment?
The pattern looks like it's oscillating very quickly inside a cube, which shouldn't happen. Make sure that you are implementing trilinear interpolation correctly. To simplify debugging, try using hardcoded colour values at each integer point in [-1,1]x[-1,1]x[-1,1] and use the fraction directly, so you can tell what the interpolation should be doing. Once you've verified this works, you can debug smooth_step
and then the interpolation of random values.
Thanks, looks like my cube definition was in incorrect order. After I rearrange the corners it seems to be working now.
Things I have tried so far:
Yet I'm still getting this kind of stepped colour output?