Perlin noise- Unit 6

We got a challenge from Chris to do with perlin noise, he sent us an code to play around with and to change it and make it different. The first code we had to make white noise look TV static but when we run the code it’s just loads of squares.

Untitled

The code.
int rectSize=6;
void setup() {
  size(300,300);
}
void draw(){
    for (int x=0; x<100; x++)
    {
        for (int y=0; y < 100; y++)
        {
            rect(x*rectSize,y*rectSize,rectSize,rectSize);
        }
    }
}
To make the static effect I added noStroke(); and added fill(random(0,255)); now this is what it looks like after adding some codes.
2
It does flicker like TV static when you run the code.
After completing that Chris sent us another code which is a smoke effect.
int rectSize=3;
float noiseScale = 0.01;
float noiseValue;
void setup() {
  size(300,300);
  noStroke();
}
void draw(){
    for (int x=0; x<100; x++)
    {
        for (int y=0; y < 100; y++)
        {
            noiseValue = noise(x*noiseScale, y*noiseScale,(frameCount*noiseScale));
            fill(noiseValue*255); // black and white
            rect(x*rectSize,y*rectSize,rectSize,rectSize);
        }
    }
}
3
Now we had to make the black and white smoke look like fire, so I went onto Photoshop and got the fire colour from the RGB and after putting the RGB numbers in this is what the smoke effect looks like now.
4
It was more red then fire but we just had to find out how to change the colours and understand it.

4 computer games (or films) that use procedural generation.

Banished – 2014 – Developers – Shining Rock Software 

Banished logo.jpg

Perlin noise has been used because there’s rain and snow falling, they’ve used perlin noise and turned it into rain and snow and put it over the top of the game.

snow.png

Here’s a video so you can see: https://www.youtube.com/watch?v=Ls8FBFFjMxk

Rogue Legacy – 2013 – Developers – Cellar Door Games

Rogue Legacy logo.png

Perlin noise has been used because there’s rain falling, they’ve used perlin noise and turned it into rain and put it over the top of the game, like an overlay.

rain.png

Here’s the video so you can go and watch and get an idea: https://www.youtube.com/watch?v=B5jL25HgSIs

Spelunky – 2008 – Developers –Mossmouth

Spelunky.jpg

They’ve used perlin noise in this game because in the game there’s a pit of fire and its moving up and down, it looks just like the code below that I done for the wave but with more coding and detailed.

fire

Here’s the video link so you can go and see what the fire pit is like compared to the wave code I done, link: https://www.youtube.com/watch?v=EzfDZePfxJE

Stardew Valley – 2011 – Developers –ConcernedApe

Logo of Stardew Valley.png

This has perlin noise and has pretty much the same as the other games, this game has an overlay of snow.

snoww.png

Here’s the video so you can go and see the snow, it’s towards the end of the video, link: https://www.youtube.com/watch?v=QYxXCmWCOYU

 

One of the task was to make like a wave with the perlin noise, the picture below is the wave code which I found from https://processing.org/examples/noisewave.html and we had to change the colours and turn the wave into like white noise where it flickers and this is my result after doing some research and talking to Chris.

aaa

Code

float yoff = 0.0;        // 2nd dimension of perlin noise

void setup() {
  size(640, 360);
}

void draw() {
  background(51);

  fill(255);
  // We are going to draw a polygon out of the wave points
  beginShape(); 
  
  float xoff = 0;       // Option #1: 2D Noise
  // float xoff = yoff; // Option #2: 1D Noise
  
  // Iterate over horizontal pixels
  for (float x = 0; x <= width; x += 10) {
    // Calculate a y value according to noise, map to 
    float y = map(noise(xoff, yoff), 0, 1, 200,300); // Option #1: 2D Noise
    // float y = map(noise(xoff), 0, 1, 200,300);    // Option #2: 1D Noise
    
    // Set the vertex
    vertex(x, y); 
    // Increment x dimension for noise
    xoff += 0.05;
  }
  // increment y dimension for noise
  yoff += 0.01;
  vertex(width, height);
  vertex(0, height);
  endShape(CLOSE);
}


This is my code after changing few parts of the code and this is 
what is looks like now.waveu#y

I saved the code and taken a screen shot of me saving the code. I named the code ‘wave_code’ in my ‘Perlin noise’ folder so I know it’s the code to do with the wave.

screen shot

 

Leave a comment

Blog at WordPress.com.

Up ↑

Design a site like this with WordPress.com
Get started