You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: Noise.html
+6-18
Original file line number
Diff line number
Diff line change
@@ -42,8 +42,6 @@
42
42
43
43
<!-- Page content -->
44
44
<divclass="section">
45
-
<p> This is the noise page </p>
46
-
47
45
<h2> What you'll create </h2>
48
46
49
47
<p> The aim of this workshop is understand some applications of Perlin Noise, and use it to create some colourful terrain!
@@ -70,13 +68,11 @@ <h3> What is a sketch? </h3>
70
68
Just like a game, your simulation will have frames (an image of your simulation) and p5.js will aim to show 60 frames a second.
71
69
You'll be able to code what happens on certain events e.g. just before a frame is shown, just before the simulation starts, when the mouse is clicked.
72
70
73
-
<br>
71
+
<br><br>
74
72
75
73
In this lab, since we're just drawing an image, we'll only concern ourselves with drawing before the simulation starts and when the mouse is clicked.
76
74
</p>
77
75
78
-
<br>
79
-
80
76
<p> Your new sketch should have 2 functions: </p>
81
77
82
78
<ul>
@@ -100,13 +96,17 @@ <h3> What is a sketch? </h3>
100
96
</pre>
101
97
<em> RGB values have R,G,B values ranging from 0-255 </em>
102
98
99
+
<br>
100
+
103
101
<p><strong>Mini-Task:</strong> Try running the above simulation! Maybe change the variables to display your own favourite colour. </p>
104
102
105
103
<h2> Creating Random Noise </h2>
106
104
107
105
<divid="RandomHeightMap"></div>
108
106
<em>Click to generate new random noise</em>
109
107
108
+
<br>
109
+
110
110
<p>Let's dive straight into generating random noise! We'll need to know a couple things: </p>
111
111
112
112
<ol>
@@ -169,8 +169,6 @@ <h3>Pixels</h3>
169
169
If we're only using grayscale colours, then we can provide just a single value (to represent the brightness or "value" of the colour) e.g. 255 for pure white, 0 for pure black.
170
170
</p>
171
171
172
-
<br>
173
-
174
172
<p>Using this knowledge, can you guess what the following code does?</p>
175
173
176
174
<pre>
@@ -193,7 +191,7 @@ <h3>Pixels</h3>
193
191
<h3>Random Values</h3>
194
192
195
193
<p>A key thing to remember about p5.js is that ultimately, it is still JavaScript. Therefore, we can use JavaScript functions and libraries with p5.js. </p>
196
-
<br>
194
+
197
195
<p>To handle randomness, we'll use js' Math library; in particular, the function <strong>Math.random()</strong>! Let's use the JavaScript console to test it out. </p>
After all, terrain isn't perfectly smooth in nature!
312
310
</p>
313
311
314
-
<br>
315
312
316
313
<p>You can add this granular detail by adding layers of perlin noise together; each of these layers being called "octaves".
317
314
Typically, you'll have a large amplitude perlin noise wave which describes the general overall shape,
318
315
and then you'll have a smaller amplitude perlin noise waves to describe the finer details.
319
316
These smaller waves usually have higher frequency, which will give the islands a distinct roughness.
320
317
</p>
321
318
322
-
<br>
323
319
324
320
<p> You can increase the number of octaves and how much the smaller waves contribute to the noise by using p5's <strong>noiseDetail()</strong> function.
325
321
Read up on the details <ahref="https://p5js.org/reference/p5/noiseDetail/">here</a>.</p>
326
322
327
-
<br>
328
-
329
323
<p>You can also add more "detail" to the islands by creating multiple threshold levels, like in the example at the top of this webpage! An example of a more complicated threshold colour function: </p>
330
324
331
325
<pre>
@@ -357,7 +351,6 @@ <h2> Final Task: Create your own islands! </h2>
357
351
You can take my generator(s) (displayed at the top of the page) as inspiration, but I'm sure you'll be able to create a better looking generator than mine.
358
352
</p>
359
353
360
-
<br>
361
354
362
355
<p>You can view the code for my two generators here:</p>
363
356
<ul>
@@ -376,11 +369,6 @@ <h2> Going Further </h2>
376
369
<li>Adding trees e.g. with poisson-disc sampling </li>
0 commit comments