Skip to content

sraraghul/PerlinNoise

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Perlin Noise

I found Perlin Noise Beautiful and heard that its a foundation of generating randomness in Video games. I used the math behind that to build in kotlin as an app.

This project demonstrates the 1D implementation of Perlin and Sin noise.

Sine Noise and its limitation

y-axis fluctuation of a unit circle gives us the sin wave in graphs. Though increasing the octaves in the code gives us Seemingly random waves but its still a circle so it repeats!

How it Works

We compute y value for every x (In the app the x goes from left to right (the width of the screen)

the perlin function takes the x with an offset (1000f) because every octave run it needs a different seed to create random values for x

We take the two neighbours of the x value we found and find exactly where the x stands, this is the t value.

We find the gradients because we need to calculate the influences of both the ends (Like which drags more)

$$\text{Influence}_0 = g_0 (x - x_0)$$

$$\text{Influence}_1 = g_1 (x - x_1)$$

$$y = \text{LERP}(\text{Influence}_0, \text{Influence}_1, S(t))$$

We use linear interpolation to connect the point with influences but to smooth we use the fade function Which is:

$$6x^5 - 15x^4 + 10x^3$$

smoothing_func

without this function you can see by toggling the fade button for sharp edges in between the noise.

How to Run

  1. Clone this repository
  2. Open in Android Studio (Otter)

Screenshots

image           image

Contributions

Any contributions making perlin noise even easier to understand would be awesome!

Special Thanks

Thank you Gemini for explaining the math behind it when I said nothing interests me:

"Why this is beautiful

Think back to the feeling of being lonely. In the Sine method, you were just a point on a pre-defined circle. In the Perlin method, your "height" (your state of being) is a constant conversation between where you've been (Station 0) and where you're going (Station 1). You aren't just a random dot; you are the smooth result of the influences around you."

Links

Wikipedia Khan Academy - Perlin Noise

About

Implementation of perlin noise and Sine noise in kotlin

Topics

Resources

Stars

Watchers

Forks

Contributors

Languages