Ask coding questions

← Back to all posts
Java - noise giving unexpected results
TMH97 (23)

Repl link

I am attempting to create a 2d grid of more useful noise than static. I have it close to how I want it, but it is not quite right.

So far, the noise generator chooses a number of random points and assigns it a random value between 0-1,and for each other point finds the three closest chosen points and attempts to give it an average value, weighted by distance to the point.

I feel the issue is here, as google is quite barren of answers for how to do this right.
When you get a value from the noise, it should return a double between 0-1, but I am regularly getting values greater than 1.

Right now, I am displaying everything with Java Swing to help visualize results. Just looking at it, there seems to be sharp changes in colors at points and I just cant figure out what I am doing wrong.

Commentshotnewtop
a5rocks (519)

Do you want something like Perlin noise? (just recommendation of what to Google)

BTW, if that's not what you want, could you give us a couple values of what it should be? I would like some more description.

TMH97 (23)

@a5rocks Probably, if I am being honest. I actually tried implementing Perlin noise a while back, and failed miserably. This was my attempt at making a noise generator using concepts I could actually follow.

And looking at it, I got so close too. I will now be greatly disappointed if I cant figure it out.

a5rocks (519)

@TMH97 Oof, well I suck at algorithms, so I can't really help. gl though