• No results found

GPU Shading and Rendering: Introduction & Graphics Hardware

N/A
N/A
Protected

Academic year: 2021

Share "GPU Shading and Rendering: Introduction & Graphics Hardware"

Copied!
161
0
0

Loading.... (view fulltext now)

Full text

(1)

Introduction & Graphics Hardware

Marc Olano

Computer Science and Electrical Engineering University of Maryland, Baltimore County

SIGGRAPH 2005

(2)

Schedule

Shading Technolgy

8:30 Intro/Hardware(Olano)

9:25 Compilers(Bleiweiss)

Shading Languages 10:30 GLSL(Olano)

10:55 Cg(Kilgard) 11:20 HLSL(Sander)

11:45 Sh(McCool)

GPU Rendering 1:45 Rendering

Algorithms(Hart) 2:35 GPU Production

Rendering(Gritz) Hardware Systems 3:45 ATI(Sander)

4:25 NVIDIA(Kilgard) 5:05 Panel Q&A(all)

(3)

Introdution

(4)

What is a GPU?

Graphics Processing Unit

Graphics accelerator

Parallel processing unit

We’re doing graphics, what is it good for?

Better real-time graphics

Faster non-real-time graphics

(5)

Graphics Processing Unit

Graphics accelerator

Parallel processing unit

We’re doing graphics, what is it good for?

Better real-time graphics

Faster non-real-time graphics

(6)

What is a GPU?

Graphics Processing Unit

Graphics accelerator

Parallel processing unit

We’re doing graphics, what is it good for?

Better real-time graphics

Faster non-real-time graphics

(7)

Graphics Processing Unit

Graphics accelerator

Parallel processing unit

We’re doing graphics, what is it good for?

Better real-time graphics

Faster non-real-time graphics

(8)

What is Shading?

What color are the pixels

Programmable

Flexible Appearance

Arbitrary computation

Procedural

Simple procedures

High-level language

(9)

What color are the pixels

Programmable

Flexible Appearance

Arbitrary computation

Procedural

Simple procedures

High-level language

(10)

What is Shading?

What color are the pixels

Programmable

Flexible Appearance

Arbitrary computation

Procedural

Simple procedures

High-level language

(11)

What color are the pixels

Programmable

Flexible Appearance

Arbitrary computation

Procedural

Simple procedures

High-level language

(12)

What is Shading?

What color are the pixels

Programmable

Flexible Appearance

Arbitrary computation

Procedural

Simple procedures

High-level language

(13)

What color are the pixels

Programmable

Flexible Appearance

Arbitrary computation

Procedural

Simple procedures

High-level language

(14)

What is Shading?

What color are the pixels

Programmable

Flexible Appearance

Arbitrary computation

Procedural

Simple procedures

High-level language

(15)

More realistic appearance

Bump mapping, Anisotropic, Precomputed radiance transfer, ...

Non-realistic appearance

Cartoon, Sketch, Illustration, ...

Animated appearance

Skinning, Water, Clouds, ...

Visualization

Data on surfaces, Volume rendering, ...

(16)

Some examples

More realistic appearance

Bump mapping, Anisotropic, Precomputed radiance transfer, ...

Non-realistic appearance

Cartoon, Sketch, Illustration, ...

Animated appearance

Skinning, Water, Clouds, ...

Visualization

Data on surfaces, Volume rendering, ...

(17)

More realistic appearance

Bump mapping, Anisotropic, Precomputed radiance transfer, ...

Non-realistic appearance

Cartoon, Sketch, Illustration, ...

Animated appearance

Skinning, Water, Clouds, ...

Visualization

Data on surfaces, Volume rendering, ...

(18)

Some examples

More realistic appearance

Bump mapping, Anisotropic, Precomputed radiance transfer, ...

Non-realistic appearance

Cartoon, Sketch, Illustration, ...

Animated appearance

Skinning, Water, Clouds, ...

Visualization

Data on surfaces, Volume rendering, ...

(19)

The rest of the problem!

In our case, using GPU for other than polygon rendering

Curved surfaces

Ray tracing

Point based rendering

...

(20)

What is Rendering?

The rest of the problem!

In our case, using GPU for other than polygon rendering

Curved surfaces

Ray tracing

Point based rendering

...

(21)

The rest of the problem!

In our case, using GPU for other than polygon rendering

Curved surfaces

Ray tracing

Point based rendering

...

(22)

Non-Real Time vs. Real-Time

Real-Time Non-Real-Time

Tens of frames per second Seconds to hours per frame Thousand instruction shaders Thousands line shaders Limited computation, texture,

memory, ...

“Unlimited” computation, texture, memory, ...

(23)

Real-Time Non-Real-Time

Tens of frames per second Seconds to hours per frame Thousand instruction shaders Thousands line shaders Limited computation, texture,

memory, ...

“Unlimited” computation, texture, memory, ...

(24)

Non-Real Time vs. Real-Time

Real-Time Non-Real-Time

Tens of frames per second Seconds to hours per frame Thousand instruction shaders Thousands line shaders Limited computation, texture,

memory, ...

“Unlimited” computation, texture, memory, ...

(25)

Real-Time Non-Real-Time

Tens of frames per second Seconds to hours per frame Thousand instruction shaders Thousands line shaders Limited computation, texture,

memory, ...

“Unlimited” computation, texture, memory, ...

(26)

How is this possible?

GPUs are programmable!

Per-vertex programs

Per-fragment programs

(27)

Pixel-Planes 5 [Rhoades et al., 1992]

PixelFlow/pfman [Olano and Lastra, 1998]

RTSL [Proudfoot et al., 2001]

Sh [McCool and Toit, 2004]

(BrookGPU) [Buck et al., 2004]

(28)

Research Languages

Pixel-Planes 5 [Rhoades et al., 1992]

PixelFlow/pfman [Olano and Lastra, 1998]

RTSL [Proudfoot et al., 2001]

Sh [McCool and Toit, 2004]

(BrookGPU) [Buck et al., 2004]

(29)

Pixel-Planes 5 [Rhoades et al., 1992]

PixelFlow/pfman [Olano and Lastra, 1998]

RTSL [Proudfoot et al., 2001]

Sh [McCool and Toit, 2004]

(BrookGPU) [Buck et al., 2004]

(30)

Research Languages

Pixel-Planes 5 [Rhoades et al., 1992]

PixelFlow/pfman [Olano and Lastra, 1998]

RTSL [Proudfoot et al., 2001]

Sh [McCool and Toit, 2004]

(BrookGPU) [Buck et al., 2004]

(31)

Pixel-Planes 5 [Rhoades et al., 1992]

PixelFlow/pfman [Olano and Lastra, 1998]

RTSL [Proudfoot et al., 2001]

Sh [McCool and Toit, 2004]

(BrookGPU) [Buck et al., 2004]

(32)

Commercial Languages

GL or DX low-level

OpenGL Shading Language

DirectX HLSL

NVIDIA Cg

(33)

GL or DX low-level

OpenGL Shading Language

DirectX HLSL

NVIDIA Cg

(34)

Commercial Languages

GL or DX low-level

OpenGL Shading Language

DirectX HLSL

NVIDIA Cg

(35)

GL or DX low-level

OpenGL Shading Language

DirectX HLSL

NVIDIA Cg

(36)

Ignoring Hardware Differences

Part II

Graphics Hardware

(37)

Outline

Ignoring Hardware Differences Simplified Models

RenderMan Hardware

(38)

Ignoring Hardware Differences

Machine Complexity

Graphics machines are complex

User does not want to know

How machine does what it does

Tons of machine-specific differences

Answer:

Simple model of machine

High-level language for procedures

Well-defined procedure input & output

System connects procedures

(39)

Machine Complexity

Graphics machines are complex

User does not want to know

How machine does what it does

Tons of machine-specific differences

Answer:

Simple model of machine

High-level language for procedures

Well-defined procedure input & output

System connects procedures

(40)

Ignoring Hardware Differences

Machine Complexity

Graphics machines are complex

User does not want to know

How machine does what it does

Tons of machine-specific differences

Answer:

Simple model of machine

High-level language for procedures

Well-defined procedure input & output

System connects procedures

(41)

Machine Complexity

Graphics machines are complex

User does not want to know

How machine does what it does

Tons of machine-specific differences

Answer:

Simple model of machine

High-level language for procedures

Well-defined procedure input & output

System connects procedures

(42)

Ignoring Hardware Differences

Machine Complexity

Graphics machines are complex

User does not want to know

How machine does what it does

Tons of machine-specific differences

Answer:

Simple model of machine

High-level language for procedures

Well-defined procedure input & output

System connects procedures

(43)

Machine Complexity

Graphics machines are complex

User does not want to know

How machine does what it does

Tons of machine-specific differences

Answer:

Simple model of machine

High-level language for procedures

Well-defined procedure input & output

System connects procedures

(44)

Ignoring Hardware Differences

Machine Complexity

Graphics machines are complex

User does not want to know

How machine does what it does

Tons of machine-specific differences

Answer:

Simple model of machine

High-level language for procedures

Well-defined procedure input & output

System connects procedures

(45)

Simplified Machine

User’s mental model

Hide details

Device independent

Procedural stages

(46)

Ignoring Hardware Differences

Simplified Machine

User’s mental model

Hide details

Device independent

Procedural stages

(47)

Simplified Machine

User’s mental model

Hide details

Device independent

Procedural stages

(48)

Ignoring Hardware Differences

Simplified Machine

User’s mental model

Hide details

Device independent

Procedural stages

(49)

RenderMan Model

Model

Transform Displacement

Shade Light

Volume Imager

“Abstract” interface

Blocks = procedures

Block interfaces well defined

Connections

Inputs & outputs don’t have to match

System handles conversion

(50)

Ignoring Hardware Differences

RenderMan Model

Model

Transform Displacement

Shade Light

Volume Imager

“Abstract” interface

Blocks = procedures

Block interfaces well defined

Connections

Inputs & outputs don’t have to match

System handles conversion

(51)

RenderMan Shader types

Model

Transform Displacement

Shade Light

Volume Imager

(52)

Ignoring Hardware Differences

RenderMan Shader types

Model

Transform

Displacement

Shade Light

Volume Imager

(53)

RenderMan Shader types

Model

Transform Displacement

Shade Light

Volume Imager

(54)

Ignoring Hardware Differences

RenderMan Shader types

Model

Transform Displacement

Shade Light

Volume Imager

(55)

RenderMan Shader types

Model

Transform Displacement

Shade Light

Volume Imager

(56)

Ignoring Hardware Differences

RenderMan Shader types

Model

Transform Displacement

Shade Light

Volume Imager

(57)

RenderMan Shader types

Model

Transform Displacement

Shade Light

Volume Imager

Katsuaki Hiramitsu www.edit.ne.jp/˜katsu/

(58)

Ignoring Hardware Differences

RenderMan Model

Model

Transform Displacement

Shade Light

Volume Imager

What it says:

Input and output of each block

What each block should do

What it doesn’t say:

Order or grouping of processing

(59)

RenderMan Model

Model

Transform Displacement

Shade Light

Volume Imager

What it says:

Input and output of each block

What each block should do

What it doesn’t say:

Order or grouping of processing

(60)

Ignoring Hardware Differences

RenderMan REYES

Model

Transform Displacement

Shade Light

Volume Imager

Object

Object / Sample

Image / Pixel

(61)

RenderMan Ray Tracing

Model

Transform Displacement

Shade Light

Volume Imager

Ray

Image / Pixel

(62)

Ignoring Hardware Differences

RenderMan

SGI Multi-pass RenderMan

Model

Transform Displacement

Shade Light

Volume Imager

Object

Object / Pass / Pixel

Image / Pixel

(63)

Hardware Model

Vertex

Fragment Texture

Vertex shading

Transform

Procedural transformation

Skinning

Shade

Per-vertex shading

Computed texture coordinates

(64)

Ignoring Hardware Differences

Hardware Model

Vertex

Fragment Texture

Fragment shading

Per-fragment shading

Computed and dependent texture

(65)

Hardware Model

Vertex

Fragment Texture

Render to texture

Rendered shadow &

environment maps

Multi-pass fragment shading [Proudfoot et al., 2001]

(66)

Ignoring Hardware Differences

Hardware Model

Vertex

Fragment Buffers

Render to vertex array / buffer objects

Geometry images [Gu et al., 2002]

Multi-pass vertex shading

Merge vertex & fragment capabilities

(67)

Hardware Model

Vertex

Fragment Buffers

Vertex texture

Texture-based vertex displacement

Tabulated functions

(68)

Ignoring Hardware Differences

Hardware Model

Vertex

Fragment Buffers

It’s all about the memory

What it says:

Input and output of each block

What each block should do

What it doesn’t say:

Vertex processing order

Fragment processing order

Interleaving of vertex and fragment

(69)

Hardware Model

Vertex

Fragment Buffers

It’s all about the memory

What it says:

Input and output of each block

What each block should do

What it doesn’t say:

Vertex processing order

Fragment processing order

Interleaving of vertex and fragment

(70)

Ignoring Hardware Differences

Hardware Model

Vertex

Fragment Buffers

It’s all about the memory

What it says:

Input and output of each block

What each block should do

What it doesn’t say:

Vertex processing order

Fragment processing order

Interleaving of vertex and fragment

(71)

No, but really, what’s in there?

Vertex

Fragment Buffers

Some other stuff,

Parallelism,

And more parallelism

(72)

Ignoring Hardware Differences

No, but really, what’s in there?

Vertex

Fragment Buffers

Triangle

Zbuf / Blend

Some other stuff,

Parallelism,

And more parallelism

(73)

No, but really, what’s in there?

Vertex

Fragment Buffers

Triangle

Zbuf / Blend

Ver Ver

Fragm Fragm Fragm Fragm Fragm Fragm Fragm Fragm Fragm Fragm Fragment Fragment ent ent ent ent

Ver Ver Vertex Vertex Vertex Vertex Vertex Vertex tex tex

Some other stuff,

Parallelism,

And more parallelism

(74)

Ignoring Hardware Differences

No, but really, what’s in there?

Vertex

Fragment Buffers

Triangle

Zbuf / Blend

Ver Ver

Fragm Fragm Fragm Fragm Fragm Fragm Fragm Fragm Fragm Fragm Fragment Fragment ent ent ent ent

Ver Ver Vertex Vertex Vertex Vertex Vertex Vertex tex tex

Some other stuff,

Parallelism,

And more parallelism

(75)

Part III

Noise

(76)

What is this Noise? Perlin noise Modifications

Outline

What is this Noise?

Perlin noise Modifications

(77)

Why Noise?

Introduced by [Perlin, 1985]

Heavilyused in production animation

Technical Achievement Oscar in 1997

“Salt,” adds spice to shaders

(78)

What is this Noise? Perlin noise Modifications

Why Noise?

Introduced by [Perlin, 1985]

Heavilyused in production animation

Technical Achievement Oscar in 1997

“Salt,” adds spice to shaders

+ =

(79)

Noise Characteristics

Random

No correlation between distant values

Repeatable/deterministic

Same argument always produces same value

Band-limited

Most energy in one octave (e.g. between f & 2f)

1 2 3 4 5 6 7

(80)

What is this Noise? Perlin noise Modifications

Noise Characteristics

Random

No correlation between distant values

Repeatable/deterministic

Same argument always produces same value

Band-limited

Most energy in one octave (e.g. between f & 2f)

1 2 3 4 5 6 7

(81)

Noise Characteristics

Random

No correlation between distant values

Repeatable/deterministic

Same argument always produces same value

Band-limited

Most energy in one octave (e.g. between f & 2f)

1 2 3 4 5 6 7

(82)

What is this Noise? Perlin noise Modifications

Gradient Noise

Original Perlin noise [Perlin, 1985]

Perlin Improved noise [Perlin, 2002]

Lattice based

Value=0 at integer lattice points

Gradientdefined at integer lattice

Interpolate between

1/2 to 1 cycle each unit

1 2 3 4 5 6 7 1 2 3 4 5 6 7

Original Improved

(83)

Gradient Noise

Original Perlin noise [Perlin, 1985]

Perlin Improved noise [Perlin, 2002]

Lattice based

Value=0 at integer lattice points

Gradientdefined at integer lattice

Interpolate between

1/2 to 1 cycle each unit

1 2 3 4 5 6 7 1 2 3 4 5 6 7

Original Improved

(84)

What is this Noise? Perlin noise Modifications

Gradient Noise

Original Perlin noise [Perlin, 1985]

Perlin Improved noise [Perlin, 2002]

Lattice based

Value=0 at integer lattice points

Gradientdefined at integer lattice

Interpolate between

1/2 to 1 cycle each unit

1 2 3 4 5 6 7 1 2 3 4 5 6 7

Original Improved

(85)

Value Noise

Lattice based

Valuedefined at integer lattice points

Interpolate between

At most 1/2 cycle each unit

Significant low-frequency content

Easy hardware implementation with lower quality

1 2 3 4 5 6 7 1 2 3 4 5 6 7

Linear Interp Cubic Interp

(86)

What is this Noise? Perlin noise Modifications

Value Noise

Lattice based

Valuedefined at integer lattice points

Interpolate between

At most 1/2 cycle each unit

Significant low-frequency content

Easy hardware implementation with lower quality

1 2 3 4 5 6 7 1 2 3 4 5 6 7

Linear Interp Cubic Interp

(87)

Value Noise

Lattice based

Valuedefined at integer lattice points

Interpolate between

At most 1/2 cycle each unit

Significant low-frequency content

Easy hardware implementation with lower quality

1 2 3 4 5 6 7 1 2 3 4 5 6 7

Linear Interp Cubic Interp

(88)

What is this Noise? Perlin noise Modifications

Value Noise

Lattice based

Valuedefined at integer lattice points

Interpolate between

At most 1/2 cycle each unit

Significant low-frequency content

Easy hardware implementation with lower quality

1 2 3 4 5 6 7 1 2 3 4 5 6 7

Linear Interp Cubic Interp

(89)

Hardware Noise

Value noise

PixelFlow [Lastra et al., 1995]

Perlin Noise Pixel Shaders [Hart, 2001]

Noise textures

Gradient noise

Hardware [Perlin, 2001]

Complex composition [Perlin, 2004]

Shader implementation [Green, 2005]

(90)

What is this Noise? Perlin noise Modifications

Outline

What is this Noise?

Perlin noise Modifications

(91)

Noise Details

Subclass of gradient noise

Original Perlin

Perlin Improved

All of our proposed modifications

(92)

What is this Noise? Perlin noise Modifications

Find the Lattice

Lattice-based noise: must find nearest lattice points

Point ~p = (~px, ~py, ~pz)

has integer lattice location

~pi = (⌊~px⌋, ⌊~py⌋, ⌊~pz⌋) = (X , Y , Z )

and fractional location in cell

~pf = ~p − ~pi = (x, y , z)

(93)

Find the Lattice

Lattice-based noise: must find nearest lattice points

Point ~p = (~px, ~py, ~pz)

has integer lattice location

~pi = (⌊~px⌋, ⌊~py⌋, ⌊~pz⌋) = (X , Y , Z )

and fractional location in cell

~pf = ~p − ~pi = (x, y , z)

(94)

What is this Noise? Perlin noise Modifications

Find the Lattice

Lattice-based noise: must find nearest lattice points

Point ~p = (~px, ~py, ~pz)

has integer lattice location

~pi = (⌊~px⌋, ⌊~py⌋, ⌊~pz⌋) = (X , Y , Z )

and fractional location in cell

~pf = ~p − ~pi = (x, y , z)

X

Y

(95)

Find the Lattice

Lattice-based noise: must find nearest lattice points

Point ~p = (~px, ~py, ~pz)

has integer lattice location

~pi = (⌊~px⌋, ⌊~py⌋, ⌊~pz⌋) = (X , Y , Z )

and fractional location in cell

~pf = ~p − ~pi = (x, y , z)

x X y

Y

(96)

What is this Noise? Perlin noise Modifications

Gradient

Random vector at each lattice point is a function of ~pi

g (~pi)

A function with that gradient grad(~p) = g (~pi) • ~pf

= gx(~pi) ∗ x + gy(~pi) ∗ y + gz(~pi) ∗ z

(97)

Gradient

Random vector at each lattice point is a function of ~pi

g (~pi)

A function with that gradient grad(~p) = g (~pi) • ~pf

= gx(~pi) ∗ x + gy(~pi) ∗ y + gz(~pi) ∗ z

(98)

What is this Noise? Perlin noise Modifications

Gradient

Random vector at each lattice point is a function of ~pi

g (~pi)

A function with that gradient grad(~p) = g (~pi) • ~pf

= gx(~pi) ∗ x + gy(~pi) ∗ y + gz(~pi) ∗ z

(99)

Interpolate

Interpolate nearest 2n gradient functions

2D noise(~p) is influenced by

~pi+ (0, 0); ~pi + (0, 1); ~pi + (1, 0) ; ~pi + (1, 1)

Linear interpolation

lerp(t, a, b) = (1 − t) a + t b

Smooth interpolation

fade(t) =

 3t2− 2t3 for original noise 10t3− 15t4+ 6t5 for improved noise

flerp(t) = lerp(fade(t), a, b)

(100)

What is this Noise? Perlin noise Modifications

Interpolate

Interpolate nearest 2n gradient functions

2D noise(~p) is influenced by

~pi+ (0, 0); ~pi + (0, 1); ~pi + (1, 0); ~pi + (1, 1)

Linear interpolation

lerp(t, a, b) = (1 − t) a + t b

Smooth interpolation

fade(t) =

 3t2− 2t3 for original noise 10t3− 15t4+ 6t5 for improved noise

flerp(t) = lerp(fade(t), a, b)

(101)

Interpolate

Interpolate nearest 2n gradient functions

2D noise(~p) is influenced by

~pi+ (0, 0); ~pi + (0, 1); ~pi + (1, 0); ~pi + (1, 1)

Linear interpolation

lerp(t, a, b) = (1 − t) a + t b

Smooth interpolation

fade(t) =

 3t2− 2t3 for original noise 10t3− 15t4+ 6t5 for improved noise

flerp(t) = lerp(fade(t), a, b)

(102)

What is this Noise? Perlin noise Modifications

Interpolate

Interpolate nearest 2n gradient functions

2D noise(~p) is influenced by

~pi+ (0, 0) ; ~pi + (0, 1); ~pi + (1, 0); ~pi + (1, 1)

Linear interpolation

lerp(t, a, b) = (1 − t) a + t b

Smooth interpolation

fade(t) =

 3t2− 2t3 for original noise 10t3− 15t4+ 6t5 for improved noise

flerp(t) = lerp(fade(t), a, b)

(103)

Interpolate

Interpolate nearest 2n gradient functions

2D noise(~p) is influenced by

~pi+ (0, 0) ; ~pi + (0, 1) ; ~pi + (1, 0); ~pi + (1, 1)

Linear interpolation

lerp(t, a, b) = (1 − t) a + t b

Smooth interpolation

fade(t) =

 3t2− 2t3 for original noise 10t3− 15t4+ 6t5 for improved noise

flerp(t) = lerp(fade(t), a, b)

(104)

What is this Noise? Perlin noise Modifications

Interpolate

Interpolate nearest 2n gradient functions

2D noise(~p) is influenced by

~pi+ (0, 0) ; ~pi + (0, 1) ; ~pi + (1, 0) ; ~pi + (1, 1)

Linear interpolation

lerp(t, a, b) = (1 − t) a + t b

Smooth interpolation

fade(t) =

 3t2− 2t3 for original noise 10t3− 15t4+ 6t5 for improved noise

flerp(t) = lerp(fade(t), a, b)

(105)

Interpolate

Interpolate nearest 2n gradient functions

2D noise(~p) is influenced by

~pi+ (0, 0) ; ~pi + (0, 1) ; ~pi + (1, 0) ; ~pi + (1, 1)

Linear interpolation

lerp(t, a, b) = (1 − t) a + t b

Smooth interpolation

fade(t) =

 3t2− 2t3 for original noise 10t3− 15t4+ 6t5 for improved noise

flerp(t) = lerp(fade(t), a, b)

(106)

What is this Noise? Perlin noise Modifications

Interpolate

Interpolate nearest 2n gradient functions

2D noise(~p) is influenced by

~pi+ (0, 0) ; ~pi + (0, 1) ; ~pi + (1, 0) ; ~pi + (1, 1)

Linear interpolation

lerp(t, a, b) = (1 − t) a + t b

Smooth interpolation

fade(t) =

 3t2− 2t3 for original noise 10t3− 15t4+ 6t5 for improved noise

flerp(t) = lerp(fade(t), a, b)

(107)

Interpolate

Interpolate nearest 2n gradient functions

2D noise(~p) is influenced by

~pi+ (0, 0) ; ~pi + (0, 1) ; ~pi + (1, 0) ; ~pi + (1, 1)

Linear interpolation

lerp(t, a, b) = (1 − t) a + t b

Smooth interpolation

fade(t) =

 3t2− 2t3 for original noise 10t3− 15t4+ 6t5 for improved noise

flerp(t) = lerp(fade(t), a, b)

(108)

What is this Noise? Perlin noise Modifications

Interpolate

Interpolate nearest 2n gradient functions

2D noise(~p) is influenced by

~pi+ (0, 0) ; ~pi + (0, 1) ; ~pi + (1, 0) ; ~pi + (1, 1)

Linear interpolation

lerp(t, a, b) = (1 − t) a + t b

Smooth interpolation

fade(t) =

 3t2− 2t3 for original noise 10t3− 15t4+ 6t5 for improved noise

flerp(t) = lerp(fade(t), a, b)

(109)

Hash

n-D gradient function built from 1D components g(~pi)

Both original and improved use a permutation table hash

Original: g is a table of unit vectors

Improved: g is derived from bits of final hash

(110)

What is this Noise? Perlin noise Modifications

Hash

n-D gradient function built from 1D components g(hash(X , Y , Z ))

Both original and improved use a permutation table hash

Original: g is a table of unit vectors

Improved: g is derived from bits of final hash

(111)

Hash

n-D gradient function built from 1D components g(hash(Z + hash(X , Y )))

Both original and improved use a permutation table hash

Original: g is a table of unit vectors

Improved: g is derived from bits of final hash

(112)

What is this Noise? Perlin noise Modifications

Hash

n-D gradient function built from 1D components g(hash(Z + hash(Y + hash(X ))))

Both original and improved use a permutation table hash

Original: g is a table of unit vectors

Improved: g is derived from bits of final hash

(113)

Hash

n-D gradient function built from 1D components g(hash(Z +hash(Y +hash(X ))))

Both original and improved use a permutation tablehash

Original: g is a table of unit vectors

Improved: g is derived from bits of final hash

(114)

What is this Noise? Perlin noise Modifications

Hash

n-D gradient function built from 1D components g(hash(Z + hash(Y + hash(X ))))

Both original and improved use a permutation table hash

Original: g is a table of unit vectors

Improved: g is derived from bits of final hash

(115)

Outline

What is this Noise?

Perlin noise

Modifications Corner Gradients Factorization Hash

(116)

What is this Noise? Perlin noise Modifications

Gradient Vectors of n-D Noise

Original: on the surface of a n-sphere

Found by hash of ~pi into gradient table

Improved: at the edges of an n-cube

Found by decoding bits of hash of ~pi

(117)

Gradient Vectors of n-D Noise

Original: on the surface of a n-sphere

Found by hash of ~pi into gradient table

Improved: at the edges of an n-cube

Found by decoding bits of hash of ~pi

(118)

What is this Noise? Perlin noise Modifications

Gradients of noise(x,y,0) or noise(x,0)

Why?

Cheaper low-D noise matches slice of higher-D

Reuse textures (for full noise or partial computation)

Original: new short gradient vectors

Improved: gradients in new directions

Possibly including 0 gradient vector!

(119)

Gradients of noise(x,y,0) or noise(x,0)

Why?

Cheaper low-D noise matches slice of higher-D

Reuse textures (for full noise or partial computation)

Original: new short gradient vectors

Improved: gradients in new directions

Possibly including 0 gradient vector!

(120)

What is this Noise? Perlin noise Modifications

Gradients of noise(x,y,0) or noise(x,0)

Why?

Cheaper low-D noise matches slice of higher-D

Reuse textures (for full noise or partial computation)

Original: new short gradient vectors

Improved: gradients in new directions

Possibly including 0 gradient vector!

(121)

Solution?

Observe: use gradient function, not vector alone grad = gx x + gy y + gz z

In any integer plane, fractional z = 0 grad = gx x + gy y + 0

Any choice keeping projection of vectors the same will work

Improved noise uses cube edge centers

Instead use cube corners!

(122)

What is this Noise? Perlin noise Modifications

Solution?

Observe: use gradient function, not vector alone grad = gx x + gy y + gz z

In any integer plane, fractional z = 0 grad = gx x + gy y + 0

Any choice keeping projection of vectors the same will work

Improved noise uses cube edge centers

Instead use cube corners!

(123)

Solution?

Observe: use gradient function, not vector alone grad = gx x + gy y + gz z

In any integer plane, fractional z = 0 grad = gx x + gy y + 0

Any choice keeping projection of vectors the same will work

Improved noise uses cube edge centers

Instead use cube corners!

(124)

What is this Noise? Perlin noise Modifications

Solution?

Observe: use gradient function, not vector alone grad = gx x + gy y + gz z

In any integer plane, fractional z = 0 grad = gx x + gy y + 0

Any choice keeping projection of vectors the same will work

Improved noise uses cube edge centers

Instead use cube corners!

(125)

Solution?

Observe: use gradient function, not vector alone grad = gx x + gy y + gz z

In any integer plane, fractional z = 0 grad = gx x + gy y + 0

Any choice keeping projection of vectors the same will work

Improved noise uses cube edge centers

Instead use cube corners!

(126)

What is this Noise? Perlin noise Modifications

Corner Gradients

Simple binary selection from hash bits

±x, ±y , ±z

Perlin mentions “clumping” for corner gradient selection

Not very noticeable in practice

Already happens in any integer plane of improved noise

(127)

Corner Gradients

Simple binary selection from hash bits

±x, ±y , ±z

Perlin mentions “clumping” for corner gradient selection

Not very noticeable in practice

Already happens in any integer plane of improved noise

Edge Centers Corner

(128)

What is this Noise? Perlin noise Modifications

Separable Computation

Like to store computation in texture

Texture sampling 3-4x highest frequency

1D & 2D OK size, 3D gets big, 4D impossible

Factor into lower-D textures

(e.g. write noise(~px, ~py, ~pz) as several x/y terms) noise(~px, ~py, ~pz) = flerp(z,+ ∗ z

+ ∗ (z − 1))

(129)

Separable Computation

Like to store computation in texture

Texture sampling 3-4x highest frequency

1D & 2D OK size, 3D gets big, 4D impossible

Factor into lower-D textures

(e.g. write noise(~px, ~py, ~pz) as several x/y terms) noise(~px, ~py, ~pz) = flerp(z,+ ∗ z

+ ∗ (z − 1))

(130)

What is this Noise? Perlin noise Modifications

Separable Computation

Like to store computation in texture

Texture sampling 3-4x highest frequency

1D & 2D OK size, 3D gets big, 4D impossible

Factor into lower-D textures

(e.g. write noise(~px, ~py, ~pz) as several x/y terms) noise(~px, ~py, ~pz) = flerp(z,+ ∗ z

+ ∗ (z − 1))

(131)

Separable Computation

Like to store computation in texture

Texture sampling 3-4x highest frequency

1D & 2D OK size, 3D gets big, 4D impossible

Factor into lower-D textures

(e.g. write noise(~px, ~py, ~pz) as several x/y terms) noise(~px, ~py, ~pz) = flerp(z,+ ∗ z

+ ∗ (z − 1))

(132)

What is this Noise? Perlin noise Modifications

Separable Computation

Like to store computation in texture

Texture sampling 3-4x highest frequency

1D & 2D OK size, 3D gets big, 4D impossible

Factor into lower-D textures

(e.g. write noise(~px, ~py, ~pz) as several x/y terms) noise(~px, ~py, ~pz) = flerp(z,xyz-term+xyz-term ∗ z

xyz-term+xyz-term ∗ (z − 1))

(133)

Separable Computation

Like to store computation in texture

Texture sampling 3-4x highest frequency

1D & 2D OK size, 3D gets big, 4D impossible

Factor into lower-D textures

(e.g. write noise(~px, ~py, ~pz) as several x/y terms)

noise(~px, ~py, ~pz) = flerp(z,xy-term(Z0)+xy-term(Z0) ∗ z xy-term(Z1)+xy-term(Z1) ∗ (z − 1))

(134)

What is this Noise? Perlin noise Modifications

Factorization Details

noise(~p) = flerp(z,zconst(~px, ~py,Z0)+zgrad(~px, ~py,Z0) ∗ z, zconst(~px, ~py,Z1)+zgrad(~px, ~py,Z1) ∗ (z − 1))

With nested hash,

zconst(~px, ~py,Z0)= zconst(~px, ~py+ hash(Z0)) zgrad (~px, ~py,Z0)= zgrad (~px, ~py+ hash(Z0))

With corner gradients, zconst = noise!

(135)

Factorization Details

noise(~p) = flerp(z,zconst(~px, ~py,Z0)+zgrad(~px, ~py,Z0) ∗ z, zconst(~px, ~py,Z1)+zgrad(~px, ~py,Z1) ∗ (z − 1))

With nested hash,

zconst(~px, ~py,Z0)= zconst(~px, ~py+ hash(Z0)) zgrad (~px, ~py,Z0)= zgrad (~px, ~py+ hash(Z0))

With corner gradients, zconst = noise!

References

Related documents