noise functionstheshark/courses/cs354/... · generating smooth noise 1. create grid of random...

35
Noise Functions

Upload: others

Post on 20-Jul-2020

3 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Noise Functionstheshark/courses/cs354/... · Generating Smooth Noise 1. Create grid of random gradient vectors 2. Compute points within grid using nearest nodes 3. Interpolate between

Noise Functions

Page 2: Noise Functionstheshark/courses/cs354/... · Generating Smooth Noise 1. Create grid of random gradient vectors 2. Compute points within grid using nearest nodes 3. Interpolate between

Recall: Texture Mapping

Page 3: Noise Functionstheshark/courses/cs354/... · Generating Smooth Noise 1. Create grid of random gradient vectors 2. Compute points within grid using nearest nodes 3. Interpolate between

Procedural Texture

Main idea: determine color at (u,v) using mathematical function

• no need for art assets• computed on the fly: no memory cost• can generate infinite amounts of data

Page 4: Noise Functionstheshark/courses/cs354/... · Generating Smooth Noise 1. Create grid of random gradient vectors 2. Compute points within grid using nearest nodes 3. Interpolate between

Checkerboard

Page 5: Noise Functionstheshark/courses/cs354/... · Generating Smooth Noise 1. Create grid of random gradient vectors 2. Compute points within grid using nearest nodes 3. Interpolate between

Stripes

Page 6: Noise Functionstheshark/courses/cs354/... · Generating Smooth Noise 1. Create grid of random gradient vectors 2. Compute points within grid using nearest nodes 3. Interpolate between

Stripes

Page 7: Noise Functionstheshark/courses/cs354/... · Generating Smooth Noise 1. Create grid of random gradient vectors 2. Compute points within grid using nearest nodes 3. Interpolate between

What’s Missing?

Procedural textures provide some visual interest, but how can we make them look better?

Page 8: Noise Functionstheshark/courses/cs354/... · Generating Smooth Noise 1. Create grid of random gradient vectors 2. Compute points within grid using nearest nodes 3. Interpolate between

Adding Noise

Problem: procedural textures are too regular• Looks “fake” (i.e. inorganic)

Real textures have noise

What is noise?

Page 9: Noise Functionstheshark/courses/cs354/... · Generating Smooth Noise 1. Create grid of random gradient vectors 2. Compute points within grid using nearest nodes 3. Interpolate between

Noise

Random (stochastic) fluctuations in an expected signal• Different concentrations of energy

create different patterns

Page 10: Noise Functionstheshark/courses/cs354/... · Generating Smooth Noise 1. Create grid of random gradient vectors 2. Compute points within grid using nearest nodes 3. Interpolate between

White Noise

White noise problems: • isn’t smooth • isn’t correlated

Page 11: Noise Functionstheshark/courses/cs354/... · Generating Smooth Noise 1. Create grid of random gradient vectors 2. Compute points within grid using nearest nodes 3. Interpolate between

Perlin Noise

Insight: A single noise function is unstructured but a combination of noise functions has structure

Page 12: Noise Functionstheshark/courses/cs354/... · Generating Smooth Noise 1. Create grid of random gradient vectors 2. Compute points within grid using nearest nodes 3. Interpolate between

Generating Smooth Noise1. Create grid of random gradient vectors2. Compute points within grid using nearest

nodes3. Interpolate between node values to form

continuous function4. Combine smooth noise function with other

smooth noise functions at different octaves

Page 13: Noise Functionstheshark/courses/cs354/... · Generating Smooth Noise 1. Create grid of random gradient vectors 2. Compute points within grid using nearest nodes 3. Interpolate between

Noise Octaves

An octave represents a noise function with a particular frequency-amplitude

Page 14: Noise Functionstheshark/courses/cs354/... · Generating Smooth Noise 1. Create grid of random gradient vectors 2. Compute points within grid using nearest nodes 3. Interpolate between

Noise Octaves

Can combine multiple octaves to get better looking results via Perlin noise

Page 15: Noise Functionstheshark/courses/cs354/... · Generating Smooth Noise 1. Create grid of random gradient vectors 2. Compute points within grid using nearest nodes 3. Interpolate between

Perlin Noise Applications

Perlin noise applied to procedural function…

Page 16: Noise Functionstheshark/courses/cs354/... · Generating Smooth Noise 1. Create grid of random gradient vectors 2. Compute points within grid using nearest nodes 3. Interpolate between

Manipulating Perlin Noise• Control over:

• Amplitude• Frequency• Number of octaves• Persistence

(influence of amplitude on each successive octave)

• Parametrizable for artist controls

Increased amplitude

Increased frequency

Page 17: Noise Functionstheshark/courses/cs354/... · Generating Smooth Noise 1. Create grid of random gradient vectors 2. Compute points within grid using nearest nodes 3. Interpolate between

Perlin Noise Examples

Page 18: Noise Functionstheshark/courses/cs354/... · Generating Smooth Noise 1. Create grid of random gradient vectors 2. Compute points within grid using nearest nodes 3. Interpolate between

Blending with Perlin Noise

Perlin Noise provides “organic” transition between textures by interpolating based on function value

http://devmag.org.za/2009/04/25/perlin-noise/

Page 19: Noise Functionstheshark/courses/cs354/... · Generating Smooth Noise 1. Create grid of random gradient vectors 2. Compute points within grid using nearest nodes 3. Interpolate between

Animating with Perlin Noise

Generate Perlin noise in 3D and animate 2D frames using this 3D texture

Or interpolate between Perlin noise functions to create smooth transitions over time

Page 20: Noise Functionstheshark/courses/cs354/... · Generating Smooth Noise 1. Create grid of random gradient vectors 2. Compute points within grid using nearest nodes 3. Interpolate between

Simplex NoiseSo actually use Simplex noise instead of Perlin

noise…

• Fewer directional artifacts• More computationally efficient• Also by Perlin• OpenSimplex is open source version of algorithm

(many other implementations as well!)

Page 21: Noise Functionstheshark/courses/cs354/... · Generating Smooth Noise 1. Create grid of random gradient vectors 2. Compute points within grid using nearest nodes 3. Interpolate between

Example: Minecraft

Page 22: Noise Functionstheshark/courses/cs354/... · Generating Smooth Noise 1. Create grid of random gradient vectors 2. Compute points within grid using nearest nodes 3. Interpolate between

Minecraft Landscape

Key features:• Discrete (made of blocks / voxels)• Random – no repeated features• Extends indefinitely• Persistent

Page 23: Noise Functionstheshark/courses/cs354/... · Generating Smooth Noise 1. Create grid of random gradient vectors 2. Compute points within grid using nearest nodes 3. Interpolate between

Minecraft Landscape

Making a small piece of landscape easy:1. Generate Perlin noise patch

• One pixel per block in (x,y) directions

2. Clamp heights to discrete steps

Page 24: Noise Functionstheshark/courses/cs354/... · Generating Smooth Noise 1. Create grid of random gradient vectors 2. Compute points within grid using nearest nodes 3. Interpolate between

Problems…

How to handle seams?

How to handle persistence?

Page 25: Noise Functionstheshark/courses/cs354/... · Generating Smooth Noise 1. Create grid of random gradient vectors 2. Compute points within grid using nearest nodes 3. Interpolate between

Handling Seams

Interpolate with neighbor tiles at each level…

…perhaps using Perlin noise!

Page 26: Noise Functionstheshark/courses/cs354/... · Generating Smooth Noise 1. Create grid of random gradient vectors 2. Compute points within grid using nearest nodes 3. Interpolate between

Handling Persistence

• World is made of tiles

• Each tile has a deterministic seed

• Must keep track of user activity with a change log

Page 27: Noise Functionstheshark/courses/cs354/... · Generating Smooth Noise 1. Create grid of random gradient vectors 2. Compute points within grid using nearest nodes 3. Interpolate between

Same Idea in No Man’s Sky…

Page 28: Noise Functionstheshark/courses/cs354/... · Generating Smooth Noise 1. Create grid of random gradient vectors 2. Compute points within grid using nearest nodes 3. Interpolate between

Memory Efficient!Tiles can be swapped in and out as needed

Keep an nxn buffer of tiles loaded around the player (same idea as Zelda, Megaman, etc on the NES)

Doesn’t solve popping (must implement some form of LOD)

Page 29: Noise Functionstheshark/courses/cs354/... · Generating Smooth Noise 1. Create grid of random gradient vectors 2. Compute points within grid using nearest nodes 3. Interpolate between

Perlin Noise and Voronoi• Possible to combine Perlin noise with other

algorithms!• Voronoi diagrams partition planes based on

distance to provided points• Commonly used together for terrain generation

Discuss: How can we generate terrain using Voronoi partitions? How do we combine this with a noise function?

Page 30: Noise Functionstheshark/courses/cs354/... · Generating Smooth Noise 1. Create grid of random gradient vectors 2. Compute points within grid using nearest nodes 3. Interpolate between

Voronoi SamplingVoronoi samples represent biome qualities:

• Altitude• Latitude• Rainfall

Generate biomes from samples then add noise between borders• Noise represents biome weight or something

similar

Page 31: Noise Functionstheshark/courses/cs354/... · Generating Smooth Noise 1. Create grid of random gradient vectors 2. Compute points within grid using nearest nodes 3. Interpolate between

Going Further…

Simulation can be applied via hydraulic erosion, temperature, tectonics, flora and fauna etc

Can be as simple or as complex as desired (within system limitations!)

Page 32: Noise Functionstheshark/courses/cs354/... · Generating Smooth Noise 1. Create grid of random gradient vectors 2. Compute points within grid using nearest nodes 3. Interpolate between

Perlin Worms“Worms” have segments:

• Segments always connected• Segments oriented based on noise function

Create “tunnels” in world to simulate caves

Guarantees on connectivity between tunnels (unlike standard 3D Perlin noise)

Page 33: Noise Functionstheshark/courses/cs354/... · Generating Smooth Noise 1. Create grid of random gradient vectors 2. Compute points within grid using nearest nodes 3. Interpolate between

Perlin Worms

https://www.youtube.com/watch?v=aQ-bomm3lEc

Page 35: Noise Functionstheshark/courses/cs354/... · Generating Smooth Noise 1. Create grid of random gradient vectors 2. Compute points within grid using nearest nodes 3. Interpolate between

Additional Readinghttp://mrl.nyu.edu/~perlin/paper445.pdf

http://flafla2.github.io/2014/08/09/perlinnoise.html

http://lodev.org/cgtutor/randomnoise.html

https://www.smashingmagazine.com/2016/03/procedural-content-generation-introduction/