Real-Time Programmable Real-Time Programmable Shading Shading - - PDF document

real time programmable real time programmable shading
SMART_READER_LITE
LIVE PREVIEW

Real-Time Programmable Real-Time Programmable Shading Shading - - PDF document

Real-Time Programmable Real-Time Programmable Shading Shading (http://www.cs.unc.edu/~olano/papers/rtshading/) (http://www.cs.unc.edu/~olano/papers/rtshading/) Anselmo Lastra, Steve Molnar, Anselmo Lastra, Steve Molnar, Marc Olano, Yulan


slide-1
SLIDE 1

1

Real-Time Programmable Shading

Anselmo Lastra, Steve Molnar, Marc Olano, Yulan Wang

{lastra,molnar,olano,wangy}@cs.unc.edu (http://www.cs.unc.edu/~olano/papers/rtshading/) University of North Carolina at Chapel Hill

Real-Time Programmable Shading

Anselmo Lastra, Steve Molnar, Marc Olano, Yulan Wang

{lastra,molnar,olano,wangy}@cs.unc.edu (http://www.cs.unc.edu/~olano/papers/rtshading/) University of North Carolina at Chapel Hill

Introduction Organization

◆ Requirements of programmable shading ◆ PixelFlow shading architecture ◆ An example

Requirements PixelFlow Example

Programmable what?

◆ Simple functions ◆ Run at each pixel/sample ◆ Compute surface shading, lighting,

displacement maps, atmospheric effects, ...

– Whitted 82, Cook 84, Perlin 85, Hanrahan 90 – Rhoades 92

Requirements PixelFlow Example

Surface shader

◆ For one sample ◆ Inputs:

– Intrinsic color, normal, texture coordinates, width, length, bumpiness, swirliness, ...

◆ Outputs:

– Color, (opacity)

Requirements PixelFlow Example

slide-2
SLIDE 2

2

Resource requirements

◆ Programmability ◆ Memory ◆ Computational power

Requirements PixelFlow Example

Programmability

◆ Programmable processors at sample level ◆ High level language (i.e. RenderMan)

– Hanrahan 90, Upstill 90

Requirements PixelFlow Example

Resource requirements

◆ Programmability ◆ Memory ◆ Computational power

Requirements PixelFlow Example

Memory

◆ Table memory ◆ Local memory Shader Local Variables carpet 24 marble 26 stippled 33 stone 23

Requirements PixelFlow Example

Resource requirements

◆ Programmability ◆ Memory ◆ Computational power

– Parallelism – Deferred shading – Uniform/varying – Fixed point/floating point

Requirements PixelFlow Example

Parallelism

◆ Pixel-Planes 5 (Fuchs 89)

– 2–50 Graphics processors (i860) – 1–20 Renderers (custom) – 16k Pixel processors / renderer (custom)

◆ Reality Engine (Akeley 93)

– 8–12 Geometry engines (i860XP) – 5–20 Fragment generators (custom) – 80–320 Image engines (custom)

Requirements PixelFlow Example

slide-3
SLIDE 3

3

Resource requirements

◆ Programmability ◆ Memory ◆ Computational power

– Parallelism – Deferred shading – Uniform/varying – Fixed point/floating point

Requirements PixelFlow Example

Deferred shading

◆ Keep shading parameters at each pixel ◆ Shade after visibility is determined ◆ Pros:

– Doesn’t shade hidden pixels – Shading independant of geometric complexity! – Better utilization on SIMD

◆ Cons:

– Can’t affect visibility (No transparency, no displacement maps!)

Requirements PixelFlow Example

Resource requirements

◆ Programmability ◆ Memory ◆ Computational power

– Parallelism – Deferred shading – Uniform/varying – Fixed point/floating point

Requirements PixelFlow Example

Uniform/varying

◆ Uniform = constant across pixels/samples

– Wood grain, marble vein frequency, ...

◆ Varying = different in each pixel/sample

– Normal, texture coordinates, ...

◆ Don’t compute uniform values at every

pixel — compute once and broadcast

Requirements PixelFlow Example

Resource requirements

◆ Programmability ◆ Memory ◆ Computational power

– Parallelism – Deferred shading – Uniform/varying – Fixed point/floating point

Requirements PixelFlow Example

Fixed point/floating point

◆ Pixel processors

– Many processors – Simple instruction set – Floating point acceleration is unlikely

◆ Fixed point

– When required precision is known – More efficient in time and memory

Requirements PixelFlow Example

slide-4
SLIDE 4

4

PixelFlow

◆ Node description ◆ Memory ◆ Timings ◆ System

Requirements PixelFlow Example

PixelFlow node

Composition network Geometry network 128 x 64 SIMD array Table Memory Optional video card

Requirements PixelFlow Example

HP PA-RISC HP PA-RISC

PixelFlow

◆ Node description ◆ Memory ◆ Timings ◆ System

Requirements PixelFlow Example

Memory

◆ 16MB table memory ◆ 256 bytes local memory ◆ 128 bytes local memory/communication

Requirements PixelFlow Example

Timings (µs)

Requirements PixelFlow Example

float fixed 4 byte 4 byte 2 byte + 3.94µs 0.13 0.07 * 2.53 2.00 0.50 / 7.04 6.40 1.60 sqrt 6.98 3.33 1.22

Timings (µs)

Requirements PixelFlow Example

+ * / sqrt 4 byte float 4 byte fixed 2 byte fixed 4 8 + * / sqrt 4 byte float 4 byte fixed 2 byte fixed

slide-5
SLIDE 5

5

PixelFlow

◆ Node description ◆ Memory ◆ Timings ◆ System

Requirements PixelFlow Example

PixelFlow system

Rasterizer Nodes Shader Nodes Frame Buffer Node

Requirements PixelFlow Example

An example

◆ Video ◆ Shading functions ◆ Time

Requirements PixelFlow Example

An example

Requirements PixelFlow Example

Show video

Shading functions

◆ Pins

– Crown, label, scuffs, dirt, Phong

◆ Alley

– Wood, reflection map

◆ Ball

– Phong

◆ Light

– Shadow map

Requirements PixelFlow Example

Shading functions

Requirements PixelFlow Example

slide-6
SLIDE 6

6

An example

◆ Video ◆ Shading functions ◆ Time

– Breakdown of 33ms frame time – Breakdown of 150µs to run all shaders (excluding table lookups) – Time for table lookups – Use of multiple processors

Requirements PixelFlow Example

Time: 7 ms - shadow map

33 ms

Requirements PixelFlow Example

An example

◆ Video ◆ Shading functions ◆ Time

– Breakdown of 33ms frame time – Breakdown of 150µs to run all shaders (excluding table lookups) – Time for table lookups – Use of multiple processors

Requirements PixelFlow Example

Time: 7 ms - reflection map

33 ms

Requirements PixelFlow Example

An example

◆ Video ◆ Shading functions ◆ Time

– Breakdown of 33ms frame time – Breakdown of 150µs to run all shaders (excluding table lookups) – Time for table lookups – Use of multiple processors

Requirements PixelFlow Example

Time: 15.7 ms - final image

33 ms

Requirements PixelFlow Example

slide-7
SLIDE 7

7

An example

◆ Video ◆ Shading functions ◆ Time

– Breakdown of 33ms frame time – Breakdown of 150µs to run all shaders (excluding table lookups) – Time for table lookups – Using multiple processors

Requirements PixelFlow Example

Shading: 2µs - crown

150 µs

Requirements PixelFlow Example

An example

◆ Video ◆ Shading functions ◆ Time

– Breakdown of 33ms frame time – Breakdown of 150µs to run all shaders (excluding table lookups) – Time for table lookups – Using multiple processors

Requirements PixelFlow Example

Shading: 15µs - label

150 µs

Requirements PixelFlow Example

An example

◆ Video ◆ Shading functions ◆ Time

– Breakdown of 33ms frame time – Breakdown of 150µs to run all shaders (excluding table lookups) – Time for table lookups – Using multiple processors

Requirements PixelFlow Example

Shading: 39µs - scuffs & dirt

150 µs

Requirements PixelFlow Example

slide-8
SLIDE 8

8

An example

◆ Video ◆ Shading functions ◆ Time

– Breakdown of 33ms frame time – Breakdown of 150µs to run all shaders (excluding table lookups) – Time for table lookups – Using multiple processors

Requirements PixelFlow Example

Shading: 15µs - wood

150 µs

Requirements PixelFlow Example

An example

◆ Video ◆ Shading functions ◆ Time

– Breakdown of 33ms frame time – Breakdown of 150µs to run all shaders (excluding table lookups) – Time for table lookups – Using multiple processors

Requirements PixelFlow Example

Shading: 28 µs - light/shadows

150 µs

Requirements PixelFlow Example

An example

◆ Video ◆ Shading functions ◆ Time

– Breakdown of 33ms frame time – Breakdown of 150µs to run all shaders (excluding table lookups) – Time for table lookups – Using multiple processors

Requirements PixelFlow Example

Shading: 12µs - Phong (pins)

150 µs

Requirements PixelFlow Example

slide-9
SLIDE 9

9

An example

◆ Video ◆ Shading functions ◆ Time

– Breakdown of 33ms frame time – Breakdown of 150µs to run all shaders (excluding table lookups) – Time for table lookups – Using multiple processors

Requirements PixelFlow Example

Shading: 27µs - reflection

150 µs

Requirements PixelFlow Example

An example

◆ Video ◆ Shading functions ◆ Time

– Breakdown of 33ms frame time – Breakdown of 150µs to run all shaders (excluding table lookups) – Time for table lookups – Using multiple processors

Requirements PixelFlow Example

Shading: 12µs - Phong (ball)

150 µs

Requirements PixelFlow Example

An example

◆ Video ◆ Shading functions ◆ Time

– Breakdown of 33ms frame time – Breakdown of 150µs to run all shaders (excluding table lookups) – Time for table lookups – Using multiple processors

Requirements PixelFlow Example

Time for table lookups

◆ About 23ns per pixel ◆ Worst case

– Bowling pin (4 lookups) in all pixels

» Label image » Scuff bump map » Dirt image » Shadow map

– Total 760µs per region

Requirements PixelFlow Example

slide-10
SLIDE 10

10

Using multiple processors

Requirements PixelFlow Example

Rasterizer Nodes Shader Nodes Frame Buffer Node Computation Communication

Using multiple processors

Requirements PixelFlow Example

Rasterizer 1 Rasterizer 2 Shader 1 Shader 2 Frame buffer Screen region

Using multiple processors

Requirements PixelFlow Example

Rasterizer Nodes Shader Nodes Frame Buffer Node Computation Communication

Using multiple processors

Requirements PixelFlow Example

Rasterizer 1 Rasterizer 2 Shader 1 Shader 2 Frame buffer Screen region

Using multiple processors

Requirements PixelFlow Example

Rasterizer Nodes Shader Nodes Frame Buffer Node Computation Communication

Using multiple processors

Requirements PixelFlow Example

Rasterizer 1 Rasterizer 2 Shader 1 Shader 2 Frame buffer Screen region

slide-11
SLIDE 11

11

Using multiple processors

Requirements PixelFlow Example

Rasterizer Nodes Shader Nodes Frame Buffer Node Computation Communication

Using multiple processors

Requirements PixelFlow Example

Rasterizer 1 Rasterizer 2 Shader 1 Shader 2 Frame buffer Screen region

Using multiple processors

Requirements PixelFlow Example

Rasterizer Nodes Shader Nodes Frame Buffer Node Computation Communication

Using multiple processors

Requirements PixelFlow Example

Rasterizer 1 Rasterizer 2 Shader 1 Shader 2 Frame buffer Screen region

Using multiple processors

Requirements PixelFlow Example

Rasterizer Nodes Shader Nodes Frame Buffer Node Computation Communication

Using multiple processors

Requirements PixelFlow Example

Rasterizer 1 Rasterizer 2 Shader 1 Shader 2 Frame buffer Screen region

slide-12
SLIDE 12

12

Using multiple processors

Requirements PixelFlow Example

Rasterizer Nodes Shader Nodes Frame Buffer Node Computation Communication

Using multiple processors

Requirements PixelFlow Example

Rasterizer 1 Rasterizer 2 Shader 1 Shader 2 Frame buffer Screen region

Using multiple processors

Requirements PixelFlow Example

Rasterizer Nodes Shader Nodes Frame Buffer Node Computation Communication

Using multiple processors

Requirements PixelFlow Example

Rasterizer 1 Rasterizer 2 Shader 1 Shader 2 Frame buffer Screen region

Using multiple processors

Requirements PixelFlow Example

Rasterizer Nodes Shader Nodes Frame Buffer Node Computation Communication

Using multiple processors

Requirements PixelFlow Example

Rasterizer 1 Rasterizer 2 Shader 1 Shader 2 Frame buffer Screen region

slide-13
SLIDE 13

13

Using multiple processors

Requirements PixelFlow Example

Rasterizer Nodes Shader Nodes Frame Buffer Node Computation Communication

Using multiple processors

Requirements PixelFlow Example

Rasterizer 1 Rasterizer 2 Shader 1 Shader 2 Frame buffer Screen region

Using multiple processors

Requirements PixelFlow Example

Rasterizer Nodes Shader Nodes Frame Buffer Node Computation Communication

Rasterizer 1 Rasterizer 2 Shader 1 Shader 2 Frame buffer

Using multiple processors

Requirements PixelFlow Example

Screen region

Future work

◆ RenderMan-like shading compiler ◆ Allow programming other places ◆ Convince commercial vendors that they can

and should do programmable shading too

Acknowledgements

◆ Lawrence Kesteloot, Fredrik Fatemi ◆ UNC PixelFlow Group ◆ Tony Apodaca, Pixar ◆ Hewlett-Packard ◆ ARPA ISTO Order No. A410 ◆ NSF Grant No. MIP-9306208