Introduction To Noise Functions

Definitions

## Sin Wave | |

## Noise Wave |

Creating the Perlin Noise Function

Persistence

frequency = 2^{i}amplitude = persistence^{i}

Frequency | 1 | 2 | 4 | 8 | 16 | 32 | ||||||||

Persistence = 1/4 | + | + | + | + | + | = | ||||||||

Amplitude: | 1 | ^{1}/_{4} | ^{1}/_{16} | ^{1}/_{64} | ^{1}/_{256} | ^{1}/_{1024} | result | |||||||

Persistence = 1/2 | + | + | + | + | + | = | ||||||||

Amplitude: | 1 | ^{1}/_{2} | ^{1}/_{4} | ^{1}/_{8} | ^{1}/_{16} | ^{1}/_{32} | result | |||||||

Persistence = 1 / root2 | + | + | + | + | + | = | ||||||||

Amplitude: | 1 | ^{1}/_{1.414} | ^{1}/_{2} | ^{1}/_{2.828} | ^{1}/_{4} | ^{1}/_{5.656} | result | |||||||

Persistence = 1 | + | + | + | + | + | = | ||||||||

Amplitude: | 1 | 1 | 1 | 1 | 1 | 1 | result |

Octaves

Making your noise functions

function IntNoise(32-bit integer: x) x = (x<<13) ^ x; return ( 1.0 - ( (x * (x * x * 15731 + 789221) + 1376312589) & 7fffffff) / 1073741824.0); end IntNoise function |

Interpolation

Linear Interpolation: |

function |

Cosine Interpolation:

function |

Cubic Interpolation:

function |

Smoothed Noise

function |

2-dimensional Smooth Noise

function |

Putting it all together

1-dimensional Perlin Noise Pseudo code

function |

2-dimensional Perlin Noise Pseudocode

function |

Applications of Perlin Noise

__1 dimensional__

See: Creating Informal Looking Interfaces.

Controlling virtual beings: | |

Drawing sketched lines: |

__2 dimensional__

Landscapes: | |

Clouds: | |

Generating Textures: |

__3 dimensional__

3D Clouds: | |

Animated Clouds: | |

Solid Textures: |

__4 dimensional__

Animated 3D Textures and Clouds: |

Copyright Matt Fairclough 1998 | The land, clouds and water in this picture were all mathematically generated with Perlin Noise, and rendered with Terragen. |

The clouds in this demo are animated with 3D perlin Noise. The algorithm had to be modified slightly to be able to produce Perlin Noise in real time. See the Clouds Article for more info on how this was done. |

Generating Textures with Perlin Noise

The following textures were made with 3D Perlin Noise

texture = cosine( x + perlin(x,y,z) )

g = perlin(x,y,z) * 20 grain = g - int(g)

bumps = perlin(x*50, y*50, z*20) if bumps < .5 then bumps = 0 else bumps = 1t

]]>

则平面上一点(x,y,z)与(x0,y0,z0)的向量必然与法线垂直。因此得出平面的点法式方程:

A(x-X0) + B(y-y0) + C(z-z0) = 0

将判断点坐标代入方程 满足条件 则点在平面上。

另:若方程坐标多项式>0,则在平面正面（法向量方向），反之在背面

注释：

两向量a * b 的长度为：

||a || * ||b|| * sin(thta) //thta为a与b的夹角

这样 A(x-X0) + B(y-y0) + C(z-z0) = 0 a,b垂直

A(x-X0) + B(y-y0) + C(z-z0) > 0 a在b方向

A(x-X0) + B(y-y0) + C(z-z0) < 0 a不在b方向

]]>

前几天来了个弟弟，要学3D，所以也和他一起写了写渲染部分。

昨天吧，他写了一天的顶点渲染（带索引缓冲），结果回家问我怎么有时候渲染是一个平面上的4个点是渲染成的矩形，有时候渲染成的是三角形。我也不了解，就帮他看了看书，最后发现在没有开启双面渲染的情况下，你的眼点只有在三角面的正向的时候才能看见渲染的三角形，然而什么是正面就是这个问题的核心了。

在定义渲染顶点stream的时候,渲染出图象的正向遵守左手法则，大拇指为三角面的正向，弟弟之所以只渲染出了半个矩形是因为另外半个是背朝屏幕的，所以看不见。

]]>