Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
Uncharted 2: HDR Lighting<br />John Hable<br />Naughty Dog<br />
Agenda<br />Gamma/Linear-Space Lighting<br />Filmic Tonemapping<br />SSAO<br />Rendering Architecture/How it all fits toge...
Skeletons in the Closet<br /><ul><li>Used to work for EA Black Box (Vancouver)‏
Ucap Project
I.e. Tiger Woods's Face
Also used to work for EA Los Angeles
LMNO (Spielberg Project)‏
Not PQRS (Boom Blox)‏
Now at Naughty Dog
Uncharted 2</li></li></ul><li>Part 1: Gamma!<br />
Gamma<br /><ul><li>Mostly solved in Film Industry after lots of kicking and screaming
Never heard about it in college
George Borshukov taught it to me back at EA
Matrix Sequels
Issue is getting more traction now
Eugene d’Eon’s chapter in GPU Gems 3</li></li></ul><li>Demo<br /><ul><li>What is halfway between white and black
Suppose we show alternating light/dark lines.
If we squint, we get half the linear intensity.</li></li></ul><li>Demo<br /><ul><li>Test image with 4 rectangles.
Real image of a computer screen shot from my camera.</li></li></ul><li>Demo<br /><ul><li>Alternating lines of black and wh...
That’s the box on the top.</li></ul>128<br />
Demo<br /><ul><li>Correct answer is 187.
WTF?</li></ul>128<br />187<br />
Color Ramp<br /><ul><li>You have seen this before.</li></ul>0<br />127<br />255<br />187<br />
Gamma Lines<br />255<br /><ul><li>F(x) = pow(x,2.2)‏</li></ul>187<br />127<br />0<br />
What is Gamma<br /><ul><li>Gamma of 0.45, 1, 2.2
Our monitors are the red one</li></li></ul><li>We all love mink...<br /><ul><li>F(x) = x</li></li></ul><li>We all love min...
How bad is it?<br /><ul><li>Your monitor has a gamma of about 2.2
So if you output the left image to the framebuffer, it will actually look like the one right.</li></ul>2.2<br />
Let’s build a Camera…<br /><ul><li>A linear camera.</li></ul>Actual<br />Light<br />Monitor<br />Output<br />1.0<br />2.2<...
Let’s build a Camera…<br /><ul><li>Any consumer camera.</li></ul>Actual<br />Light<br />Monitor<br />Output<br />.45<br />...
How to fix this?<br /><ul><li>Your screen displays a gamma of 2.2
This is stored on your hard drive.
You never see this image, but it’s on your hard drive.</li></ul>2.2<br />
What is Gamma<br /><ul><li>Curves again.</li></li></ul><li>What is Gamma<br />Q) Why not just store as linear?<br />A) Our...
How bad is it?<br /><ul><li>Suppose we look at the 0-63 range.
What if displays were linear?</li></li></ul><li>Gamma<br /><ul><li>Gamma of 2.2 gives us more dark colors.</li></li></ul><...
On a scale from 0-255
0 would equal 0
1 would equal our current value of 20
2 would equal our current value of 28
3 would equal our current value of 33
Darkest Values:</li></li></ul><li>Ramp Again<br /><ul><li>See any banding in the whites? </li></li></ul><li>3D Graphics<br...
Note: we’re talking about “correct”, not “good”</li></li></ul><li>3D Graphics<br /><ul><li>Here's what is going on.</li></...
3D Graphics<br /><ul><li>Account for gamma when reading textures
color = pow( tex2D( Sampler, Uv ), 2.2 )‏
Do your lighting calculations
Account for gamma on color output
finalcolor = pow( color, 1/2.2 )‏</li></li></ul><li>3D Graphics<br /><ul><li>Here's what is going on.</li></ul>Monitor<br ...
3D Graphics<br /><ul><li>Comparison again...</li></li></ul><li>3D Graphics<br /><ul><li>The Wrong Shader?</li></ul>Spec = ...
3D Graphics<br /><ul><li>The Right Shader?</li></ul>Spec = CalSpec();<br />Diff = pow( tex2D( Sampler, UV ), 2.2 );<br />C...
3D Graphics<br /><ul><li>But, there is hardware to do this for us.
Hardware does sampling for free
For Texture read:
D3DSAMP_SRGBTEXTURE
For RenderTarget write:
D3DRS_SRGBWRITEENABLE</li></li></ul><li>3D Graphics<br /><ul><li>With those states we can remove the pow functions.</li></...
3D Graphics<br /><ul><li>What does the real world look like?
Notice the harsh line.</li></li></ul><li>3D Graphics<br /><ul><li>Another Example</li></li></ul><li>FAQs<br />Q1) But I li...
FAQs<br /><ul><li>It looks like the one on top before the monitor’s 2.2</li></li></ul><li>Harsh Falloff<br /><ul><li>Devas...
Gamma-Space
Use sRGB hardware or pow(2.2) on read
128 ~= 0.2
Linear-Space
Don’t use sRGB or pow(2.2) on read
128 = 0.5</li></li></ul><li>Which Maps?<br /><ul><li>Diffuse Map
Definitely Gamma
Normal Map
Definitely Linear</li></li></ul><li>Which Maps?<br /><ul><li>Specular?
Uncharted 2 had them as Linear
Artists have trouble tweaking them to look right
Probably should be in Gamma</li></li></ul><li>Which Maps?<br /><ul><li>Ambient Occlusion
Technically, it’s a mathematical value like a normal map.
But artists tweak them a lot and bake extra lighting into them.
Uncharted 2 had them as Linear
Probably should be Gamma</li></li></ul><li>Exercise for the Reader<br /><ul><li>Gamma 2.2 != sRGB != Xenon PWL
sRGB: PC and PS3 gamma
Xenon PWL: Piecewise linear gamma</li></li></ul><li>Xenon Gotchas<br /><ul><li>Xbox 360 Gamma Curve is wonky
Way too bright at the low end.
HDR the Bungie Way, Chris Tchou
Post Processing in The Orange Box, Alex Vlachos
Output curve is extra contrasty
Henry LaBounta was going to talk about it.
Try hooking up your Xenon to a waveform monitor and display a test pattern.  Prepare to be mortified.
Both factors counteract each other</li></li></ul><li>Linear-Space Lighting: Conclusion<br />“Drake!  You must believe in l...
Part 2: Filmic Tonemaping<br />
Filmic Tonemapping<br /><ul><li>Let's talk about the magic of the human eye.</li></li></ul><li>Filmic Tonemapping<br /><ul...
Full Auto settings.
Outside blown out.
Cello case looks empty.
My eye somehow adjusts...</li></li></ul><li>Filmic Tonemapping<br /><ul><li>Adaptiveness of human eye.</li></li></ul><li>F...
Note: 1 F-Stop is a power of two
So 4 F-stops is 2^4=16x difference in intensity</li></li></ul><li>Gamma<br /><ul><li>Exposure: -4</li></li></ul><li>Gamma<...
Good News: HDR Image
Bad News: Now what?
Re-tweaking exposure won't help</li></li></ul><li>Gamma<br /><ul><li>This is what Photography people call tonemapping.
Photomatix
This one is local
The one we’ll use is global</li></li></ul><li>Point of Confusion<br /><ul><li>Two problems to solve.
Simulate the Iris
Dynamic Range in different shots
Tunnel vs. Daylight
Simulate the Retina
Different Range within a shot
Inside looking outside</li></li></ul><li>Terminology<br /><ul><li>Photography/Film
Within a Shot – HDR Tonemapping
Different Shots – Choosing the correct exposure?
Video Games
Within a Shot – HDR Tonemapping
Different Shots – HDR Tonemapping?</li></li></ul><li>Terminology<br /><ul><li>For this presentation
Within a Shot – HDR Tonemapping
Different Shots
Automatic Exposure Adjustment
Dynamic Iris</li></li></ul><li>Linear Curve<br /><ul><li>Apartment of Habib Zargarpour
Creative Director, Microsoft Game Studios
Used to be Art Director on LMNO at EA</li></li></ul><li>Linear Curve<br /><ul><li>OutColor = pow(x,1/2.2)‏</li></li></ul><...
Simplest version is:
F(x) = x/(x+1)
Yes, I’m oversimplifiying for time.</li></li></ul><li>Fade!<br /><ul><li>Let's fade from linear to Reinhard.</li></li></ul...
The crisper, more saturated blacks of improper gamma.
The nice soft highlights of Reinhard
And get the input colors to actually match like pure linear.</li></li></ul><li>Voila!<br /><ul><li>Guess what?  There is a...
CG Supervisor at Digital Domain
Used to be a CG Supervisor on LMNO at EA</li></li></ul><li>Film<br />Q) Why do they still use film in movies?<br />A) The ...
Film<br /><ul><li>Kodak film examples.</li></ul>Shoulder<br />Toe<br />
Film<br /><ul><li>Using a film curve solves tons of problems.
Film vs. Digital purists.
Who would’ve thought: Kodak knows how to make good film.</li></li></ul><li>Filmic Curve<br /><ul><li>Crisp blacks, saturat...
Filmic Tonemapping<br /><ul><li>This technique works with any color.</li></ul>Reinhard<br />Linear<br />Filmic<br />
Filmic Tonemapping<br /><ul><li>This technique works with any color.</li></ul>Reinhard<br />Linear<br />Filmic<br />
Filmic Tonemapping<br /><ul><li>This technique works with any color.</li></ul>Reinhard<br />Linear<br />Filmic<br />
Filmic Tonemapping<br /><ul><li>This technique works with any color.</li></ul>Reinhard<br />Linear<br />Filmic<br />
Filmic Tonemapping<br /><ul><li>This technique works with any color.</li></ul>Reinhard<br />Linear<br />Filmic<br />
Filmic Tonemapping<br /><ul><li>This technique works with any color.</li></ul>Reinhard<br />Linear<br />Filmic<br />
Filmic Tonemapping<br /><ul><li>This technique works with any color.</li></ul>Reinhard<br />Linear<br />Filmic<br />
Filmic Tonemapping<br /><ul><li>This technique works with any color.</li></ul>Reinhard<br />Linear<br />Filmic<br />
Filmic Tonemapping<br /><ul><li>In terms of “Crisp Blacks” vs. “Milky Blacks”
Filmic > Linear > Reinhard
In terms of “Soft Highights” vs. “Clamped Highlights”
Filmic = Reinhard > Linear</li></li></ul><li>Filmic Tonemapping<br /><ul><li>Linear.</li></li></ul><li>Filmic Tonemapping<...
What happens if we go down?
Notice the crisper blacks in the filmic version.</li></li></ul><li>Filmic Tonemapping<br /><ul><li>Exposure: 0</li></li></...
Filmic Tonemapping<br /><ul><li>Variation in white section:</li></ul>254<br />248<br />224<br />240<br />252<br />
More Magic<br /><ul><li>The catch:
Three texture lookups
Jim Hejl to the rescue</li></ul>	Principle Member of Technical Staff<br />	GPU Group, Office of the CTO<br />	AMD Research...
Replaces the entire Lin/Log and Texture LUT
Includes the pow(x,1/2.2)‏</li></ul>x = max(0, LinearColor-0.004);<br />GammaColor = (x*(6.2*x+0.5))/(x*(6.2*x+1.7)+0.06);...
Filmic Tonemapping<br /><ul><li>Nice curve
Toe arguably too strong
Most monitors are too contrasty, strong toe makes it worse
May want less shoulder
The more range, the more shoulder
If your scene lacks range, you want to tone down the shoulder a bit</li></li></ul><li>Filmic Tonemapping<br />A = Shoulder...
Filmic Tonemapping<br />Shoulder Strength = 0.22<br />Linear Strength = 0.30<br />Linear Angle = 0.10<br />Toe Strength = ...
Conclusions<br /><ul><li>Filmic Tonemapping
IMO: The most important post effect
Changes your life completely
Once you have it, you can't live without it
If you implement it, you have to redo all your lighting
You can't just switch it on if your lighting is tweaked for no dynamic range.</li></li></ul><li>Filmic Tonemapping<br />“A...
Part 3: SSAO<br />
SSAO Time<br /><ul><li>That was fun.
Time for stage 3.
Let’s talk about why you need AO.</li></li></ul><li>Why AO?<br /><ul><li>The shadow “grounds” the car.</li></li></ul><li>W...
But if you are already in shadow, you need something else...
It's the AO that grounds the car in those shots.
So what if we took the AO out?
Trick taught to me by Habib (the guy with the awesome condo earlier)‏</li></li></ul><li>Why AO?<br /><ul><li>Your shadow c...
Sky is Hemisphere Light (ish)‏</li></li></ul><li>How to use AO?<br /><ul><li>Sun is Yellow (ish)‏
Sky is Blue (ish)‏</li></li></ul><li>How to use AO?<br /><ul><li>Sun is Directional
Approximate Directional Shadow with Shadow Mapping</li></li></ul><li>How to use AO?<br /><ul><li>Sky is Hemisphere (sorta)‏
Approximate Hemisphere Shadow with AO</li></li></ul><li>How to use AO?<br /><ul><li>Sun is yellow, sky is blue.</li></li><...
How to use AO?<br />
How to use AO?<br />
How to use AO?<br />
How to use AO?<br />
Sunlight<br />Q) Why not have it affect sunlight?<br />A) It does the exact opposite of what you want it to do.<br />
SSAO Example<br /><ul><li>Off</li></li></ul><li>SSAO Example<br /><ul><li>On</li></li></ul><li>SSAO Example<br /><ul><li>S...
SSAO Darkens Sunlight – BAD
Reduces perceived contrast
Makes lighting look flatter
My Opinion: SSAO should NOT affect Direct Light</li></li></ul><li>The Algorithm<br /><ul><li>Only Input is Half-Res Depth
No normals
No special filtering (I.e. Bilateral)‏
Processed in 64x64 blocks
Adjacent Depth tiles included as well</li></li></ul><li>The Algorithm<br /><ul><li>Calculate Base AO
Dilate Horizontal
Dilate Vertical
Apply Low Pass Filter</li></li></ul><li>SSAO Passes<br />0) Base Image<br />
SSAO Passes<br />1) Base SSAO<br />
SSAO Passes<br />2) Dilate Horizontal<br />
SSAO Passes<br />3) Dilate Vertical<br />
SSAO Passes<br />4) Low Pass Filter<br />	(I.e. blur the $&%@ out of it)‏<br />
SSAO Passes<br /><ul><li>Step One: The Base AO
Uses half-res depth buffer
Calculate AO based on nearby depth samples</li></li></ul><li>SSAO Passes<br /><ul><li>Pink point on a black surface.</li><...
Our solution is much hackier.</li></li></ul><li>SSAO Passes<br /><ul><li>Who needs sphere?  A box will do just as well.</l...
Half Volume = Fully Unoccluded</li></li></ul><li>SSAO Passes<br /><ul><li>We can estimate volume without knowing the normal.
Half Volume = Fully Unoccluded</li></li></ul><li>SSAO Passes<br /><ul><li>We can estimate volume without knowing the normal.
Half Volume = Fully Unoccluded</li></li></ul><li>SSAO Passes<br /><ul><li>We can estimate volume without knowing the normal.
Half Volume = Fully Unoccluded</li></li></ul><li>SSAO Passes<br /><ul><li>Start with a point</li></li></ul><li>SSAO Passes...
Artifacts<br /><ul><li>Blur adds white outline
Crossing Pattern</li></li></ul><li>Artifacts<br /><ul><li>More Crossing patterns</li></li></ul><li>Artifacts<br /><ul><li>...
Benefits outweigh drawbacks
Have option to turn it off per surface
Most snow fades at distance
Some objects apply sqrt() to brighten it
Some objects just have it off</li></li></ul><li>More Shots<br /><ul><li>On</li></li></ul><li>More Shots<br /><ul><li>Off</...
Deepens our Blacks
Artifacts are not too bad
Could use better filtering for halos
Runs on SPUs, and doesn’t need normal buffer</li></li></ul><li>Part 4: Architecture<br />
Architecture<br /><ul><li>Time for part 4.
Here is the base overview.
Skip some things</li></li></ul><li>Rendering Passes<br /><ul><li>Final output</li></li></ul><li>Rendering Passes<br /><ul>...
Calculate lighting in Tiles</li></li></ul><li>Rendering Passes<br /><ul><li>Back on the GPU...</li></li></ul><li>Rendering...
Frame 1<br /><ul><li>Begin Frame 1.</li></li></ul><li>Frame 1<br /><ul><li>All PPU stuff.</li></li></ul><li>Frame 1<br /><...
This was news to me when I started here.</li></li></ul><li>Performance<br /><ul><li>Let’s talk about Laundry
Say you have 5 loads to do
1 washer, 1 dryer</li></li></ul><li>In-Order<br /><ul><li>Load 1 in Washer
Load 1 in Dryer
Load 2 in Washer
Load 2 in Dryer
Load 3 in Washer
Load 3 in Dryer
Load 4 in Washer
Load 4 in Dryer
Load 5 in Washer
Load 5 in Dryer</li></li></ul><li>Pipelined<br /><ul><li>Load 1 in Washer
Load 2 in Washer, Load 1 in Dryer
Load 3 in Washer, Load 2 in Dryer
Load 4 in Washer, Load 3 in Dryer
Load 5 in Washer, Load 4 in Dryer
Load 5 in Dryer</li></li></ul><li>Software Pipelining<br /><ul><li>We can do this in software
Called “Software Pipelining”
It’s how we optimize SPU code by hand
Pal Engstad (our Lead Graphics Programmer) will be putting a doc online explaining the full process.
Should be online: look for the post on the blog
Direct links:
www.naughtydog.com/docs/gdc2010/intro-spu-optimizations-part-1.pdf
www.naughtydog.com/docs/gdc2010/intro-spu-optimizations-part-2.pdf</li></li></ul><li>SPU C++ Intrinsics<br />for( int y = ...
SPU Assembly 1/2<br />EVEN<br />ODD<br />loop:<br />		{nop}								{o6} lqxcurrAo, pvColor, colorOffset<br />		{nop}						...
SPU Assembly 2/2<br />EVEN<br />ODD<br />	{e6} fm blurAo, ao_n4, w4							{lnop}<br />	{e6} fma blurAo, ao_n3, w3, blurAo	...
SPU Assembly<br />{e6} faao_n3, ao_n3, ao_p3{o6}lqxnextAo, pvNextColor, colorOffset<br /><ul><li>Here is a sample line of ...
SPUs issue one even and odd instruction per cycle
One line = One cycle
e6 = even, 6 cycle latency
o6 = odd, 6 cycle latency</li></li></ul><li>Iteration 1<br />loop:<br />nop											lnop<br />nop 											lnop  <br /...
Iteration 1<br />loop:<br />nop											lnop<br />nop 					{o6:0} lqx currAo, pvColor, colorOffset<br />nop 					{o6:0} ...
Iteration 1<br />loop:<br />nop											lnop<br />nop 					{o6:0} lqx currAo, pvColor, colorOffset<br />nop 					{o6:0} ...
Problems<br /><ul><li>Take this line:</li></ul>            {o6} lqxcurrAo, pvColor, colorOffset<br />            {o4} shuf...
Next instruction needs currAo
currAo won’t be ready yet
Stall for 5 cycles</li></li></ul><li>Iteration 1<br />loop:<br />nop											lnop<br />nop 					{o6:0} lqx currAo, pvCol...
Iteration 1<br />loop:<br />nop											lnop<br />nop 					{o6:0} lqx currAo, pvColor, colorOffset<br />nop 					{o6:0} ...
Iteration 2<br />loop:<br />nop											lnop<br />{e6:1} fa ao_n4, ao_n4, nextAo	{o6:0} lqx currAo, pvColor, colorOffset...
Iteration 3<br />loop:<br />nop				 							lnop<br />{e6:1} fa ao_n4, ao_n4, nextAo	{o6:0} lqx currAo, pvColor, colorOffse...
Iteration 4<br />loop:<br />nop 											lnop<br />{e6:1} fa ao_n4, ao_n4, nextAo	{o6:0} lqx currAo, pvColor, colorOffse...
Copy Operations<br />loop:<br />{e2:x} ai ao_n1__, ao_n1_, 0							{o4:x} shlqbii currAo_, currAo, 0<br />{e6:1} fa ao_n4,...
Optimized<br />loop:<br />{e2:x} ai ao_n1__, ao_n1_, 0							{o4:x} shlqbii currAo_, currAo, 0<br />{e6:1} fa ao_n4, ao_n4...
Optimized<br />EVEN<br />ODD<br />loop:<br />{e2:x} ai ao_n1__, ao_n1_, 0							{o4:x} shlqbii currAo_, currAo, 0<br />{e6...
Optimized<br />EVEN<br />ODD<br />loop:<br />{e2:x} ai ao_n1__, ao_n1_, 0							{o4:x} shlqbii currAo_, currAo, 0<br />{e6...
Optimized<br />EVEN<br />ODD<br />loop:<br />{e2:x} ai ao_n1__, ao_n1_, 0							{o4:x} shlqbii currAo_, currAo, 0<br />{e6...
Solution<br /><ul><li>Gives about a 2x performance boost
Sometimes more or less
SSAO went from 2ms on all 6 SPUs to 1ms on all 6 SPUs
With practice, can do about 1-2 loops per day.
SSAO has 6 loops, and took a little over a week.
Same process for:
PostFX
Fullscreen Lighting
Ambient Cubemaps
Many more</li></li></ul><li>Full Timeline<br /><ul><li>Hand-Optimized by ICE Team</li></li></ul><li>Full Timeline<br /><ul...
Performance<br /><ul><li>Fullscreen Lighting / SSAO Performance</li></li></ul><li>Performance<br /><ul><li>Fullscreen Ligh...
Architecture Conclusions<br />“So, you are the scheduler that has been nipping at my heels...”<br />
Final Final Thoughts<br /><ul><li>Gamma is super-duper important.
Filmic Tonemapping changes your life.
SSAO is cool, and keep it out of your sunlight.
SPUs are awesome.
They don’t optimize themselves.
For a tight for-loop, you can do about 2x better than the compiler.</li></li></ul><li>Btw...<br /><ul><li>Naughty Dog is h...
We’re also looking for
Senior Lighting Artist.
Graphics Programmer</li></li></ul><li>That’s it!<br /><ul><li>Questions…</li>
Hable John Uncharted2 Hdr Lighting
Hable John Uncharted2 Hdr Lighting
Hable John Uncharted2 Hdr Lighting
Hable John Uncharted2 Hdr Lighting
Hable John Uncharted2 Hdr Lighting
Hable John Uncharted2 Hdr Lighting
Hable John Uncharted2 Hdr Lighting
Hable John Uncharted2 Hdr Lighting
Hable John Uncharted2 Hdr Lighting
Hable John Uncharted2 Hdr Lighting
Hable John Uncharted2 Hdr Lighting
Hable John Uncharted2 Hdr Lighting
Hable John Uncharted2 Hdr Lighting
Hable John Uncharted2 Hdr Lighting
Hable John Uncharted2 Hdr Lighting
Hable John Uncharted2 Hdr Lighting
Hable John Uncharted2 Hdr Lighting
Hable John Uncharted2 Hdr Lighting
Hable John Uncharted2 Hdr Lighting
Hable John Uncharted2 Hdr Lighting
Hable John Uncharted2 Hdr Lighting
Hable John Uncharted2 Hdr Lighting
Hable John Uncharted2 Hdr Lighting
Hable John Uncharted2 Hdr Lighting
Hable John Uncharted2 Hdr Lighting
Hable John Uncharted2 Hdr Lighting
Hable John Uncharted2 Hdr Lighting
Hable John Uncharted2 Hdr Lighting
Hable John Uncharted2 Hdr Lighting
Upcoming SlideShare
Loading in …5
×

of

Hable John Uncharted2 Hdr Lighting Slide 1 Hable John Uncharted2 Hdr Lighting Slide 2 Hable John Uncharted2 Hdr Lighting Slide 3 Hable John Uncharted2 Hdr Lighting Slide 4 Hable John Uncharted2 Hdr Lighting Slide 5 Hable John Uncharted2 Hdr Lighting Slide 6 Hable John Uncharted2 Hdr Lighting Slide 7 Hable John Uncharted2 Hdr Lighting Slide 8 Hable John Uncharted2 Hdr Lighting Slide 9 Hable John Uncharted2 Hdr Lighting Slide 10 Hable John Uncharted2 Hdr Lighting Slide 11 Hable John Uncharted2 Hdr Lighting Slide 12 Hable John Uncharted2 Hdr Lighting Slide 13 Hable John Uncharted2 Hdr Lighting Slide 14 Hable John Uncharted2 Hdr Lighting Slide 15 Hable John Uncharted2 Hdr Lighting Slide 16 Hable John Uncharted2 Hdr Lighting Slide 17 Hable John Uncharted2 Hdr Lighting Slide 18 Hable John Uncharted2 Hdr Lighting Slide 19 Hable John Uncharted2 Hdr Lighting Slide 20 Hable John Uncharted2 Hdr Lighting Slide 21 Hable John Uncharted2 Hdr Lighting Slide 22 Hable John Uncharted2 Hdr Lighting Slide 23 Hable John Uncharted2 Hdr Lighting Slide 24 Hable John Uncharted2 Hdr Lighting Slide 25 Hable John Uncharted2 Hdr Lighting Slide 26 Hable John Uncharted2 Hdr Lighting Slide 27 Hable John Uncharted2 Hdr Lighting Slide 28 Hable John Uncharted2 Hdr Lighting Slide 29 Hable John Uncharted2 Hdr Lighting Slide 30 Hable John Uncharted2 Hdr Lighting Slide 31 Hable John Uncharted2 Hdr Lighting Slide 32 Hable John Uncharted2 Hdr Lighting Slide 33 Hable John Uncharted2 Hdr Lighting Slide 34 Hable John Uncharted2 Hdr Lighting Slide 35 Hable John Uncharted2 Hdr Lighting Slide 36 Hable John Uncharted2 Hdr Lighting Slide 37 Hable John Uncharted2 Hdr Lighting Slide 38 Hable John Uncharted2 Hdr Lighting Slide 39 Hable John Uncharted2 Hdr Lighting Slide 40 Hable John Uncharted2 Hdr Lighting Slide 41 Hable John Uncharted2 Hdr Lighting Slide 42 Hable John Uncharted2 Hdr Lighting Slide 43 Hable John Uncharted2 Hdr Lighting Slide 44 Hable John Uncharted2 Hdr Lighting Slide 45 Hable John Uncharted2 Hdr Lighting Slide 46 Hable John Uncharted2 Hdr Lighting Slide 47 Hable John Uncharted2 Hdr Lighting Slide 48 Hable John Uncharted2 Hdr Lighting Slide 49 Hable John Uncharted2 Hdr Lighting Slide 50 Hable John Uncharted2 Hdr Lighting Slide 51 Hable John Uncharted2 Hdr Lighting Slide 52 Hable John Uncharted2 Hdr Lighting Slide 53 Hable John Uncharted2 Hdr Lighting Slide 54 Hable John Uncharted2 Hdr Lighting Slide 55 Hable John Uncharted2 Hdr Lighting Slide 56 Hable John Uncharted2 Hdr Lighting Slide 57 Hable John Uncharted2 Hdr Lighting Slide 58 Hable John Uncharted2 Hdr Lighting Slide 59 Hable John Uncharted2 Hdr Lighting Slide 60 Hable John Uncharted2 Hdr Lighting Slide 61 Hable John Uncharted2 Hdr Lighting Slide 62 Hable John Uncharted2 Hdr Lighting Slide 63 Hable John Uncharted2 Hdr Lighting Slide 64 Hable John Uncharted2 Hdr Lighting Slide 65 Hable John Uncharted2 Hdr Lighting Slide 66 Hable John Uncharted2 Hdr Lighting Slide 67 Hable John Uncharted2 Hdr Lighting Slide 68 Hable John Uncharted2 Hdr Lighting Slide 69 Hable John Uncharted2 Hdr Lighting Slide 70 Hable John Uncharted2 Hdr Lighting Slide 71 Hable John Uncharted2 Hdr Lighting Slide 72 Hable John Uncharted2 Hdr Lighting Slide 73 Hable John Uncharted2 Hdr Lighting Slide 74 Hable John Uncharted2 Hdr Lighting Slide 75 Hable John Uncharted2 Hdr Lighting Slide 76 Hable John Uncharted2 Hdr Lighting Slide 77 Hable John Uncharted2 Hdr Lighting Slide 78 Hable John Uncharted2 Hdr Lighting Slide 79 Hable John Uncharted2 Hdr Lighting Slide 80 Hable John Uncharted2 Hdr Lighting Slide 81 Hable John Uncharted2 Hdr Lighting Slide 82 Hable John Uncharted2 Hdr Lighting Slide 83 Hable John Uncharted2 Hdr Lighting Slide 84 Hable John Uncharted2 Hdr Lighting Slide 85 Hable John Uncharted2 Hdr Lighting Slide 86 Hable John Uncharted2 Hdr Lighting Slide 87 Hable John Uncharted2 Hdr Lighting Slide 88 Hable John Uncharted2 Hdr Lighting Slide 89 Hable John Uncharted2 Hdr Lighting Slide 90 Hable John Uncharted2 Hdr Lighting Slide 91 Hable John Uncharted2 Hdr Lighting Slide 92 Hable John Uncharted2 Hdr Lighting Slide 93 Hable John Uncharted2 Hdr Lighting Slide 94 Hable John Uncharted2 Hdr Lighting Slide 95 Hable John Uncharted2 Hdr Lighting Slide 96 Hable John Uncharted2 Hdr Lighting Slide 97 Hable John Uncharted2 Hdr Lighting Slide 98 Hable John Uncharted2 Hdr Lighting Slide 99 Hable John Uncharted2 Hdr Lighting Slide 100 Hable John Uncharted2 Hdr Lighting Slide 101 Hable John Uncharted2 Hdr Lighting Slide 102 Hable John Uncharted2 Hdr Lighting Slide 103 Hable John Uncharted2 Hdr Lighting Slide 104 Hable John Uncharted2 Hdr Lighting Slide 105 Hable John Uncharted2 Hdr Lighting Slide 106 Hable John Uncharted2 Hdr Lighting Slide 107 Hable John Uncharted2 Hdr Lighting Slide 108 Hable John Uncharted2 Hdr Lighting Slide 109 Hable John Uncharted2 Hdr Lighting Slide 110 Hable John Uncharted2 Hdr Lighting Slide 111 Hable John Uncharted2 Hdr Lighting Slide 112 Hable John Uncharted2 Hdr Lighting Slide 113 Hable John Uncharted2 Hdr Lighting Slide 114 Hable John Uncharted2 Hdr Lighting Slide 115 Hable John Uncharted2 Hdr Lighting Slide 116 Hable John Uncharted2 Hdr Lighting Slide 117 Hable John Uncharted2 Hdr Lighting Slide 118 Hable John Uncharted2 Hdr Lighting Slide 119 Hable John Uncharted2 Hdr Lighting Slide 120 Hable John Uncharted2 Hdr Lighting Slide 121 Hable John Uncharted2 Hdr Lighting Slide 122 Hable John Uncharted2 Hdr Lighting Slide 123 Hable John Uncharted2 Hdr Lighting Slide 124 Hable John Uncharted2 Hdr Lighting Slide 125 Hable John Uncharted2 Hdr Lighting Slide 126 Hable John Uncharted2 Hdr Lighting Slide 127 Hable John Uncharted2 Hdr Lighting Slide 128 Hable John Uncharted2 Hdr Lighting Slide 129 Hable John Uncharted2 Hdr Lighting Slide 130 Hable John Uncharted2 Hdr Lighting Slide 131 Hable John Uncharted2 Hdr Lighting Slide 132 Hable John Uncharted2 Hdr Lighting Slide 133 Hable John Uncharted2 Hdr Lighting Slide 134 Hable John Uncharted2 Hdr Lighting Slide 135 Hable John Uncharted2 Hdr Lighting Slide 136 Hable John Uncharted2 Hdr Lighting Slide 137 Hable John Uncharted2 Hdr Lighting Slide 138 Hable John Uncharted2 Hdr Lighting Slide 139 Hable John Uncharted2 Hdr Lighting Slide 140 Hable John Uncharted2 Hdr Lighting Slide 141 Hable John Uncharted2 Hdr Lighting Slide 142 Hable John Uncharted2 Hdr Lighting Slide 143 Hable John Uncharted2 Hdr Lighting Slide 144 Hable John Uncharted2 Hdr Lighting Slide 145 Hable John Uncharted2 Hdr Lighting Slide 146 Hable John Uncharted2 Hdr Lighting Slide 147 Hable John Uncharted2 Hdr Lighting Slide 148 Hable John Uncharted2 Hdr Lighting Slide 149 Hable John Uncharted2 Hdr Lighting Slide 150 Hable John Uncharted2 Hdr Lighting Slide 151 Hable John Uncharted2 Hdr Lighting Slide 152 Hable John Uncharted2 Hdr Lighting Slide 153 Hable John Uncharted2 Hdr Lighting Slide 154 Hable John Uncharted2 Hdr Lighting Slide 155 Hable John Uncharted2 Hdr Lighting Slide 156 Hable John Uncharted2 Hdr Lighting Slide 157 Hable John Uncharted2 Hdr Lighting Slide 158 Hable John Uncharted2 Hdr Lighting Slide 159 Hable John Uncharted2 Hdr Lighting Slide 160 Hable John Uncharted2 Hdr Lighting Slide 161 Hable John Uncharted2 Hdr Lighting Slide 162 Hable John Uncharted2 Hdr Lighting Slide 163 Hable John Uncharted2 Hdr Lighting Slide 164 Hable John Uncharted2 Hdr Lighting Slide 165 Hable John Uncharted2 Hdr Lighting Slide 166 Hable John Uncharted2 Hdr Lighting Slide 167 Hable John Uncharted2 Hdr Lighting Slide 168 Hable John Uncharted2 Hdr Lighting Slide 169 Hable John Uncharted2 Hdr Lighting Slide 170 Hable John Uncharted2 Hdr Lighting Slide 171 Hable John Uncharted2 Hdr Lighting Slide 172 Hable John Uncharted2 Hdr Lighting Slide 173 Hable John Uncharted2 Hdr Lighting Slide 174 Hable John Uncharted2 Hdr Lighting Slide 175 Hable John Uncharted2 Hdr Lighting Slide 176 Hable John Uncharted2 Hdr Lighting Slide 177 Hable John Uncharted2 Hdr Lighting Slide 178 Hable John Uncharted2 Hdr Lighting Slide 179 Hable John Uncharted2 Hdr Lighting Slide 180 Hable John Uncharted2 Hdr Lighting Slide 181 Hable John Uncharted2 Hdr Lighting Slide 182 Hable John Uncharted2 Hdr Lighting Slide 183 Hable John Uncharted2 Hdr Lighting Slide 184 Hable John Uncharted2 Hdr Lighting Slide 185 Hable John Uncharted2 Hdr Lighting Slide 186 Hable John Uncharted2 Hdr Lighting Slide 187 Hable John Uncharted2 Hdr Lighting Slide 188 Hable John Uncharted2 Hdr Lighting Slide 189 Hable John Uncharted2 Hdr Lighting Slide 190 Hable John Uncharted2 Hdr Lighting Slide 191 Hable John Uncharted2 Hdr Lighting Slide 192 Hable John Uncharted2 Hdr Lighting Slide 193 Hable John Uncharted2 Hdr Lighting Slide 194 Hable John Uncharted2 Hdr Lighting Slide 195 Hable John Uncharted2 Hdr Lighting Slide 196 Hable John Uncharted2 Hdr Lighting Slide 197 Hable John Uncharted2 Hdr Lighting Slide 198 Hable John Uncharted2 Hdr Lighting Slide 199 Hable John Uncharted2 Hdr Lighting Slide 200 Hable John Uncharted2 Hdr Lighting Slide 201 Hable John Uncharted2 Hdr Lighting Slide 202 Hable John Uncharted2 Hdr Lighting Slide 203 Hable John Uncharted2 Hdr Lighting Slide 204 Hable John Uncharted2 Hdr Lighting Slide 205 Hable John Uncharted2 Hdr Lighting Slide 206 Hable John Uncharted2 Hdr Lighting Slide 207 Hable John Uncharted2 Hdr Lighting Slide 208 Hable John Uncharted2 Hdr Lighting Slide 209 Hable John Uncharted2 Hdr Lighting Slide 210 Hable John Uncharted2 Hdr Lighting Slide 211 Hable John Uncharted2 Hdr Lighting Slide 212 Hable John Uncharted2 Hdr Lighting Slide 213 Hable John Uncharted2 Hdr Lighting Slide 214 Hable John Uncharted2 Hdr Lighting Slide 215 Hable John Uncharted2 Hdr Lighting Slide 216 Hable John Uncharted2 Hdr Lighting Slide 217 Hable John Uncharted2 Hdr Lighting Slide 218 Hable John Uncharted2 Hdr Lighting Slide 219 Hable John Uncharted2 Hdr Lighting Slide 220 Hable John Uncharted2 Hdr Lighting Slide 221 Hable John Uncharted2 Hdr Lighting Slide 222 Hable John Uncharted2 Hdr Lighting Slide 223 Hable John Uncharted2 Hdr Lighting Slide 224 Hable John Uncharted2 Hdr Lighting Slide 225 Hable John Uncharted2 Hdr Lighting Slide 226 Hable John Uncharted2 Hdr Lighting Slide 227 Hable John Uncharted2 Hdr Lighting Slide 228 Hable John Uncharted2 Hdr Lighting Slide 229 Hable John Uncharted2 Hdr Lighting Slide 230 Hable John Uncharted2 Hdr Lighting Slide 231 Hable John Uncharted2 Hdr Lighting Slide 232 Hable John Uncharted2 Hdr Lighting Slide 233 Hable John Uncharted2 Hdr Lighting Slide 234 Hable John Uncharted2 Hdr Lighting Slide 235 Hable John Uncharted2 Hdr Lighting Slide 236 Hable John Uncharted2 Hdr Lighting Slide 237 Hable John Uncharted2 Hdr Lighting Slide 238 Hable John Uncharted2 Hdr Lighting Slide 239 Hable John Uncharted2 Hdr Lighting Slide 240 Hable John Uncharted2 Hdr Lighting Slide 241 Hable John Uncharted2 Hdr Lighting Slide 242 Hable John Uncharted2 Hdr Lighting Slide 243 Hable John Uncharted2 Hdr Lighting Slide 244 Hable John Uncharted2 Hdr Lighting Slide 245 Hable John Uncharted2 Hdr Lighting Slide 246 Hable John Uncharted2 Hdr Lighting Slide 247 Hable John Uncharted2 Hdr Lighting Slide 248 Hable John Uncharted2 Hdr Lighting Slide 249 Hable John Uncharted2 Hdr Lighting Slide 250 Hable John Uncharted2 Hdr Lighting Slide 251 Hable John Uncharted2 Hdr Lighting Slide 252 Hable John Uncharted2 Hdr Lighting Slide 253 Hable John Uncharted2 Hdr Lighting Slide 254 Hable John Uncharted2 Hdr Lighting Slide 255 Hable John Uncharted2 Hdr Lighting Slide 256 Hable John Uncharted2 Hdr Lighting Slide 257 Hable John Uncharted2 Hdr Lighting Slide 258 Hable John Uncharted2 Hdr Lighting Slide 259 Hable John Uncharted2 Hdr Lighting Slide 260 Hable John Uncharted2 Hdr Lighting Slide 261 Hable John Uncharted2 Hdr Lighting Slide 262 Hable John Uncharted2 Hdr Lighting Slide 263 Hable John Uncharted2 Hdr Lighting Slide 264 Hable John Uncharted2 Hdr Lighting Slide 265 Hable John Uncharted2 Hdr Lighting Slide 266 Hable John Uncharted2 Hdr Lighting Slide 267 Hable John Uncharted2 Hdr Lighting Slide 268 Hable John Uncharted2 Hdr Lighting Slide 269 Hable John Uncharted2 Hdr Lighting Slide 270 Hable John Uncharted2 Hdr Lighting Slide 271 Hable John Uncharted2 Hdr Lighting Slide 272 Hable John Uncharted2 Hdr Lighting Slide 273 Hable John Uncharted2 Hdr Lighting Slide 274 Hable John Uncharted2 Hdr Lighting Slide 275 Hable John Uncharted2 Hdr Lighting Slide 276 Hable John Uncharted2 Hdr Lighting Slide 277 Hable John Uncharted2 Hdr Lighting Slide 278 Hable John Uncharted2 Hdr Lighting Slide 279 Hable John Uncharted2 Hdr Lighting Slide 280 Hable John Uncharted2 Hdr Lighting Slide 281 Hable John Uncharted2 Hdr Lighting Slide 282 Hable John Uncharted2 Hdr Lighting Slide 283 Hable John Uncharted2 Hdr Lighting Slide 284 Hable John Uncharted2 Hdr Lighting Slide 285 Hable John Uncharted2 Hdr Lighting Slide 286 Hable John Uncharted2 Hdr Lighting Slide 287 Hable John Uncharted2 Hdr Lighting Slide 288 Hable John Uncharted2 Hdr Lighting Slide 289 Hable John Uncharted2 Hdr Lighting Slide 290 Hable John Uncharted2 Hdr Lighting Slide 291 Hable John Uncharted2 Hdr Lighting Slide 292 Hable John Uncharted2 Hdr Lighting Slide 293 Hable John Uncharted2 Hdr Lighting Slide 294 Hable John Uncharted2 Hdr Lighting Slide 295 Hable John Uncharted2 Hdr Lighting Slide 296 Hable John Uncharted2 Hdr Lighting Slide 297 Hable John Uncharted2 Hdr Lighting Slide 298 Hable John Uncharted2 Hdr Lighting Slide 299 Hable John Uncharted2 Hdr Lighting Slide 300 Hable John Uncharted2 Hdr Lighting Slide 301 Hable John Uncharted2 Hdr Lighting Slide 302 Hable John Uncharted2 Hdr Lighting Slide 303 Hable John Uncharted2 Hdr Lighting Slide 304 Hable John Uncharted2 Hdr Lighting Slide 305 Hable John Uncharted2 Hdr Lighting Slide 306 Hable John Uncharted2 Hdr Lighting Slide 307 Hable John Uncharted2 Hdr Lighting Slide 308 Hable John Uncharted2 Hdr Lighting Slide 309 Hable John Uncharted2 Hdr Lighting Slide 310 Hable John Uncharted2 Hdr Lighting Slide 311 Hable John Uncharted2 Hdr Lighting Slide 312 Hable John Uncharted2 Hdr Lighting Slide 313
Upcoming SlideShare
機械学習とその理論 (情報オリンピック2015春合宿講義資料)
Next
Download to read offline and view in fullscreen.

80 Likes

Share

Download to read offline

Hable John Uncharted2 Hdr Lighting

Download to read offline

http://ozlael.egloos.com

Related Books

Free with a 30 day trial from Scribd

See all

Related Audiobooks

Free with a 30 day trial from Scribd

See all

Hable John Uncharted2 Hdr Lighting

  1. 1. Uncharted 2: HDR Lighting<br />John Hable<br />Naughty Dog<br />
  2. 2. Agenda<br />Gamma/Linear-Space Lighting<br />Filmic Tonemapping<br />SSAO<br />Rendering Architecture/How it all fits together.<br />
  3. 3. Skeletons in the Closet<br /><ul><li>Used to work for EA Black Box (Vancouver)‏
  4. 4. Ucap Project
  5. 5. I.e. Tiger Woods's Face
  6. 6. Also used to work for EA Los Angeles
  7. 7. LMNO (Spielberg Project)‏
  8. 8. Not PQRS (Boom Blox)‏
  9. 9. Now at Naughty Dog
  10. 10. Uncharted 2</li></li></ul><li>Part 1: Gamma!<br />
  11. 11. Gamma<br /><ul><li>Mostly solved in Film Industry after lots of kicking and screaming
  12. 12. Never heard about it in college
  13. 13. George Borshukov taught it to me back at EA
  14. 14. Matrix Sequels
  15. 15. Issue is getting more traction now
  16. 16. Eugene d’Eon’s chapter in GPU Gems 3</li></li></ul><li>Demo<br /><ul><li>What is halfway between white and black
  17. 17. Suppose we show alternating light/dark lines.
  18. 18. If we squint, we get half the linear intensity.</li></li></ul><li>Demo<br /><ul><li>Test image with 4 rectangles.
  19. 19. Real image of a computer screen shot from my camera.</li></li></ul><li>Demo<br /><ul><li>Alternating lines of black and white (0 and 255).</li></li></ul><li>Demo<br /><ul><li>So if the left and right are alternating lines of 0 and 255, then what color is the rectangle with the blue dot?</li></li></ul><li>Demo<br /><ul><li>Common wrong answer: 127/128.
  20. 20. That’s the box on the top.</li></ul>128<br />
  21. 21. Demo<br /><ul><li>Correct answer is 187.
  22. 22. WTF?</li></ul>128<br />187<br />
  23. 23. Color Ramp<br /><ul><li>You have seen this before.</li></ul>0<br />127<br />255<br />187<br />
  24. 24. Gamma Lines<br />255<br /><ul><li>F(x) = pow(x,2.2)‏</li></ul>187<br />127<br />0<br />
  25. 25. What is Gamma<br /><ul><li>Gamma of 0.45, 1, 2.2
  26. 26. Our monitors are the red one</li></li></ul><li>We all love mink...<br /><ul><li>F(x) = x</li></li></ul><li>We all love mink...<br /><ul><li>F(x) = pow(x,0.45) note: .45 ~= 1/2.2‏</li></li></ul><li>We all love mink...<br /><ul><li>F(x) = pow(x,2.2)‏</li></li></ul><li>What is Gamma<br /><ul><li>Get to know these curves…</li></li></ul><li>What is Gamma<br /><ul><li>Back and forth between curves.</li></ul>2.2<br />2.2<br />.45<br />.45<br />
  27. 27. How bad is it?<br /><ul><li>Your monitor has a gamma of about 2.2
  28. 28. So if you output the left image to the framebuffer, it will actually look like the one right.</li></ul>2.2<br />
  29. 29. Let’s build a Camera…<br /><ul><li>A linear camera.</li></ul>Actual<br />Light<br />Monitor<br />Output<br />1.0<br />2.2<br />Hard<br />Drive<br />
  30. 30. Let’s build a Camera…<br /><ul><li>Any consumer camera.</li></ul>Actual<br />Light<br />Monitor<br />Output<br />.45<br />2.2<br />Hard<br />Drive<br />
  31. 31. How to fix this?<br /><ul><li>Your screen displays a gamma of 2.2
  32. 32. This is stored on your hard drive.
  33. 33. You never see this image, but it’s on your hard drive.</li></ul>2.2<br />
  34. 34. What is Gamma<br /><ul><li>Curves again.</li></li></ul><li>What is Gamma<br />Q) Why not just store as linear?<br />A) Our eyes perceive more data in the blacks.<br />
  35. 35. How bad is it?<br /><ul><li>Suppose we look at the 0-63 range.
  36. 36. What if displays were linear?</li></li></ul><li>Gamma<br /><ul><li>Gamma of 2.2 gives us more dark colors.</li></li></ul><li>How bad is it?<br /><ul><li>If displays were linear:
  37. 37. On a scale from 0-255
  38. 38. 0 would equal 0
  39. 39. 1 would equal our current value of 20
  40. 40. 2 would equal our current value of 28
  41. 41. 3 would equal our current value of 33
  42. 42. Darkest Values:</li></li></ul><li>Ramp Again<br /><ul><li>See any banding in the whites? </li></li></ul><li>3D Graphics<br /><ul><li>If your game is not gamma correct, it looks like the image on the left..
  43. 43. Note: we’re talking about “correct”, not “good”</li></li></ul><li>3D Graphics<br /><ul><li>Here's what is going on.</li></ul>Screen<br />Hard<br />Drive<br />Lighting<br />
  44. 44. 3D Graphics<br /><ul><li>Account for gamma when reading textures
  45. 45. color = pow( tex2D( Sampler, Uv ), 2.2 )‏
  46. 46. Do your lighting calculations
  47. 47. Account for gamma on color output
  48. 48. finalcolor = pow( color, 1/2.2 )‏</li></li></ul><li>3D Graphics<br /><ul><li>Here's what is going on.</li></ul>Monitor<br />Adjust<br />Hard<br />Drive<br />Lighting<br />Shader<br />Correct<br />Gamma<br />
  49. 49. 3D Graphics<br /><ul><li>Comparison again...</li></li></ul><li>3D Graphics<br /><ul><li>The Wrong Shader?</li></ul>Spec = CalSpec();<br />Diff = tex2D( Sampler, UV );<br />Color = Diff * max( 0, dot( N, L ) ) + Spec;<br />return Color;<br />
  50. 50. 3D Graphics<br /><ul><li>The Right Shader?</li></ul>Spec = CalSpec();<br />Diff = pow( tex2D( Sampler, UV ), 2.2 );<br />Color = Diff * max( 0, dot( N, L ) ) + Spec;<br />return pow( Color, 1/2.2);<br />
  51. 51. 3D Graphics<br /><ul><li>But, there is hardware to do this for us.
  52. 52. Hardware does sampling for free
  53. 53. For Texture read:
  54. 54. D3DSAMP_SRGBTEXTURE
  55. 55. For RenderTarget write:
  56. 56. D3DRS_SRGBWRITEENABLE</li></li></ul><li>3D Graphics<br /><ul><li>With those states we can remove the pow functions.</li></ul>Spec = CalSpec();<br />Diff = tex2D( Sampler, UV );<br />Color = Diff * max( 0, dot( N, L ) ) + Spec;<br />return Color;<br />
  57. 57. 3D Graphics<br /><ul><li>What does the real world look like?
  58. 58. Notice the harsh line.</li></li></ul><li>3D Graphics<br /><ul><li>Another Example</li></li></ul><li>FAQs<br />Q1) But I like the soft falloff!<br />A1) Don’t be so sure.<br />
  59. 59. FAQs<br /><ul><li>It looks like the one on top before the monitor’s 2.2</li></li></ul><li>Harsh Falloff<br /><ul><li>Devastating.</li></li></ul><li>Harsh Falloff<br /><ul><li>Devastating.</li></li></ul><li>Harsh Falloff<br /><ul><li>Devastating.</li></li></ul><li>Which Maps?<br /><ul><li>Which maps should be Linear-Space vs Gamma-Space?
  60. 60. Gamma-Space
  61. 61. Use sRGB hardware or pow(2.2) on read
  62. 62. 128 ~= 0.2
  63. 63. Linear-Space
  64. 64. Don’t use sRGB or pow(2.2) on read
  65. 65. 128 = 0.5</li></li></ul><li>Which Maps?<br /><ul><li>Diffuse Map
  66. 66. Definitely Gamma
  67. 67. Normal Map
  68. 68. Definitely Linear</li></li></ul><li>Which Maps?<br /><ul><li>Specular?
  69. 69. Uncharted 2 had them as Linear
  70. 70. Artists have trouble tweaking them to look right
  71. 71. Probably should be in Gamma</li></li></ul><li>Which Maps?<br /><ul><li>Ambient Occlusion
  72. 72. Technically, it’s a mathematical value like a normal map.
  73. 73. But artists tweak them a lot and bake extra lighting into them.
  74. 74. Uncharted 2 had them as Linear
  75. 75. Probably should be Gamma</li></li></ul><li>Exercise for the Reader<br /><ul><li>Gamma 2.2 != sRGB != Xenon PWL
  76. 76. sRGB: PC and PS3 gamma
  77. 77. Xenon PWL: Piecewise linear gamma</li></li></ul><li>Xenon Gotchas<br /><ul><li>Xbox 360 Gamma Curve is wonky
  78. 78. Way too bright at the low end.
  79. 79. HDR the Bungie Way, Chris Tchou
  80. 80. Post Processing in The Orange Box, Alex Vlachos
  81. 81. Output curve is extra contrasty
  82. 82. Henry LaBounta was going to talk about it.
  83. 83. Try hooking up your Xenon to a waveform monitor and display a test pattern. Prepare to be mortified.
  84. 84. Both factors counteract each other</li></li></ul><li>Linear-Space Lighting: Conclusion<br />“Drake! You must believe in linear-space lighting!”<br />
  85. 85. Part 2: Filmic Tonemaping<br />
  86. 86. Filmic Tonemapping<br /><ul><li>Let's talk about the magic of the human eye.</li></li></ul><li>Filmic Tonemapping<br /><ul><li>Real example from my apartment.
  87. 87. Full Auto settings.
  88. 88. Outside blown out.
  89. 89. Cello case looks empty.
  90. 90. My eye somehow adjusts...</li></li></ul><li>Filmic Tonemapping<br /><ul><li>Adaptiveness of human eye.</li></li></ul><li>Filmic Tonemapping<br /><ul><li>Adaptiveness of human eye.</li></li></ul><li>Filmic Tonemapping<br /><ul><li>Adaptiveness of human eye.</li></li></ul><li>Filmic Tonemapping<br /><ul><li>Adaptiveness of human eye.</li></li></ul><li>Filmic Tonemapping<br /><ul><li>Adaptiveness of human eye.</li></li></ul><li>Filmic Tonemapping<br /><ul><li>Adaptiveness of human eye.</li></li></ul><li>Filmic Tonemapping<br /><ul><li>Adaptiveness of human eye.</li></li></ul><li>Filmic Tonemapping<br /><ul><li>Adaptiveness of human eye.</li></li></ul><li>Filmic Tonemapping<br /><ul><li>One more</li></li></ul><li>Filmic Tonemapping<br /><ul><li>One more</li></li></ul><li>Gamma<br /><ul><li>Let’s take an HDR image
  91. 91. Note: 1 F-Stop is a power of two
  92. 92. So 4 F-stops is 2^4=16x difference in intensity</li></li></ul><li>Gamma<br /><ul><li>Exposure: -4</li></li></ul><li>Gamma<br /><ul><li>Exposure: -2</li></li></ul><li>Gamma<br /><ul><li>Exposure: 0</li></li></ul><li>Gamma<br /><ul><li>Exposure: 2</li></li></ul><li>Gamma<br /><ul><li>Exposure: 4</li></li></ul><li>Now what?<br /><ul><li>We actually need 8 stops
  93. 93. Good News: HDR Image
  94. 94. Bad News: Now what?
  95. 95. Re-tweaking exposure won't help</li></li></ul><li>Gamma<br /><ul><li>This is what Photography people call tonemapping.
  96. 96. Photomatix
  97. 97. This one is local
  98. 98. The one we’ll use is global</li></li></ul><li>Point of Confusion<br /><ul><li>Two problems to solve.
  99. 99. Simulate the Iris
  100. 100. Dynamic Range in different shots
  101. 101. Tunnel vs. Daylight
  102. 102. Simulate the Retina
  103. 103. Different Range within a shot
  104. 104. Inside looking outside</li></li></ul><li>Terminology<br /><ul><li>Photography/Film
  105. 105. Within a Shot – HDR Tonemapping
  106. 106. Different Shots – Choosing the correct exposure?
  107. 107. Video Games
  108. 108. Within a Shot – HDR Tonemapping
  109. 109. Different Shots – HDR Tonemapping?</li></li></ul><li>Terminology<br /><ul><li>For this presentation
  110. 110. Within a Shot – HDR Tonemapping
  111. 111. Different Shots
  112. 112. Automatic Exposure Adjustment
  113. 113. Dynamic Iris</li></li></ul><li>Linear Curve<br /><ul><li>Apartment of Habib Zargarpour
  114. 114. Creative Director, Microsoft Game Studios
  115. 115. Used to be Art Director on LMNO at EA</li></li></ul><li>Linear Curve<br /><ul><li>OutColor = pow(x,1/2.2)‏</li></li></ul><li>Reinhard<br /><ul><li>Most common tonemapping operator is Reinhard
  116. 116. Simplest version is:
  117. 117. F(x) = x/(x+1)
  118. 118. Yes, I’m oversimplifiying for time.</li></li></ul><li>Fade!<br /><ul><li>Let's fade from linear to Reinhard.</li></li></ul><li>Fade!<br /><ul><li>Let's fade from linear to Reinhard.</li></li></ul><li>Fade!<br /><ul><li>Let's fade from linear to Reinhard.</li></li></ul><li>Fade!<br /><ul><li>Let's fade from linear to Reinhard.</li></li></ul><li>Fade!<br /><ul><li>Let's fade from linear to Reinhard.</li></li></ul><li>Fade!<br /><ul><li>Let's fade from linear to Reinhard.</li></li></ul><li>Why Does this happen<br /><ul><li>Start with orange (255,88,21)‏</li></li></ul><li>Linear Curve<br /><ul><li>Linear curve at the low end and high end</li></li></ul><li>Bad Gamma<br /><ul><li>Better blacks actually, but wrong color at the bottom and horrible hue-shifting.</li></li></ul><li>Reinhard<br /><ul><li>Desaturated blacks, but nice top end.</li></li></ul><li>Color Changes<br /><ul><li>Gee...if only we could get:
  119. 119. The crisper, more saturated blacks of improper gamma.
  120. 120. The nice soft highlights of Reinhard
  121. 121. And get the input colors to actually match like pure linear.</li></li></ul><li>Voila!<br /><ul><li>Guess what? There is a solution!</li></li></ul><li>Voila!<br /><ul><li>Solution by Haarm-Peter Duiker
  122. 122. CG Supervisor at Digital Domain
  123. 123. Used to be a CG Supervisor on LMNO at EA</li></li></ul><li>Film<br />Q) Why do they still use film in movies?<br />A) The look.<br />
  124. 124. Film<br /><ul><li>Kodak film examples.</li></ul>Shoulder<br />Toe<br />
  125. 125. Film<br /><ul><li>Using a film curve solves tons of problems.
  126. 126. Film vs. Digital purists.
  127. 127. Who would’ve thought: Kodak knows how to make good film.</li></li></ul><li>Filmic Curve<br /><ul><li>Crisp blacks, saturated dark end, and nice highlights.</li></li></ul><li>Filmic Tonemapping<br /><ul><li>This technique works with any color.</li></ul>Reinhard<br />Linear<br />Filmic<br />
  128. 128. Filmic Tonemapping<br /><ul><li>This technique works with any color.</li></ul>Reinhard<br />Linear<br />Filmic<br />
  129. 129. Filmic Tonemapping<br /><ul><li>This technique works with any color.</li></ul>Reinhard<br />Linear<br />Filmic<br />
  130. 130. Filmic Tonemapping<br /><ul><li>This technique works with any color.</li></ul>Reinhard<br />Linear<br />Filmic<br />
  131. 131. Filmic Tonemapping<br /><ul><li>This technique works with any color.</li></ul>Reinhard<br />Linear<br />Filmic<br />
  132. 132. Filmic Tonemapping<br /><ul><li>This technique works with any color.</li></ul>Reinhard<br />Linear<br />Filmic<br />
  133. 133. Filmic Tonemapping<br /><ul><li>This technique works with any color.</li></ul>Reinhard<br />Linear<br />Filmic<br />
  134. 134. Filmic Tonemapping<br /><ul><li>This technique works with any color.</li></ul>Reinhard<br />Linear<br />Filmic<br />
  135. 135. Filmic Tonemapping<br /><ul><li>This technique works with any color.</li></ul>Reinhard<br />Linear<br />Filmic<br />
  136. 136. Filmic Tonemapping<br /><ul><li>In terms of “Crisp Blacks” vs. “Milky Blacks”
  137. 137. Filmic > Linear > Reinhard
  138. 138. In terms of “Soft Highights” vs. “Clamped Highlights”
  139. 139. Filmic = Reinhard > Linear</li></li></ul><li>Filmic Tonemapping<br /><ul><li>Linear.</li></li></ul><li>Filmic Tonemapping<br /><ul><li>Fade from linear to filmic.</li></li></ul><li>Filmic Tonemapping<br /><ul><li>Fade from linear to filmic.</li></li></ul><li>Filmic Tonemapping<br /><ul><li>Fade from linear to filmic.</li></li></ul><li>Filmic Tonemapping<br /><ul><li>Fade from linear to filmic.</li></li></ul><li>Filmic Tonemapping<br /><ul><li>Fade from linear to filmic.</li></li></ul><li>Filmic Tonemapping<br /><ul><li>Fade from linear to filmic.</li></li></ul><li>Filmic vs Reinhard<br /><ul><li>Fade from linear to Reinhard.</li></li></ul><li>Filmic Tonemapping<br /><ul><li>Fade from Reinhard to filmic.</li></li></ul><li>Filmic Tonemapping<br /><ul><li>Fade from Reinhard to filmic.</li></li></ul><li>Filmic Tonemapping<br /><ul><li>Fade from Reinhard to filmic.</li></li></ul><li>Filmic Tonemapping<br /><ul><li>Fade from Reinhard to filmic.</li></li></ul><li>Filmic Tonemapping<br /><ul><li>Fade from Reinhard to filmic.</li></li></ul><li>Filmic Tonemapping<br /><ul><li>Fade from Reinhard to filmic.</li></li></ul><li>Filmic Tonemapping<br /><ul><li>Let's do a comparison.</li></li></ul><li>Filmic Tonemapping<br /><ul><li>This is with a linear curve.</li></li></ul><li>Filmic Tonemapping<br /><ul><li>And here is filmic.</li></li></ul><li>Filmic Tonemapping<br /><ul><li>First, we'll go up.</li></li></ul><li>Filmic Tonemapping<br /><ul><li>Exposure 0</li></li></ul><li>Filmic Tonemapping<br /><ul><li>Exposure +1</li></li></ul><li>Filmic Tonemapping<br /><ul><li>Exposure +2</li></li></ul><li>Filmic Tonemapping<br /><ul><li>Exposure +3</li></li></ul><li>Filmic Tonemapping<br /><ul><li>Exposure +4</li></li></ul><li>Filmic Tonemapping<br /><ul><li>Ok, now that's bad.
  140. 140. What happens if we go down?
  141. 141. Notice the crisper blacks in the filmic version.</li></li></ul><li>Filmic Tonemapping<br /><ul><li>Exposure: 0</li></li></ul><li>Filmic Tonemapping<br /><ul><li>Exposure: -1</li></li></ul><li>Filmic Tonemapping<br /><ul><li>Exposure: -2</li></li></ul><li>Filmic Tonemapping<br /><ul><li>Exposure: -3</li></li></ul><li>Filmic Tonemapping<br /><ul><li>Exposure: -4</li></li></ul><li>Filmic Tonemapping<br /><ul><li>Colors get crisper and more saturated at the bottom end.</li></li></ul><li>Filmic Tonemapping<br />float3 ld = 0.002;<br />float linReference = 0.18;<br />float logReference = 444;<br />float logGamma = 0.45;<br />outColor.rgb = (log10(0.4*outColor.rgb/linReference)/ld*logGamma + logReference)/1023.f;<br />outColor.rgb = clamp(outColor.rgb , 0, 1);<br />float FilmLutWidth = 256;<br />float Padding = .5/FilmLutWidth;<br />outColor.r = tex2D(FilmLutSampler, float2( lerp(Padding,1-Padding,outColor.r), .5)).r;<br />outColor.g = tex2D(FilmLutSampler, float2( lerp(Padding,1-Padding,outColor.g), .5)).r;<br />outColor.b = tex2D(FilmLutSampler, float2( lerp(Padding,1-Padding,outColor.b), .5)).r;<br />
  142. 142. Filmic Tonemapping<br /><ul><li>Variation in white section:</li></ul>254<br />248<br />224<br />240<br />252<br />
  143. 143. More Magic<br /><ul><li>The catch:
  144. 144. Three texture lookups
  145. 145. Jim Hejl to the rescue</li></ul> Principle Member of Technical Staff<br /> GPU Group, Office of the CTO<br /> AMD Research<br /><ul><li>Used to work for EA</li></li></ul><li>More Magic<br /><ul><li>Awesome approximation with only ALU ops.
  146. 146. Replaces the entire Lin/Log and Texture LUT
  147. 147. Includes the pow(x,1/2.2)‏</li></ul>x = max(0, LinearColor-0.004);<br />GammaColor = (x*(6.2*x+0.5))/(x*(6.2*x+1.7)+0.06);<br />
  148. 148. Filmic Tonemapping<br /><ul><li>Nice curve
  149. 149. Toe arguably too strong
  150. 150. Most monitors are too contrasty, strong toe makes it worse
  151. 151. May want less shoulder
  152. 152. The more range, the more shoulder
  153. 153. If your scene lacks range, you want to tone down the shoulder a bit</li></li></ul><li>Filmic Tonemapping<br />A = Shoulder Strength<br />B = Linear Strength<br />C = Linear Angle<br />D = Toe Strength<br />E = Toe Numerator<br />F = Toe Denominator<br />Note: E/F = Toe Angle<br />LinearWhite = Linear White Point Value<br />F(x) = ((x*(A*x+C*B)+D*E)/(x*(A*x+B)+D*F)) - E/F;<br />FinalColor = F(LinearColor)/F(LinearWhite)‏<br />
  154. 154. Filmic Tonemapping<br />Shoulder Strength = 0.22<br />Linear Strength = 0.30<br />Linear Angle = 0.10<br />Toe Strength = 0.20<br />Toe Numerator = 0.01<br />Toe Denominator = 0.30<br />Linear White Point Value = 11.2<br />These numbers DO NOT have the pow(x,1/2.2) baked in<br />
  155. 155. Conclusions<br /><ul><li>Filmic Tonemapping
  156. 156. IMO: The most important post effect
  157. 157. Changes your life completely
  158. 158. Once you have it, you can't live without it
  159. 159. If you implement it, you have to redo all your lighting
  160. 160. You can't just switch it on if your lighting is tweaked for no dynamic range.</li></li></ul><li>Filmic Tonemapping<br />“At least I’m not getting choked in gamma space...”<br />
  161. 161. Part 3: SSAO<br />
  162. 162. SSAO Time<br /><ul><li>That was fun.
  163. 163. Time for stage 3.
  164. 164. Let’s talk about why you need AO.</li></li></ul><li>Why AO?<br /><ul><li>The shadow “grounds” the car.</li></li></ul><li>Why AO?<br /><ul><li>Unless you’re already in the shadow!</li></li></ul><li>Why AO?<br /><ul><li>Your shadow can't help you now!</li></li></ul><li>Why AO?<br /><ul><li>Your shadow can't help you now!</li></li></ul><li>Why AO?<br /><ul><li>Your shadow can't help you now!</li></li></ul><li>Why AO?<br /><ul><li>Your shadow can't help you now!</li></li></ul><li>How important is it?<br /><ul><li>The shadow from the sun grounds object.
  165. 165. But if you are already in shadow, you need something else...
  166. 166. It's the AO that grounds the car in those shots.
  167. 167. So what if we took the AO out?
  168. 168. Trick taught to me by Habib (the guy with the awesome condo earlier)‏</li></li></ul><li>Why AO?<br /><ul><li>Your shadow can't help you now!</li></li></ul><li>Why AO?<br /><ul><li>Your shadow can't help you now!</li></li></ul><li>Why AO?<br /><ul><li>Your shadow can't help you now!</li></li></ul><li>Why AO?<br /><ul><li>Your shadow can't help you now!</li></li></ul><li>Why AO?<br /><ul><li>Your shadow can't help you now!</li></li></ul><li>Why AO?<br /><ul><li>Your shadow can't help you now!</li></li></ul><li>Why AO?<br /><ul><li>Your shadow can't help you now!</li></li></ul><li>Why AO?<br /><ul><li>Your shadow can't help you now!</li></li></ul><li>How to use AO?<br /><ul><li>Sun is Directional Light
  169. 169. Sky is Hemisphere Light (ish)‏</li></li></ul><li>How to use AO?<br /><ul><li>Sun is Yellow (ish)‏
  170. 170. Sky is Blue (ish)‏</li></li></ul><li>How to use AO?<br /><ul><li>Sun is Directional
  171. 171. Approximate Directional Shadow with Shadow Mapping</li></li></ul><li>How to use AO?<br /><ul><li>Sky is Hemisphere (sorta)‏
  172. 172. Approximate Hemisphere Shadow with AO</li></li></ul><li>How to use AO?<br /><ul><li>Sun is yellow, sky is blue.</li></li></ul><li>How to use AO?<br />
  173. 173. How to use AO?<br />
  174. 174. How to use AO?<br />
  175. 175. How to use AO?<br />
  176. 176. How to use AO?<br />
  177. 177. Sunlight<br />Q) Why not have it affect sunlight?<br />A) It does the exact opposite of what you want it to do.<br />
  178. 178. SSAO Example<br /><ul><li>Off</li></li></ul><li>SSAO Example<br /><ul><li>On</li></li></ul><li>SSAO Example<br /><ul><li>SSAO Darkens Shadows – Good
  179. 179. SSAO Darkens Sunlight – BAD
  180. 180. Reduces perceived contrast
  181. 181. Makes lighting look flatter
  182. 182. My Opinion: SSAO should NOT affect Direct Light</li></li></ul><li>The Algorithm<br /><ul><li>Only Input is Half-Res Depth
  183. 183. No normals
  184. 184. No special filtering (I.e. Bilateral)‏
  185. 185. Processed in 64x64 blocks
  186. 186. Adjacent Depth tiles included as well</li></li></ul><li>The Algorithm<br /><ul><li>Calculate Base AO
  187. 187. Dilate Horizontal
  188. 188. Dilate Vertical
  189. 189. Apply Low Pass Filter</li></li></ul><li>SSAO Passes<br />0) Base Image<br />
  190. 190. SSAO Passes<br />1) Base SSAO<br />
  191. 191. SSAO Passes<br />2) Dilate Horizontal<br />
  192. 192. SSAO Passes<br />3) Dilate Vertical<br />
  193. 193. SSAO Passes<br />4) Low Pass Filter<br /> (I.e. blur the $&%@ out of it)‏<br />
  194. 194. SSAO Passes<br /><ul><li>Step One: The Base AO
  195. 195. Uses half-res depth buffer
  196. 196. Calculate AO based on nearby depth samples</li></li></ul><li>SSAO Passes<br /><ul><li>Pink point on a black surface.</li></li></ul><li>SSAO Passes<br /><ul><li>Correct way is to look at the hemisphere...</li></li></ul><li>SSAO Passes<br /><ul><li>...and find the area that is visible to the point.
  197. 197. Our solution is much hackier.</li></li></ul><li>SSAO Passes<br /><ul><li>Who needs sphere? A box will do just as well.</li></li></ul><li>SSAO Passes<br /><ul><li>Instead of area though, we will approximate volume.</li></li></ul><li>SSAO Passes<br /><ul><li>We can estimate volume without knowing the normal.
  198. 198. Half Volume = Fully Unoccluded</li></li></ul><li>SSAO Passes<br /><ul><li>We can estimate volume without knowing the normal.
  199. 199. Half Volume = Fully Unoccluded</li></li></ul><li>SSAO Passes<br /><ul><li>We can estimate volume without knowing the normal.
  200. 200. Half Volume = Fully Unoccluded</li></li></ul><li>SSAO Passes<br /><ul><li>We can estimate volume without knowing the normal.
  201. 201. Half Volume = Fully Unoccluded</li></li></ul><li>SSAO Passes<br /><ul><li>Start with a point</li></li></ul><li>SSAO Passes<br /><ul><li>And sample pairs of points.</li></li></ul><li>SSAO Passes<br /><ul><li>What if we have an occluder?</li></li></ul><li>SSAO Passes<br /><ul><li>What if we have an occluder?</li></li></ul><li>SSAO Passes<br /><ul><li>We lose depth info.</li></li></ul><li>SSAO Passes<br /><ul><li>We could call it occluded.</li></li></ul><li>SSAO Passes<br /><ul><li>But, is that correct? Maybe not.</li></li></ul><li>SSAO Passes<br /><ul><li>Let's choose a cutoff, and mark the pair as invalid.</li></li></ul><li>SSAO Passes<br /><ul><li>Sample pattern?</li></li></ul><li>SSAO Passes<br /><ul><li>Sample pattern. Discard in pairs.</li></li></ul><li>SSAO Passes<br /><ul><li>Note the single light outline.</li></li></ul><li>SSAO Passes<br /><ul><li>Find discontinuties...</li></li></ul><li>SSAO Passes<br /><ul><li>Find discontinuties...</li></li></ul><li>SSAO Passes<br /><ul><li>Find discontinuties...</li></li></ul><li>SSAO Passes<br /><ul><li>Find discontinuties...</li></li></ul><li>SSAO Passes<br /><ul><li>...and dilate at discontinuties. Here is original.</li></li></ul><li>SSAO Passes<br /><ul><li>After X dilate.</li></li></ul><li>SSAO Passes<br /><ul><li>After Y dilate. And the light outline is gone.</li></li></ul><li>SSAO Passes<br /><ul><li>And do a gaussian blur.</li></li></ul><li>SSAO Passes<br /><ul><li>Final</li></li></ul><li>Artifacts<br />White Outline<br />Crossing Pattern<br />Depth Discontinuities<br />
  202. 202. Artifacts<br /><ul><li>Blur adds white outline
  203. 203. Crossing Pattern</li></li></ul><li>Artifacts<br /><ul><li>More Crossing patterns</li></li></ul><li>Artifacts<br /><ul><li>Depth Discontinuities. Notice a little anti-halo.</li></li></ul><li>Artifacts<br /><ul><li>Hard to see in real levels though.</li></li></ul><li>Artifacts<br /><ul><li>Artifacts are usually only noticeable to the trained eye
  204. 204. Benefits outweigh drawbacks
  205. 205. Have option to turn it off per surface
  206. 206. Most snow fades at distance
  207. 207. Some objects apply sqrt() to brighten it
  208. 208. Some objects just have it off</li></li></ul><li>More Shots<br /><ul><li>On</li></li></ul><li>More Shots<br /><ul><li>Off</li></li></ul><li>More Shots<br /><ul><li>Here's a few more shots.</li></li></ul><li>More Shots<br /><ul><li>Here's a few more shots.</li></li></ul><li>More Shots<br /><ul><li>Here's a few more shots.</li></li></ul><li>More Shots<br /><ul><li>Here's a few more shots.</li></li></ul><li>More Shots<br /><ul><li>Here's a few more shots.</li></li></ul><li>More Shots<br /><ul><li>Here's a few more shots.</li></li></ul><li>More Shots<br /><ul><li>Here's a few more shots.</li></li></ul><li>More Shots<br /><ul><li>Here's a few more shots.</li></li></ul><li>More Shots<br /><ul><li>Here's a few more shots.</li></li></ul><li>More Shots<br /><ul><li>Here's a few more shots.</li></li></ul><li>SSAO Conclusion<br /><ul><li>Grounds characters and other objects
  209. 209. Deepens our Blacks
  210. 210. Artifacts are not too bad
  211. 211. Could use better filtering for halos
  212. 212. Runs on SPUs, and doesn’t need normal buffer</li></li></ul><li>Part 4: Architecture<br />
  213. 213. Architecture<br /><ul><li>Time for part 4.
  214. 214. Here is the base overview.
  215. 215. Skip some things</li></li></ul><li>Rendering Passes<br /><ul><li>Final output</li></li></ul><li>Rendering Passes<br /><ul><li>Depth and Normal, 2x MSAA</li></li></ul><li>Rendering Passes<br /><ul><li>Shadow depths for cascades</li></li></ul><li>Rendering Passes<br /><ul><li>Cascade calculation to screen-space</li></li></ul><li>Rendering Passes<br /><ul><li>Meanwhile on the SPUs...</li></li></ul><li>Rendering Passes<br /><ul><li>SSAO</li></li></ul><li>Rendering Passes<br /><ul><li>Fullscreen lighting. Diffuse and specular.
  216. 216. Calculate lighting in Tiles</li></li></ul><li>Rendering Passes<br /><ul><li>Back on the GPU...</li></li></ul><li>Rendering Passes<br /><ul><li>Render to RGBM, 2x MSAA</li></li></ul><li>Rendering Passes<br /><ul><li>Resolve RGBM 2x MSAA to FP16 1x</li></li></ul><li>Rendering Passes<br /><ul><li>Transparent objects and post.</li></li></ul><li>Full Timeline<br /><ul><li>Full Rendering Pipeline</li></li></ul><li>Full Timeline<br /><ul><li>Full Render in 3 frames</li></li></ul><li>Frame 1<br /><ul><li>Begin Frame 1.</li></li></ul><li>Frame 1<br /><ul><li>Timeline</li></ul>SPUs<br />GPU<br />PPU<br />
  217. 217. Frame 1<br /><ul><li>Begin Frame 1.</li></li></ul><li>Frame 1<br /><ul><li>All PPU stuff.</li></li></ul><li>Frame 1<br /><ul><li>PPU kicks off SPU jobs</li></li></ul><li>Frame 2<br /><ul><li>Does most of the rendering.</li></li></ul><li>Frame 2<br /><ul><li>Vertex processing on SPUs...</li></li></ul><li>Frame 2<br /><ul><li>...kicks of 2x DepthNormal pass.</li></li></ul><li>Frame 2<br /><ul><li>Resolve 2x MSAA buffers to 1x and copy.</li></li></ul><li>Frame 2<br /><ul><li>Spotlight shadow depth pass.</li></li></ul><li>Frame 2<br /><ul><li>Sunlight shadow depth pass.</li></li></ul><li>Frame 2<br /><ul><li>Kick Fullscreen Lighting SPU jobs.</li></li></ul><li>Frame 2<br /><ul><li>SSAO Jobs.</li></li></ul><li>Frame 2<br /><ul><li>Motion Blur</li></li></ul><li>Frame 2<br /><ul><li>Resolve shadow to screen. Copy Fullscreen lighting.</li></li></ul><li>Frame 2<br /><ul><li>Add Fullscreen shadowed lights.</li></li></ul><li>Frame 2<br /><ul><li>Standard Pass Vertex Processing on SPUs.</li></li></ul><li>Frame 2<br /><ul><li>Standard pass. Writes to 2x RGBM.</li></li></ul><li>Frame 2<br /><ul><li>Resolve 2x RGBM to 1x FP16</li></li></ul><li>Frame 2<br /><ul><li>Full-Res Alpha-Blended effects.</li></li></ul><li>Frame 2<br /><ul><li>Half-Res Particles and Composite.</li></li></ul><li>Frame 3<br /><ul><li>Now for the 3rd frame.</li></li></ul><li>Frame 3<br /><ul><li>Start PostFX jobs at end of Frame 2.</li></li></ul><li>Frame 3<br /><ul><li>Fill in PostFX jobs in Frame 3 with low priority.</li></li></ul><li>Frame 3<br /><ul><li>Read from main memory, do distortion and HUD.</li></li></ul><li>Full Timeline<br /><ul><li>All together.</li></li></ul><li>SPU Optimization<br /><ul><li>Quick notes on how we optimize SPU code.</li></li></ul><li>Performance<br /><ul><li>Yes! You can optimize SPU code by hand!
  218. 218. This was news to me when I started here.</li></li></ul><li>Performance<br /><ul><li>Let’s talk about Laundry
  219. 219. Say you have 5 loads to do
  220. 220. 1 washer, 1 dryer</li></li></ul><li>In-Order<br /><ul><li>Load 1 in Washer
  221. 221. Load 1 in Dryer
  222. 222. Load 2 in Washer
  223. 223. Load 2 in Dryer
  224. 224. Load 3 in Washer
  225. 225. Load 3 in Dryer
  226. 226. Load 4 in Washer
  227. 227. Load 4 in Dryer
  228. 228. Load 5 in Washer
  229. 229. Load 5 in Dryer</li></li></ul><li>Pipelined<br /><ul><li>Load 1 in Washer
  230. 230. Load 2 in Washer, Load 1 in Dryer
  231. 231. Load 3 in Washer, Load 2 in Dryer
  232. 232. Load 4 in Washer, Load 3 in Dryer
  233. 233. Load 5 in Washer, Load 4 in Dryer
  234. 234. Load 5 in Dryer</li></li></ul><li>Software Pipelining<br /><ul><li>We can do this in software
  235. 235. Called “Software Pipelining”
  236. 236. It’s how we optimize SPU code by hand
  237. 237. Pal Engstad (our Lead Graphics Programmer) will be putting a doc online explaining the full process.
  238. 238. Should be online: look for the post on the blog
  239. 239. Direct links:
  240. 240. www.naughtydog.com/docs/gdc2010/intro-spu-optimizations-part-1.pdf
  241. 241. www.naughtydog.com/docs/gdc2010/intro-spu-optimizations-part-2.pdf</li></li></ul><li>SPU C++ Intrinsics<br />for( int y = 0; y < clampHeight; y++ ) {<br />intlColorOffset = y * kAoBufferLineWidth;<br /> VF32 currWordAo = pvColor[ lColorOffset / 4 ];<br />prevWordAo[0] = prevWordAo[1] = prevWordAo[2] = prevWordAo[3] = currWordAo[0];<br /> ao_n4 = prevWordAo;<br /> ao_n3 = (VF32)si_shufb( (qword)prevWordAo, (qword)currWordAo, (qword)s_BCDa );<br /> ao_n2 = (VF32)si_shufb( (qword)prevWordAo, (qword)currWordAo, (qword)s_CDab );<br /> ao_n1 = (VF32)si_shufb( (qword)prevWordAo, (qword)currWordAo, (qword)s_Dabc );<br />ao_curr = currWordAo;<br /> for (int x = 0; x < kAoBufferLineWidth; x+=4) {<br /> VF32 nextWordAo = pvColor[ (lColorOffset + x + 4)/ 4 ];<br /> VF32 ao_p1 = (VF32)si_shufb( (qword)currWordAo, (qword)nextWordAo, (qword)s_BCDa );<br /> VF32 ao_p2 = (VF32)si_shufb( (qword)currWordAo, (qword)nextWordAo, (qword)s_CDab );<br /> VF32 ao_p3 = (VF32)si_shufb( (qword)currWordAo, (qword)nextWordAo, (qword)s_Dabc );<br /> VF32 ao_p4 = nextWordAo;<br /> VF32 blurAo = ao_n4*w4 + ao_n3*w3 + ao_n2*w2 + ao_n1*w1 + ao_curr*w0;<br /> blurAo += ao_p1*w1 + ao_p2*w2 + ao_p3*w3 + ao_p4*w4;<br />pvColor[ (lColorOffset + x)/ 4 ] = blurAo;<br />prevWordAo = currWordAo;<br />currWordAo = nextWordAo;<br /> ao_n4 = prevWordAo;<br /> ao_n3 = ao_p1;<br /> ao_n2 = ao_p2;<br /> ao_n1 = ao_p3;<br />ao_curr = currWordAo;<br /> }<br /> }<br />
  242. 242. SPU Assembly 1/2<br />EVEN<br />ODD<br />loop:<br /> {nop} {o6} lqxcurrAo, pvColor, colorOffset<br /> {nop} {o4} shufb prevAo0, currAo, currAo, s_AAAA<br /> {nop} {o4} shufb ao_n30, prevAo0, currAo, s_BCDa<br /> {nop} {o4} shufb ao_n20, prevAo0, currAo, s_CDab<br /> {nop} {o4} shufb ao_n10, prevAo0, currAo, s_Dabc<br /> {e2} selb ao_n4, ao_n4, prevAo0, endLineMask {lnop}<br /> {e2} selb ao_n3, ao_n3, ao_n30, endLineMask {lnop}<br /> {e2} selb ao_n2, ao_n2, ao_n20, endLineMask {lnop}<br /> {e2} selb ao_n1, ao_n1, ao_n10, endLineMask {lnop}<br /> {nop} {o6} lqxnextAo, pvNextColor, colorOffset<br /> {nop} {o4} shufb ao_p1, currAo, nextAo, s_BCDa<br /> {nop} {o4} shufb ao_p2, currAo, nextAo, s_CDab<br /> {nop} {o4} shufb ao_p3, currAo, nextAo, s_Dabc<br /> {e6} fa ao_n4, ao_n4, nextAo {lnop}<br /> {e6} fa ao_n3, ao_n3, ao_p3 {lnop}<br /> {e6} fa ao_n2, ao_n2, ao_p2 {lnop}<br /> {e6} fa ao_n1, ao_n1, ao_p1 {lnop}<br />
  243. 243. SPU Assembly 2/2<br />EVEN<br />ODD<br /> {e6} fm blurAo, ao_n4, w4 {lnop}<br /> {e6} fma blurAo, ao_n3, w3, blurAo {lnop}<br /> {e6} fma blurAo, ao_n2, w2, blurAo {lnop}<br /> {e6} fma blurAo, ao_n1, w1, blurAo {lnop}<br /> {e6} fmablurAo, currAo, w0, blurAo {lnop}<br /> {nop} {o6} stqxblurAo, pvColor, colorOffset<br /> {nop} {o4} shlqbii ao_n4, currAo, 0 <br /> {nop} {o4} shlqbii ao_n3, ao_p1, 0 <br /> {nop} {o4} shlqbii ao_n2, ao_p2, 0 <br /> {nop} {o4} shlqbii ao_n1, ao_p3, 0 <br /> {e2} ceqendLineMask, colorOffset, endLineOffset {lnop}<br /> {e2} ceqendBlockMask, colorOffset, endOffset {lnop}<br /> {e2} selbendLineOffsetIncr, zero, colorLineBytes, endLineMask {lnop}<br /> {e2} selbcolorOffsetIncr, defOffsetIncr, endColorOffsetIncr, endLineMask {lnop}<br /> {e2} a endLineOffset, endLineOffset, endLineOffsetIncr {lnop}<br /> {e2} a colorOffset, colorOffset, colorOffsetIncr {lnop}<br /> {nop} branch: {o?} brzendBlockMask, loop<br />
  244. 244. SPU Assembly<br />{e6} faao_n3, ao_n3, ao_p3{o6}lqxnextAo, pvNextColor, colorOffset<br /><ul><li>Here is a sample line of assembly code
  245. 245. SPUs issue one even and odd instruction per cycle
  246. 246. One line = One cycle
  247. 247. e6 = even, 6 cycle latency
  248. 248. o6 = odd, 6 cycle latency</li></li></ul><li>Iteration 1<br />loop:<br />nop lnop<br />nop lnop <br />nop lnop<br />nop lnop<br />nop lnop <br />nop lnop<br />nop lnop<br />nop lnop<br />nop lnop <br />nop lnop<br />nop lnop<br />nop lnop <br />nop lnop<br />nop lnop<br />nop lnop <br />nop lnop<br />nop lnop <br />nop lnop<br />nop lnop<br />nop branch: {o?:0} brzendBlockMask, loop <br />
  249. 249. Iteration 1<br />loop:<br />nop lnop<br />nop {o6:0} lqx currAo, pvColor, colorOffset<br />nop {o6:0} lqx nextAo, pvNextColor, colorOffset<br />nop {o4:0} shlqbiiendLineMask_, endLineMask, 0<br />nop lnop <br />nop lnop<br />nop lnop<br />nop {o4:0} shufb prevAo0, currAo, currAo, s_AAAA<br />{e2:0} ceqendLineMask, colorOffset, endLineOffset {o4:0} shufb ao_p1, currAo, nextAo, s_BCDa<br />{e2:0} ceqendBlockMask, colorOffset_, endOffset {o4:0} shufb ao_p2, currAo, nextAo, s_CDab<br />{e2:0} selbendLineOffsetIncr, zero, colorLineBytes, endLineMask {o4:0} shufb ao_p3, currAo, nextAo, s_Dabc<br />{e2:0} selb ao_n4, currAo_, prevAo0, endLineMask_ {o4:0} shufb ao_n30, prevAo0, currAo, s_BCDa<br />nop {o4:0} shufb ao_n20, prevAo0, currAo, s_CDab<br />nop {o4:0} shufb ao_n10, prevAo0, currAo, s_Dabc<br />{e2:0} selbcolorOffsetIncr, defOffsetIncr, endColorOffsetIncr, endLineMask lnop<br />{e2:0} selb ao_n3, ao_p1_, ao_n30, endLineMask_ {o4:0} shufbcolorOffset_, colorOffset_, colorOffset, s_BCa0<br />{e2:0} selb ao_n2, ao_p2_, ao_n20, endLineMask_lnop<br />{e2:0} selb ao_n1, ao_p3_, ao_n10, endLineMask_ lnop<br />{e2:0} a colorOffset, colorOffset, colorOffsetIncrlnop<br />{e2:0} a endLineOffset, endLineOffset, endLineOffsetIncrbranch: {o?:0} brzendBlockMask, loop <br />
  250. 250. Iteration 1<br />loop:<br />nop lnop<br />nop {o6:0} lqx currAo, pvColor, colorOffset<br />nop {o6:0} lqx nextAo, pvNextColor, colorOffset<br />nop {o4:0} shlqbiiendLineMask_, endLineMask, 0<br />nop lnop <br />nop lnop<br />nop lnop<br />nop {o4:0} shufb prevAo0, currAo, currAo, s_AAAA<br />{e2:0} ceqendLineMask, colorOffset, endLineOffset {o4:0} shufb ao_p1, currAo, nextAo, s_BCDa<br />{e2:0} ceqendBlockMask, colorOffset_, endOffset {o4:0} shufb ao_p2, currAo, nextAo, s_CDab<br />{e2:0} selbendLineOffsetIncr, zero, colorLineBytes, endLineMask {o4:0} shufb ao_p3, currAo, nextAo, s_Dabc<br />{e2:0} selb ao_n4, currAo_, prevAo0, endLineMask_ {o4:0} shufb ao_n30, prevAo0, currAo, s_BCDa<br />nop {o4:0} shufb ao_n20, prevAo0, currAo, s_CDab<br />nop {o4:0} shufb ao_n10, prevAo0, currAo, s_Dabc<br />{e2:0} selbcolorOffsetIncr, defOffsetIncr, endColorOffsetIncr, endLineMask lnop<br />{e2:0} selb ao_n3, ao_p1_, ao_n30, endLineMask_ {o4:0} shufbcolorOffset_, colorOffset_, colorOffset, s_BCa0<br />{e2:0} selb ao_n2, ao_p2_, ao_n20, endLineMask_lnop<br />{e2:0} selb ao_n1, ao_p3_, ao_n10, endLineMask_ lnop<br />{e2:0} a colorOffset, colorOffset, colorOffsetIncrlnop<br />{e2:0} a endLineOffset, endLineOffset, endLineOffsetIncrbranch: {o?:0} brzendBlockMask, loop <br />
  251. 251. Problems<br /><ul><li>Take this line:</li></ul> {o6} lqxcurrAo, pvColor, colorOffset<br /> {o4} shufb prevAo0, currAo, currAo, s_AAAA<br /><ul><li>Load a value into currAo
  252. 252. Next instruction needs currAo
  253. 253. currAo won’t be ready yet
  254. 254. Stall for 5 cycles</li></li></ul><li>Iteration 1<br />loop:<br />nop lnop<br />nop {o6:0} lqx currAo, pvColor, colorOffset<br />nop {o6:0} lqx nextAo, pvNextColor, colorOffset<br />nop {o4:0} shlqbiiendLineMask_, endLineMask, 0<br />nop lnop <br />nop lnop<br />nop lnop<br />nop {o4:0} shufb prevAo0, currAo, currAo, s_AAAA<br />{e2:0} ceqendLineMask, colorOffset, endLineOffset {o4:0} shufb ao_p1, currAo, nextAo, s_BCDa<br />{e2:0} ceqendBlockMask, colorOffset_, endOffset {o4:0} shufb ao_p2, currAo, nextAo, s_CDab<br />{e2:0} selbendLineOffsetIncr, zero, colorLineBytes, endLineMask {o4:0} shufb ao_p3, currAo, nextAo, s_Dabc<br />{e2:0} selb ao_n4, currAo_, prevAo0, endLineMask_ {o4:0} shufb ao_n30, prevAo0, currAo, s_BCDa<br />nop {o4:0} shufb ao_n20, prevAo0, currAo, s_CDab<br />nop {o4:0} shufb ao_n10, prevAo0, currAo, s_Dabc<br />{e2:0} selbcolorOffsetIncr, defOffsetIncr, endColorOffsetIncr, endLineMask lnop<br />{e2:0} selb ao_n3, ao_p1_, ao_n30, endLineMask_ {o4:0} shufbcolorOffset_, colorOffset_, colorOffset, s_BCa0<br />{e2:0} selb ao_n2, ao_p2_, ao_n20, endLineMask_lnop<br />{e2:0} selb ao_n1, ao_p3_, ao_n10, endLineMask_ lnop<br />{e2:0} a colorOffset, colorOffset, colorOffsetIncrlnop<br />{e2:0} a endLineOffset, endLineOffset, endLineOffsetIncrbranch: {o?:0} brzendBlockMask, loop <br />
  255. 255. Iteration 1<br />loop:<br />nop lnop<br />nop {o6:0} lqx currAo, pvColor, colorOffset<br />nop {o6:0} lqx nextAo, pvNextColor, colorOffset<br />nop {o4:0} shlqbiiendLineMask_, endLineMask, 0<br />nop lnop <br />nop lnop<br />nop lnop<br />nop {o4:0} shufb prevAo0, currAo, currAo, s_AAAA<br />{e2:0} ceqendLineMask, colorOffset, endLineOffset {o4:0} shufb ao_p1, currAo, nextAo, s_BCDa<br />{e2:0} ceqendBlockMask, colorOffset_, endOffset {o4:0} shufb ao_p2, currAo, nextAo, s_CDab<br />{e2:0} selbendLineOffsetIncr, zero, colorLineBytes, endLineMask {o4:0} shufb ao_p3, currAo, nextAo, s_Dabc<br />{e2:0} selb ao_n4, currAo_, prevAo0, endLineMask_ {o4:0} shufb ao_n30, prevAo0, currAo, s_BCDa<br />nop {o4:0} shufb ao_n20, prevAo0, currAo, s_CDab<br />nop {o4:0} shufb ao_n10, prevAo0, currAo, s_Dabc<br />{e2:0} selbcolorOffsetIncr, defOffsetIncr, endColorOffsetIncr, endLineMask lnop<br />{e2:0} selb ao_n3, ao_p1_, ao_n30, endLineMask_ {o4:0} shufbcolorOffset_, colorOffset_, colorOffset, s_BCa0<br />{e2:0} selb ao_n2, ao_p2_, ao_n20, endLineMask_lnop<br />{e2:0} selb ao_n1, ao_p3_, ao_n10, endLineMask_ lnop<br />{e2:0} a colorOffset, colorOffset, colorOffsetIncrlnop<br />{e2:0} a endLineOffset, endLineOffset, endLineOffsetIncrbranch: {o?:0} brzendBlockMask, loop <br />
  256. 256. Iteration 2<br />loop:<br />nop lnop<br />{e6:1} fa ao_n4, ao_n4, nextAo {o6:0} lqx currAo, pvColor, colorOffset<br />{e6:1} fa ao_n3, ao_n3, ao_p3{o6:0} lqx nextAo, pvNextColor, colorOffset<br />nop{o4:0} shlqbiiendLineMask_, endLineMask, 0<br />{e6:1} fa ao_n1_, ao_n1, ao_p1 lnop<br />{e6:1} fa ao_n2_, ao_n2, ao_p2 lnop<br />noplnop<br />{e6:1} fm blurAo, ao_n4, w4 {o4:0} shufb prevAo0, currAo, currAo, s_AAAA<br />{e2:0} ceqendLineMask, colorOffset, endLineOffset {o4:0} shufb ao_p1, currAo, nextAo, s_BCDa<br />{e2:0} ceqendBlockMask, colorOffset_, endOffset {o4:0} shufb ao_p2, currAo, nextAo, s_CDab<br />{e2:0} selbendLineOffsetIncr, zero, colorLineBytes, endLineMask {o4:0} shufb ao_p3, currAo, nextAo, s_Dabc<br />{e2:0} selb ao_n4, currAo_, prevAo0, endLineMask_ {o4:0} shufb ao_n30, prevAo0, currAo, s_BCDa<br />nop{o4:0} shufb ao_n20, prevAo0, currAo, s_CDab<br />{e6:1} fma blurAo, ao_n3, w3, blurAo {o4:0} shufb ao_n10, prevAo0, currAo, s_Dabc<br />{e2:0} selbcolorOffsetIncr, defOffsetIncr, endColorOffsetIncr, endLineMasklnop <br />{e2:0} selb ao_n3, ao_p1_, ao_n30, endLineMask_ {o4:0} shufbcolorOffset_, colorOffset_, colorOffset, s_BCa0<br />{e2:0} selb ao_n2, ao_p2_, ao_n20, endLineMask_lnop<br />{e2:0} selb ao_n1, ao_p3_, ao_n10, endLineMask_ lnop<br />{e2:0} a colorOffset, colorOffset, colorOffsetIncrlnop<br />{e2:0} a endLineOffset, endLineOffset, endLineOffsetIncrbranch: {o?:0} brzendBlockMask, loop <br />
  257. 257. Iteration 3<br />loop:<br />nop lnop<br />{e6:1} fa ao_n4, ao_n4, nextAo {o6:0} lqx currAo, pvColor, colorOffset<br />{e6:1} fa ao_n3, ao_n3, ao_p3{o6:0} lqx nextAo, pvNextColor, colorOffset<br />{e6:2} fmablurAo_, ao_n2_, w2, blurAo{o4:0} shlqbiiendLineMask_, endLineMask, 0<br />{e6:1} fa ao_n1_, ao_n1, ao_p1 lnop<br />{e6:1} fa ao_n2_, ao_n2, ao_p2 lnop<br />nop lnop<br />{e6:1} fm blurAo, ao_n4, w4 {o4:0} shufb prevAo0, currAo, currAo, s_AAAA<br />{e2:0} ceqendLineMask, colorOffset, endLineOffset {o4:0} shufb ao_p1, currAo, nextAo, s_BCDa<br />{e2:0} ceqendBlockMask, colorOffset_, endOffset {o4:0} shufb ao_p2, currAo, nextAo, s_CDab<br />{e2:0} selbendLineOffsetIncr, zero, colorLineBytes, endLineMask {o4:0} shufb ao_p3, currAo, nextAo, s_Dabc<br />{e2:0} selb ao_n4, currAo_, prevAo0, endLineMask_ {o4:0} shufb ao_n30, prevAo0, currAo, s_BCDa<br />{e6:2} fma blurAo__, ao_n1__, w1, blurAo_{o4:0} shufb ao_n20, prevAo0, currAo, s_CDab<br />{e6:1} fma blurAo, ao_n3, w3, blurAo {o4:0} shufb ao_n10, prevAo0, currAo, s_Dabc<br />{e2:0} selbcolorOffsetIncr, defOffsetIncr, endColorOffsetIncr, endLineMasklnop <br />{e2:0} selb ao_n3, ao_p1_, ao_n30, endLineMask_ {o4:0} shufbcolorOffset_, colorOffset_, colorOffset, s_BCa0<br />{e2:0} selb ao_n2, ao_p2_, ao_n20, endLineMask_lnop<br />{e2:0} selb ao_n1, ao_p3_, ao_n10, endLineMask_ lnop<br />{e2:0} a colorOffset, colorOffset, colorOffsetIncrlnop<br />{e2:0} a endLineOffset, endLineOffset, endLineOffsetIncrbranch: {o?:0} brzendBlockMask, loop <br />
  258. 258. Iteration 4<br />loop:<br />nop lnop<br />{e6:1} fa ao_n4, ao_n4, nextAo {o6:0} lqx currAo, pvColor, colorOffset<br />{e6:1} fa ao_n3, ao_n3, ao_p3{o6:0} lqx nextAo, pvNextColor, colorOffset<br />{e6:2} fmablurAo_, ao_n2_, w2, blurAo{o4:0} shlqbiiendLineMask_, endLineMask, 0<br />{e6:1} fa ao_n1_, ao_n1, ao_p1 lnop<br />{e6:1} fa ao_n2_, ao_n2, ao_p2 lnop<br />{e6:3} fmablurAo___, currAo___, w0, blurAo__lnop<br />{e6:1} fm blurAo, ao_n4, w4 {o4:0} shufb prevAo0, currAo, currAo, s_AAAA<br />{e2:0} ceqendLineMask, colorOffset, endLineOffset {o4:0} shufb ao_p1, currAo, nextAo, s_BCDa<br />{e2:0} ceqendBlockMask, colorOffset_, endOffset {o4:0} shufb ao_p2, currAo, nextAo, s_CDab<br />{e2:0} selbendLineOffsetIncr, zero, colorLineBytes, endLineMask {o4:0} shufb ao_p3, currAo, nextAo, s_Dabc<br />{e2:0} selb ao_n4, currAo_, prevAo0, endLineMask_ {o4:0} shufb ao_n30, prevAo0, currAo, s_BCDa<br />{e6:2} fma blurAo__, ao_n1__, w1, blurAo_{o4:0} shufb ao_n20, prevAo0, currAo, s_CDab<br />{e6:1} fma blurAo, ao_n3, w3, blurAo {o4:0} shufb ao_n10, prevAo0, currAo, s_Dabc<br />{e2:0} selbcolorOffsetIncr, defOffsetIncr, endColorOffsetIncr, endLineMask{o6:3} stqxblurAo___, pvColor, colorOffset_<br />{e2:0} selb ao_n3, ao_p1_, ao_n30, endLineMask_ {o4:0} shufbcolorOffset_, colorOffset_, colorOffset, s_BCa0<br />{e2:0} selb ao_n2, ao_p2_, ao_n20, endLineMask_lnop<br />{e2:0} selb ao_n1, ao_p3_, ao_n10, endLineMask_ lnop<br />{e2:0} a colorOffset, colorOffset, colorOffsetIncrlnop<br />{e2:0} a endLineOffset, endLineOffset, endLineOffsetIncrbranch: {o?:0} brzendBlockMask, loop <br />
  259. 259. Copy Operations<br />loop:<br />{e2:x} ai ao_n1__, ao_n1_, 0 {o4:x} shlqbii currAo_, currAo, 0<br />{e6:1} fa ao_n4, ao_n4, nextAo {o6:0} lqx currAo, pvColor, colorOffset<br />{e6:1} fa ao_n3, ao_n3, ao_p3{o6:0} lqx nextAo, pvNextColor, colorOffset<br />{e6:2} fmablurAo_, ao_n2_, w2, blurAo{o4:0} shlqbiiendLineMask_, endLineMask, 0<br />{e6:1} fa ao_n1_, ao_n1, ao_p1 {o4:x} shlqbii ao_p1_, ao_p1, 0<br />{e6:1} fa ao_n2_, ao_n2, ao_p2 {o4:x} shlqbii ao_p2_, ao_p2, 0<br />{e6:3} fmablurAo___, currAo___, w0, blurAo__ {o4:x} shlqbii ao_p3_, ao_p3, 0<br />{e6:1} fm blurAo, ao_n4, w4 {o4:0} shufb prevAo0, currAo, currAo, s_AAAA<br />{e2:0} ceqendLineMask, colorOffset, endLineOffset {o4:0} shufb ao_p1, currAo, nextAo, s_BCDa<br />{e2:0} ceqendBlockMask, colorOffset_, endOffset {o4:0} shufb ao_p2, currAo, nextAo, s_CDab<br />{e2:0} selbendLineOffsetIncr, zero, colorLineBytes, endLineMask {o4:0} shufb ao_p3, currAo, nextAo, s_Dabc<br />{e2:0} selb ao_n4, currAo_, prevAo0, endLineMask_ {o4:0} shufb ao_n30, prevAo0, currAo, s_BCDa<br />{e6:2} fma blurAo__, ao_n1__, w1, blurAo_{o4:0} shufb ao_n20, prevAo0, currAo, s_CDab<br />{e6:1} fma blurAo, ao_n3, w3, blurAo {o4:0} shufb ao_n10, prevAo0, currAo, s_Dabc<br />{e2:0} selbcolorOffsetIncr, defOffsetIncr, endColorOffsetIncr, endLineMask{o6:3} stqxblurAo___, pvColor, colorOffset_<br />{e2:0} selb ao_n3, ao_p1_, ao_n30, endLineMask_ {o4:0} shufbcolorOffset_, colorOffset_, colorOffset, s_BCa0<br />{e2:0} selb ao_n2, ao_p2_, ao_n20, endLineMask_{o4:x} shlqbii currAo___, currAo__, 0<br />{e2:0} selb ao_n1, ao_p3_, ao_n10, endLineMask_ {o4:x} shlqbii currAo__, currAo_, 0<br />{e2:0} a colorOffset, colorOffset, colorOffsetIncrlnop<br />{e2:0} a endLineOffset, endLineOffset, endLineOffsetIncrbranch: {o?:0} brzendBlockMask, loop <br />
  260. 260. Optimized<br />loop:<br />{e2:x} ai ao_n1__, ao_n1_, 0 {o4:x} shlqbii currAo_, currAo, 0<br />{e6:1} fa ao_n4, ao_n4, nextAo {o6:0} lqx currAo, pvColor, colorOffset<br />{e6:1} fa ao_n3, ao_n3, ao_p3 {o6:0} lqx nextAo, pvNextColor, colorOffset<br />{e6:2} fmablurAo_, ao_n2_, w2, blurAo {o4:0} shlqbiiendLineMask_, endLineMask, 0<br />{e6:1} fa ao_n1_, ao_n1, ao_p1 {o4:x} shlqbii ao_p1_, ao_p1, 0<br />{e6:1} fa ao_n2_, ao_n2, ao_p2 {o4:x} shlqbii ao_p2_, ao_p2, 0<br />{e6:3} fmablurAo___, currAo___, w0, blurAo__ {o4:x} shlqbii ao_p3_, ao_p3, 0<br />{e6:1} fm blurAo, ao_n4, w4 {o4:0} shufb prevAo0, currAo, currAo, s_AAAA<br />{e2:0} ceqendLineMask, colorOffset, endLineOffset {o4:0} shufb ao_p1, currAo, nextAo, s_BCDa<br />{e2:0} ceqendBlockMask, colorOffset_, endOffset {o4:0} shufb ao_p2, currAo, nextAo, s_CDab<br />{e2:0} selbendLineOffsetIncr, zero, colorLineBytes, endLineMask {o4:0} shufb ao_p3, currAo, nextAo, s_Dabc<br />{e2:0} selb ao_n4, currAo_, prevAo0, endLineMask_ {o4:0} shufb ao_n30, prevAo0, currAo, s_BCDa<br />{e6:2} fma blurAo__, ao_n1__, w1, blurAo_ {o4:0} shufb ao_n20, prevAo0, currAo, s_CDab<br />{e6:1} fma blurAo, ao_n3, w3, blurAo {o4:0} shufb ao_n10, prevAo0, currAo, s_Dabc<br />{e2:0} selbcolorOffsetIncr, defOffsetIncr, endColorOffsetIncr, endLineMask {o6:3} stqxblurAo___, pvColor, colorOffset_<br />{e2:0} selb ao_n3, ao_p1_, ao_n30, endLineMask_ {o4:0} shufbcolorOffset_, colorOffset_, colorOffset, s_BCa0<br />{e2:0} selb ao_n2, ao_p2_, ao_n20, endLineMask_ {o4:x} shlqbii currAo___, currAo__, 0<br />{e2:0} selb ao_n1, ao_p3_, ao_n10, endLineMask_ {o4:x} shlqbii currAo__, currAo_, 0<br />{e2:0} a colorOffset, colorOffset, colorOffsetIncrlnop<br />{e2:0} a endLineOffset, endLineOffset, endLineOffsetIncr branch: {o?:0} brzendBlockMask, loop <br />
  261. 261. Optimized<br />EVEN<br />ODD<br />loop:<br />{e2:x} ai ao_n1__, ao_n1_, 0 {o4:x} shlqbii currAo_, currAo, 0<br />{e6:1} fa ao_n4, ao_n4, nextAo {o6:0} lqx currAo, pvColor, colorOffset<br />{e6:1} fa ao_n3, ao_n3, ao_p3 {o6:0} lqx nextAo, pvNextColor, colorOffset<br />{e6:2} fmablurAo_, ao_n2_, w2, blurAo {o4:0} shlqbiiendLineMask_, endLineMask, 0<br />{e6:1} fa ao_n1_, ao_n1, ao_p1 {o4:x} shlqbii ao_p1_, ao_p1, 0<br />{e6:1} fa ao_n2_, ao_n2, ao_p2 {o4:x} shlqbii ao_p2_, ao_p2, 0<br />{e6:3} fmablurAo___, currAo___, w0, blurAo__ {o4:x} shlqbii ao_p3_, ao_p3, 0<br />{e6:1} fm blurAo, ao_n4, w4 {o4:0} shufb prevAo0, currAo, currAo, s_AAAA<br />{e2:0} ceqendLineMask, colorOffset, endLineOffset {o4:0} shufb ao_p1, currAo, nextAo, s_BCDa<br />{e2:0} ceqendBlockMask, colorOffset_, endOffset {o4:0} shufb ao_p2, currAo, nextAo, s_CDab<br />{e2:0} selbendLineOffsetIncr, zero, colorLineBytes, endLineMask {o4:0} shufb ao_p3, currAo, nextAo, s_Dabc<br />{e2:0} selb ao_n4, currAo_, prevAo0, endLineMask_ {o4:0} shufb ao_n30, prevAo0, currAo, s_BCDa<br />{e6:2} fma blurAo__, ao_n1__, w1, blurAo_ {o4:0} shufb ao_n20, prevAo0, currAo, s_CDab<br />{e6:1} fma blurAo, ao_n3, w3, blurAo {o4:0} shufb ao_n10, prevAo0, currAo, s_Dabc<br />{e2:0} selbcolorOffsetIncr, defOffsetIncr, endColorOffsetIncr, endLineMask {o6:3} stqxblurAo___, pvColor, colorOffset_<br />{e2:0} selb ao_n3, ao_p1_, ao_n30, endLineMask_ {o4:0} shufbcolorOffset_, colorOffset_, colorOffset, s_BCa0<br />{e2:0} selb ao_n2, ao_p2_, ao_n20, endLineMask_ {o4:x} shlqbii currAo___, currAo__, 0<br />{e2:0} selb ao_n1, ao_p3_, ao_n10, endLineMask_ {o4:x} shlqbii currAo__, currAo_, 0<br />{e2:0} a colorOffset, colorOffset, colorOffsetIncrlnop<br />{e2:0} a endLineOffset, endLineOffset, endLineOffsetIncr branch: {o?:0} brzendBlockMask, loop <br />
  262. 262. Optimized<br />EVEN<br />ODD<br />loop:<br />{e2:x} ai ao_n1__, ao_n1_, 0 {o4:x} shlqbii currAo_, currAo, 0<br />{e6:1} fa ao_n4, ao_n4, nextAo {o6:0} lqx currAo, pvColor, colorOffset<br />{e6:1} fa ao_n3, ao_n3, ao_p3 {o6:0} lqx nextAo, pvNextColor, colorOffset<br />{e6:2} fmablurAo_, ao_n2_, w2, blurAo {o4:0} shlqbiiendLineMask_, endLineMask, 0<br />{e6:1} fa ao_n1_, ao_n1, ao_p1 {o4:x} shlqbii ao_p1_, ao_p1, 0<br />{e6:1} fa ao_n2_, ao_n2, ao_p2 {o4:x} shlqbii ao_p2_, ao_p2, 0<br />{e6:3} fmablurAo___, currAo___, w0, blurAo__ {o4:x} shlqbii ao_p3_, ao_p3, 0<br />{e6:1} fm blurAo, ao_n4, w4 {o4:0} shufb prevAo0, currAo, currAo, s_AAAA<br />{e2:0} ceqendLineMask, colorOffset, endLineOffset {o4:0} shufb ao_p1, currAo, nextAo, s_BCDa<br />{e2:0} ceqendBlockMask, colorOffset_, endOffset {o4:0} shufb ao_p2, currAo, nextAo, s_CDab<br />{e2:0} selbendLineOffsetIncr, zero, colorLineBytes, endLineMask {o4:0} shufb ao_p3, currAo, nextAo, s_Dabc<br />{e2:0} selb ao_n4, currAo_, prevAo0, endLineMask_ {o4:0} shufb ao_n30, prevAo0, currAo, s_BCDa<br />{e6:2} fma blurAo__, ao_n1__, w1, blurAo_ {o4:0} shufb ao_n20, prevAo0, currAo, s_CDab<br />{e6:1} fma blurAo, ao_n3, w3, blurAo {o4:0} shufb ao_n10, prevAo0, currAo, s_Dabc<br />{e2:0} selbcolorOffsetIncr, defOffsetIncr, endColorOffsetIncr, endLineMask {o6:3} stqxblurAo___, pvColor, colorOffset_<br />{e2:0} selb ao_n3, ao_p1_, ao_n30, endLineMask_ {o4:0} shufbcolorOffset_, colorOffset_, colorOffset, s_BCa0<br />{e2:0} selb ao_n2, ao_p2_, ao_n20, endLineMask_ {o4:x} shlqbii currAo___, currAo__, 0<br />{e2:0} selb ao_n1, ao_p3_, ao_n10, endLineMask_ {o4:x} shlqbii currAo__, currAo_, 0<br />{e2:0} a colorOffset, colorOffset, colorOffsetIncrlnop<br />{e2:0} a endLineOffset, endLineOffset, endLineOffsetIncr branch: {o?:0} brzendBlockMask, loop <br />
  263. 263. Optimized<br />EVEN<br />ODD<br />loop:<br />{e2:x} ai ao_n1__, ao_n1_, 0 {o4:x} shlqbii currAo_, currAo, 0<br />{e6:1} fa ao_n4, ao_n4, nextAo {o6:0} lqx currAo, pvColor, colorOffset<br />{e6:1} fa ao_n3, ao_n3, ao_p3 {o6:0} lqx nextAo, pvNextColor, colorOffset<br />{e6:2} fmablurAo_, ao_n2_, w2, blurAo {o4:0} shlqbiiendLineMask_, endLineMask, 0<br />{e6:1} fa ao_n1_, ao_n1, ao_p1 {o4:x} shlqbii ao_p1_, ao_p1, 0<br />{e6:1} fa ao_n2_, ao_n2, ao_p2 {o4:x} shlqbii ao_p2_, ao_p2, 0<br />{e6:3} fmablurAo___, currAo___, w0, blurAo__ {o4:x} shlqbii ao_p3_, ao_p3, 0<br />{e6:1} fm blurAo, ao_n4, w4 {o4:0} shufb prevAo0, currAo, currAo, s_AAAA<br />{e2:0} ceqendLineMask, colorOffset, endLineOffset {o4:0} shufb ao_p1, currAo, nextAo, s_BCDa<br />{e2:0} ceqendBlockMask, colorOffset_, endOffset {o4:0} shufb ao_p2, currAo, nextAo, s_CDab<br />{e2:0} selbendLineOffsetIncr, zero, colorLineBytes, endLineMask {o4:0} shufb ao_p3, currAo, nextAo, s_Dabc<br />{e2:0} selb ao_n4, currAo_, prevAo0, endLineMask_ {o4:0} shufb ao_n30, prevAo0, currAo, s_BCDa<br />{e6:2} fma blurAo__, ao_n1__, w1, blurAo_ {o4:0} shufb ao_n20, prevAo0, currAo, s_CDab<br />{e6:1} fma blurAo, ao_n3, w3, blurAo {o4:0} shufb ao_n10, prevAo0, currAo, s_Dabc<br />{e2:0} selbcolorOffsetIncr, defOffsetIncr, endColorOffsetIncr, endLineMask {o6:3} stqxblurAo___, pvColor, colorOffset_<br />{e2:0} selb ao_n3, ao_p1_, ao_n30, endLineMask_ {o4:0} shufbcolorOffset_, colorOffset_, colorOffset, s_BCa0<br />{e2:0} selb ao_n2, ao_p2_, ao_n20, endLineMask_ {o4:x} shlqbii currAo___, currAo__, 0<br />{e2:0} selb ao_n1, ao_p3_, ao_n10, endLineMask_ {o4:x} shlqbii currAo__, currAo_, 0<br />{e2:0} a colorOffset, colorOffset, colorOffsetIncrlnop<br />{e2:0} a endLineOffset, endLineOffset, endLineOffsetIncr branch: {o?:0} brzendBlockMask, loop <br />
  264. 264. Solution<br /><ul><li>Gives about a 2x performance boost
  265. 265. Sometimes more or less
  266. 266. SSAO went from 2ms on all 6 SPUs to 1ms on all 6 SPUs
  267. 267. With practice, can do about 1-2 loops per day.
  268. 268. SSAO has 6 loops, and took a little over a week.
  269. 269. Same process for:
  270. 270. PostFX
  271. 271. Fullscreen Lighting
  272. 272. Ambient Cubemaps
  273. 273. Many more</li></li></ul><li>Full Timeline<br /><ul><li>Hand-Optimized by ICE Team</li></li></ul><li>Full Timeline<br /><ul><li>Hand-Optimized by Uncharted 2 Team</li></li></ul><li>Performance<br /><ul><li>Final Render</li></li></ul><li>Performance<br /><ul><li>Without Fullscreen Lighting</li></li></ul><li>Performance<br /><ul><li>Fullscreen Lighting Results</li></li></ul><li>Performance<br /><ul><li>Fullscreen Lighting / SSAO Performance</li></li></ul><li>Performance<br /><ul><li>Fullscreen Lighting / SSAO Performance</li></ul>Fullscreen Lighting<br />SSAO<br />
  274. 274. Performance<br /><ul><li>Fullscreen Lighting / SSAO Performance</li></li></ul><li>Performance<br /><ul><li>Fullscreen Lighting / SSAO Performance</li></li></ul><li>Performance<br /><ul><li>Fullscreen Lighting / SSAO Performance</li></li></ul><li>Performance<br /><ul><li>Fullscreen Lighting / SSAO Performance</li></ul>Fullscreen Lighting<br />SSAO<br />
  275. 275. Architecture Conclusions<br />“So, you are the scheduler that has been nipping at my heels...”<br />
  276. 276. Final Final Thoughts<br /><ul><li>Gamma is super-duper important.
  277. 277. Filmic Tonemapping changes your life.
  278. 278. SSAO is cool, and keep it out of your sunlight.
  279. 279. SPUs are awesome.
  280. 280. They don’t optimize themselves.
  281. 281. For a tight for-loop, you can do about 2x better than the compiler.</li></li></ul><li>Btw...<br /><ul><li>Naughty Dog is hiring!
  282. 282. We’re also looking for
  283. 283. Senior Lighting Artist.
  284. 284. Graphics Programmer</li></li></ul><li>That’s it!<br /><ul><li>Questions…</li>
  • DanielCamba1

    Nov. 12, 2021
  • ssuser36c81e

    Oct. 7, 2020
  • WenLi83

    Oct. 7, 2020
  • ssuser6e49e71

    Aug. 30, 2020
  • luqs434

    Oct. 31, 2019
  • Narann29

    Oct. 29, 2019
  • JaehoChoi3

    Aug. 1, 2019
  • JohnSmith5080

    Jun. 13, 2019
  • ShaunChoe

    Apr. 11, 2019
  • suhyoungjo

    Jan. 4, 2019
  • codevania

    Aug. 2, 2018
  • DejiaShang

    Jul. 9, 2018
  • FernandoUrquijoSnche

    Jun. 23, 2018
  • WilliamXiao3

    May. 19, 2018
  • AntonioLisboaNeto1

    May. 16, 2018
  • ssuser93938a

    May. 12, 2018
  • slysis

    Apr. 10, 2018
  • JrmieBoulay

    Mar. 19, 2018
  • AnmarAlSharif

    Dec. 13, 2017
  • ArturoGonzlezNaharro

    Dec. 13, 2017

http://ozlael.egloos.com

Views

Total views

76,658

On Slideshare

0

From embeds

0

Number of embeds

7,811

Actions

Downloads

828

Shares

0

Comments

0

Likes

80

×