Difference between revisions of "Perlin Noise"

From Free Pascal wiki
Jump to navigationJump to search
(→‎Subversion: moved noise to examples)
 
(8 intermediate revisions by 6 users not shown)
Line 1: Line 1:
 +
{{Perlin Noise}}
 +
 
This page is the start of a tutorial about using Perlin Noise on LCL applications to generate natural looking images. It will cover both basic theory and real usage examples, with a focus on compilable examples.
 
This page is the start of a tutorial about using Perlin Noise on LCL applications to generate natural looking images. It will cover both basic theory and real usage examples, with a focus on compilable examples.
  
Line 47: Line 49:
 
* perlin1d.dpr
 
* perlin1d.dpr
 
* noise.pas
 
* noise.pas
 +
 +
==Use Perlin noise to create textures==
 +
 +
It is possible to create tilable textures of stone, water, wood... with Perlin noise.
 +
 +
Here is a tutorial on how to do this: [[BGRABitmap tutorial 8]]
  
 
==Subversion==
 
==Subversion==
Line 52: Line 60:
 
You can download the source code for the examples and the library using this command:
 
You can download the source code for the examples and the library using this command:
  
svn co https://lazarus-ccr.svn.sourceforge.net/svnroot/lazarus-ccr/examples/noise noise
+
svn co https://svn.code.sf.net/p/lazarus-ccr/svn/examples/noise noise
  
 
==External Links==
 
==External Links==
  
* [http://freespace.virgin.net/hugo.elias/models/m_perlin.htm Article] with the theory of Perlin Noise.
+
* [http://web.archive.org/web/20160325134143/http://freespace.virgin.net/hugo.elias/models/m_perlin.htm Article] with the theory of Perlin Noise.
 +
 
 +
[[Category:Tutorials]]
 +
[[Category:Graphics]]
 +
[[Category:Game Development]]
 +
[[Category:Lazarus-CCR]]
 +
[[Category:SciTech]]

Latest revision as of 07:06, 11 April 2019

English (en) français (fr) 中文(中国大陆)‎ (zh_CN)

This page is the start of a tutorial about using Perlin Noise on LCL applications to generate natural looking images. It will cover both basic theory and real usage examples, with a focus on compilable examples.

Perlin Noise was invented by Ken Perlin to generate textures for a movie called Tron. Today it is widely used on movies and video games to produce natural looking smoke, landscapes, clouds and any texture including marble, irregular glass, etc.

Getting Started

Perlin Noise is based on the idea of fractals, that things in nature show different degrees of change. On a rocky mountain landscape for example when can see changes with a very big amplitude, which are the mountains themselves. Smaller changes represent irregularities on those mountains and even smaller ones represent rocks.

mountain landscape.png


First Example

This application demonstrates a simple noise function with the following properties:

  • Only 1 harmonic present
  • Amplitude of 250 pixels
  • Wavelength of 20 pixels
  • Frequency of 0.05
  • You can use a combo box to choose between Linear, Cossine and Cubic interpolation

Noise1D.png

Files:

  • noise1d.lpi
  • noise1d.dpr
  • noise.pas

Persistence Example

This application demonstrates how to sum many noise functions to get a perlin noise function. It has the following properties:

  • 3 harmonics present
  • Amplitudes of 250, 125 and 62 pixels
  • Wavelength of 20, 10, and 5 pixels
  • Frequency of 0.05, 0.1, 0.2
  • You can use a combo box to choose between Linear, Cossine and Cubic interpolation

Perlin1D.png

Files:

  • perlin1d.lpi
  • perlin1d.dpr
  • noise.pas

Use Perlin noise to create textures

It is possible to create tilable textures of stone, water, wood... with Perlin noise.

Here is a tutorial on how to do this: BGRABitmap tutorial 8

Subversion

You can download the source code for the examples and the library using this command:

svn co https://svn.code.sf.net/p/lazarus-ccr/svn/examples/noise noise

External Links

  • Article with the theory of Perlin Noise.