06.01.2013 Views

Rendering Techniques in Gears of War 2 - Unreal Engine

Rendering Techniques in Gears of War 2 - Unreal Engine

Rendering Techniques in Gears of War 2 - Unreal Engine

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>Render<strong>in</strong>g</strong> <strong>Techniques</strong> <strong>in</strong><br />

Niklas Smedberg<br />

Senior Eng<strong>in</strong>e g Programmer g<br />

Epic Games, Inc.<br />

Daniel Wright<br />

Eng<strong>in</strong>e Programmer<br />

Epic Games, Inc.<br />

<strong>Gears</strong> <strong>of</strong> <strong>War</strong> 2


About Epic Epic Games<br />

Games<br />

• 19th year <strong>of</strong> bus<strong>in</strong>ess<br />

• 110 employees <strong>in</strong> NC and still hir<strong>in</strong>g<br />

• Creators Creators <strong>of</strong> <strong>Unreal</strong> <strong>Unreal</strong> Eng<strong>in</strong>e 3<br />

• Shipped <strong>Gears</strong> <strong>of</strong> <strong>War</strong> 2<br />

• Shi Shipped Shi d <strong>Unreal</strong> U lT Tournament t3 3<br />

– Xbox 360, PC and PS3<br />

• External studios <strong>in</strong> Poland, Shanghai, and Utah


About <strong>Gears</strong> <strong>of</strong> <strong>War</strong> 2<br />

• 93% Metacritic rat<strong>in</strong>g<br />

• Over 4 million copies sold<br />

• 117 award d w<strong>in</strong>s i and d<br />

nom<strong>in</strong>ations<br />

• Shipped <strong>in</strong> two years<br />

by <strong>Gears</strong> 1 team


About Niklas Smedberg<br />

• Aka A.k.a. “Smedis” Smedis<br />

• C64 Swedish demo scene<br />

• Went pro 1997 99<br />

• Moved to the US <strong>in</strong> 2001<br />

• Shipped titles for PS1, PC, Xbox, Xbox 360, PS3<br />

• Jo<strong>in</strong>ed Epic Games 2005


Topics p<br />

Niklas Smedberg<br />

• Gore techniques q<br />

• Blood techniques<br />

• Character light<strong>in</strong>g<br />

• Screen Space Ambient Occlusion optimizations


THE FOLLOWING PRESENTATION HAS NOT BEEN RATED FOR<br />

ALL AUDIENCES<br />

VIEWER DISCRETION IS ADVISED


• Goals:<br />

Gore Goals<br />

– No seams between breakable pieces<br />

(<strong>Gears</strong> <strong>of</strong> <strong>War</strong> 1 used rigid 1-bone sk<strong>in</strong>n<strong>in</strong>g)<br />

– Dismember sk<strong>in</strong>ned meshes (e (e.g. g ragdolls)<br />

– Hand-modeled <strong>in</strong>ternals<br />

– M<strong>in</strong>imal impact on undamaged meshes


Gore Mesh<br />

• Artists make two versions <strong>of</strong> the sk<strong>in</strong>ned mesh<br />

• Undamaged mesh with no overhead<br />

• Gore mesh with additional <strong>in</strong>formation:<br />

– Completely <strong>in</strong>dependent <strong>of</strong> the undamaged mesh<br />

– Full freedom to hand-model cuts and guts<br />

– Can use different/additional textures and shaders<br />

– Pre-cut with all gore pieces separated


Locust gore mesh<br />

• Picture: Locust gore g<br />

mesh


Gore Mesh<br />

• Skeleton with breakable jo<strong>in</strong>t j constra<strong>in</strong>ts<br />

– Broken by script code - not us<strong>in</strong>g physics eng<strong>in</strong>e (as <strong>in</strong> <strong>Gears</strong> 1)<br />

– More control <strong>of</strong> when/how to break the constra<strong>in</strong>ts<br />

• Info per gore piece:<br />

– Hit po<strong>in</strong>ts<br />

– Type <strong>of</strong> special effect<br />

– Dependency <strong>of</strong> other gore pieces<br />

– Etc<br />

• An extra set <strong>of</strong> bone weights for all vertices:<br />

– Hand-made 4-bone weights<br />

– Weighted to properly separate all gore pieces along the cuts


Elaborate gore mesh<br />

• Picture: Uber reaver gore mesh


Tear<strong>in</strong>g <strong>of</strong>f a limb<br />

• Switch to the gore g mesh<br />

• Determ<strong>in</strong>e which constra<strong>in</strong>t to break<br />

• Get the pair <strong>of</strong> broken bones<br />

• CCreate t a separate t vertexbuffer t b ff ffor vertex t weights i ht<br />

– Unique per gore mesh <strong>in</strong>stance<br />

– Replaces all weights <strong>in</strong> the orig<strong>in</strong>al vertexbuffer<br />

– Used as a separate vertex stream<br />

• For each vertex:<br />

– If <strong>in</strong>fluenced by a broken bone, copy 2nd y , py set <strong>of</strong> weights g<br />

– Otherwise, copy 1st set <strong>of</strong> weights<br />

• Add physics impulse to the torn-<strong>of</strong>f limb<br />

– Let physics move the limb away


Data-driven Data driven Gore<br />

• Set up p <strong>in</strong> the <strong>Unreal</strong> Editor<br />

• Only used for really big enemies (e.g. Brumak)<br />

• Used as visual “damage states”<br />

– Not necessarily to break <strong>of</strong>f whole limbs<br />

• Gore pieces stacked on top <strong>of</strong> each other<br />

– Break “armor armor pieces pieces” , damage flesh, flesh etc. etc<br />

• Hit-po<strong>in</strong>ts, impact radius, dependency l<strong>in</strong>ks (leaf first),<br />

etc


Data-driven ata d e Go Gore, e, 1 o<strong>of</strong> 3


Data-driven ata d e Go Gore, e, 2 o<strong>of</strong> 3


Data-driven ata d e Goe,3o Gore, 3 <strong>of</strong> 3


Scripted Gore<br />

• Set up p <strong>in</strong> ggameplay p y code ( (<strong>Unreal</strong> Script) p )<br />

• Only dismember dead people<br />

– No animation/gameplay consequences<br />

• Different damage types break constra<strong>in</strong>ts differently<br />

– Complete obliteration (e.g. grenade-tag)<br />

– Partial obliteration (e.g. shotguns)<br />

• Headshots spawn additional effects (gibs)<br />

– Hand-made gib meshes can be specified per Pawn<br />

• Cha<strong>in</strong>saw breaks specific constra<strong>in</strong>ts<br />

• Ragdolls break constra<strong>in</strong>ts based on hit location


Next Example: Meatshield<br />

• Meatshields break constra<strong>in</strong>ts <strong>in</strong> a pre-determ<strong>in</strong>ed p sequence q<br />

– Based on overall “health” for the entire meatshield<br />

– Used as gory visual <strong>in</strong>dicator <strong>in</strong>stead <strong>of</strong> a bor<strong>in</strong>g “health bar”


Data-driven Data driven gore #1<br />

• Screenshot: Meatshield 1


Data-driven Data driven gore #2<br />

• Screenshot: Meatshield 2


• Screenshot: Meatshield 3<br />

Data‐driven Data driven gore #3


Data-driven Data driven gore #4<br />

• Screenshot: Meatshield 4


Data-driven Data driven gore #5<br />

• Screenshot: Meatshield 5


Data-driven Data driven gore #6<br />

• Screenshot: Meatshield 6


Data-driven Data driven gore #7<br />

• Screenshot: Meatshield 7


Next Example: Cha<strong>in</strong>saw<br />

• Cha<strong>in</strong>saw kill:<br />

– Gameplay code choos<strong>in</strong>g a specific constra<strong>in</strong>t to break


• Movie: Cha<strong>in</strong>saw<br />

Scripted gore


• Gore techniques q<br />

Topics p<br />

Niklas Smedberg<br />

• Blood techniques<br />

• Character light<strong>in</strong>g<br />

• Screen Space Ambient Occlusion optimizations


Blood <strong>Techniques</strong><br />

• Many y different techniques q used <strong>in</strong> comb<strong>in</strong>ation:<br />

– Projected blood decals<br />

– Screen-space blood splatter<br />

– World World-space space particle effects<br />

– Surface-space shader effects<br />

– Fluid simulations<br />

– Morph<strong>in</strong>g geometry


Blood <strong>Techniques</strong><br />

• Movie: Riftworm heart chamber, cha<strong>in</strong>saw<strong>in</strong>g through<br />

, g g<br />

arteries


Decal Features<br />

• Decal system y much improved p over <strong>Gears</strong> 1<br />

• Much easier to spawn decals on anyth<strong>in</strong>g<br />

• Supports any artist-created material (shader), light<strong>in</strong>g, blend<br />

mode mode, normal maps maps, animated animated, render render-to-texture, to texture etc<br />

• Three decal pools:<br />

– Blood decals, explosion decals, bullet decals<br />

– Blood splatter unaffected by the number <strong>of</strong> bullet hit-marks<br />

• Heuristic to replace oldest decal (when necessary):<br />

– Oldest not visible decal (LastRenderTime)<br />

– Oldest visible decal (Lifetime)<br />

• Proximity check to avoid multiple decals on top <strong>of</strong> each other


Decal Optimizations<br />

• AABB tree to f<strong>in</strong>d triangles g with<strong>in</strong> the decal frustum<br />

– These triangles are not clipped<br />

• Decals have their own <strong>in</strong>dex buffers<br />

– Re-use Re use whole triangles from the base mesh vertexbuffers<br />

• Frustum-clipp<strong>in</strong>g handled by GPU:<br />

– clip(), early-out branch, scissor test<br />

• DDecal l visibility i ibilit ttests: t<br />

– Re-use base mesh visibility test<br />

– Decal-specific frustum and distance check<br />

• Decals on fractured meshes:<br />

– Re-use the fragment-visibility check<br />

– Upon Upo fracture, actu e, re-calculate e ca cu ate aaffected ected deca decals s only o y


Decal Optimizations<br />

• One drawcall per decal, but:<br />

– This allows for scissor<strong>in</strong>g<br />

– Each decal is fully featured<br />

• Statically y lit decals re-use lightmaps g p from underly<strong>in</strong>g y g surface<br />

• Dynamically lit decals use additive multi-pass light<strong>in</strong>g<br />

• Decals on dynamic objects:<br />

– Projections are <strong>in</strong> local space<br />

– Re-use matrix to follow the mesh<br />

• Decals on static objects:<br />

– Placed <strong>in</strong> the various static drawlists ( (“fire fire and forget”)<br />

• Static decals (manually placed <strong>in</strong> editor):<br />

– Pre-clipped geometry (no clipp<strong>in</strong>g on GPU)


Example: Blood Smears<br />

• Project j decals on gground and on cover walls when yyou’re<br />

hurt<br />

• Project a new decal every 0.5s while mov<strong>in</strong>g<br />

• Us<strong>in</strong>g fad<strong>in</strong>g “pa<strong>in</strong>tbrush” effect along movement direction<br />

– OOverall ll ffade d + “ “pa<strong>in</strong>tbrush” i tb h” ffade d<br />

– Shader parameter curves exposed to artists<br />

• Mix with standard blood decals to break up pattern


Blood Smears, ,<br />

1 <strong>of</strong> 4


Blood Smears, ,<br />

2 <strong>of</strong> 4


Blood Smears, ,<br />

3 <strong>of</strong> 4


Blood Smears, ,<br />

4 <strong>of</strong> 4


Screen-space Screen space Blood Effects<br />

• Screen-space p blood splatter: p<br />

– Spawned by level design (Kismet), animation (AnimNotify nodes)<br />

or script code<br />

– 3D particle effects that use camera-fac<strong>in</strong>g camera fac<strong>in</strong>g particles<br />

– Game code re-positions these camera-effects each frame<br />

– Allows for more dynamic “screen-space” effects<br />

• FFull-featured ll f t d 3D particle ti l effects ff t<br />

• Artist-made materials (shaders)<br />

• Like any material, can take shader parameters from gameplay script code<br />

• Meshes, sprites, movie textures, normal-mapp<strong>in</strong>g, normal mapp<strong>in</strong>g, etc


World-space World space Blood Effects<br />

• World-space p 3D pparticle<br />

effects<br />

• Use world-space coord<strong>in</strong>ates for fake light<strong>in</strong>g on sprites<br />

and gibs<br />

– Can make up-fac<strong>in</strong>g up fac<strong>in</strong>g pixels brighter brighter, etc<br />

– Normal-mapped sprites helps<br />

• 4x6 “movie frames” <strong>in</strong> a sub-UV texture to get realistic<br />

motion<br />

– 2048x1024 color map + 1024x512 normal map<br />

– Re-used for most liquid-type effects<br />

• Mi Mix meshes h and d sprites i to achieve hi a bbetter 33-D Dffeel<strong>in</strong>g li<br />

• Mix additive and translucent blend<strong>in</strong>g to work well <strong>in</strong> both<br />

dark and bright g<br />

areas


Surface‐space Surface space Blood Effects


Example: Surface-space<br />

Surface space<br />

• Inside the Riftworm, characters use a blood shader<br />

• One scalar shader parameter (0-1) to <strong>in</strong>dicate amount <strong>of</strong> blood<br />

• Texture masks for bloody regions and pattern<br />

• Scroll textures downwards <strong>in</strong> texture-space<br />

– Gradient pattern & normalmap<br />

– (Roughly correlates to down <strong>in</strong> world-space)<br />

• Masks and shader parameter multiply<br />

– UUsed d as llerp ffactor t bbetween t a constant t t blood bl d color l and d un-bloodied bl di d color l<br />

• Blood color have negative Blue and Green components<br />

– Produces slight discoloration <strong>in</strong> the transition areas<br />

• ALL_SoldierShaders.S<strong>in</strong>glePlayer.Bloody.SoldierShader_Bloody


Fluid Simulation<br />

• Us<strong>in</strong>g g our <strong>Unreal</strong> Eng<strong>in</strong>e g 3 fluid simulation feature<br />

– Allows the player to wade through large pools <strong>of</strong> blood<br />

• Ability to raise / lower the entire fluid<br />

– Controlled bby a triggered c<strong>in</strong>ematic<br />

• Simulated on separate thread<br />

• Height-field Height field tessellated on GPU<br />

– No vertex buffer to update, all vertices are created on-the-fly on GPU<br />

– The height-field is used as a dynamic vertex texture<br />

– (Not all platforms)


Example: Riftworm Heart Chamber<br />

• Many y different techniques q <strong>in</strong> comb<strong>in</strong>ation:<br />

– Gore mesh<br />

– Screen-space blood splatter<br />

– World World-space space blood particle effects<br />

– Surface-space shader effect on the ma<strong>in</strong> character<br />

– Blood fluid simulation<br />

• Note: Cutt<strong>in</strong>g through an artery is not done with gore mesh<br />

– Skeleton animation<br />

– Throbb<strong>in</strong>g is morph<strong>in</strong>g geometry


Blood <strong>Techniques</strong><br />

• Movie: Riftworm heart chamber, cha<strong>in</strong>saw<strong>in</strong>g through<br />

, g g<br />

arteries


Morph<strong>in</strong>g Blood Geometry<br />

• Morph<strong>in</strong>g: p g<br />

– Animate <strong>in</strong>dividual vertices, not a skeleton<br />

– Blend between “morph targets” (or “blend shapes”)<br />

• UUsage examples: l<br />

– Throbb<strong>in</strong>g guts <strong>in</strong>side the Riftworm<br />

– Some c<strong>in</strong>ematics use morph targets<br />

– Meatshield, to prevent it from <strong>in</strong>tersect<strong>in</strong>g the holder<br />

• F<strong>in</strong>al example: Exit from the Riftworm<br />

– Notice blood pour<strong>in</strong>g out (morphed geometry)


Blood <strong>Techniques</strong><br />

• Movie: Riftworm exit c<strong>in</strong>ematic


In Conclusion<br />

• Achiev<strong>in</strong>g the right look for blood and gore:<br />

– Mix many different techniques<br />

– Use highly g yfeatured<br />

and flexible tools


About Daniel Wright<br />

• Jo<strong>in</strong>ed Epic Games <strong>in</strong> 2006<br />

• Huge graphics nerd<br />

• OOptimized i i dgraphics hi ffor Xbox b 360, 360 PS3 S3 and d PCC


Topics p<br />

Daniel Wright<br />

• Gore techniques q<br />

• Blood techniques<br />

• Character light<strong>in</strong>g<br />

• Screen Space Ambient Occlusion optimizations


• Gore techniques q<br />

• Blood techniques<br />

• Character light<strong>in</strong>g<br />

– Game light<strong>in</strong>g<br />

– Shadows<br />

– C<strong>in</strong>ematic light<strong>in</strong>g<br />

Topics p<br />

Daniel Wright<br />

• Screen Space Ambient Occlusion optimizations


Game Character Light<strong>in</strong>g Goals<br />

• Integrate g closely y with environment<br />

• M<strong>in</strong>imal artist effort, should ‘just work’<br />

• Upper bound on shad<strong>in</strong>g cost


Background g<br />

• Hundreds <strong>of</strong> static local light sources <strong>in</strong> <strong>Gears</strong> <strong>of</strong> <strong>War</strong> 2 levels


Background g<br />

• Hundreds <strong>of</strong> static local light sources <strong>in</strong> <strong>Gears</strong> <strong>of</strong> <strong>War</strong> 2 levels


Background g<br />

– Some <strong>of</strong> these are dom<strong>in</strong>ant light sources


Background g<br />

– The rest are fill (bounce) lights


Background<br />

• Hundreds <strong>of</strong> static local light g sources <strong>in</strong> <strong>Gears</strong> <strong>of</strong> <strong>War</strong> 2<br />

levels<br />

• Too many to light the character dynamically with all <strong>of</strong><br />

th them!<br />

!


Introduc<strong>in</strong>g the Light Environment<br />

• A Light g Environment consists <strong>of</strong>:<br />

– The <strong>in</strong>cident light<strong>in</strong>g for the object it is responsible for light<strong>in</strong>g<br />

– Update and apply logic


Incident Light<strong>in</strong>g Representation<br />

• Used a Spherical Harmonic basis<br />

• 9 coefficients<br />

Incident light<strong>in</strong>g stored <strong>in</strong> a spherical harmonic basis for two lights


Creat<strong>in</strong>g the Light Environment<br />

• Dynamically y y composite p relevant lights g <strong>in</strong>to the spherical p<br />

harmonic basis unique for each character<br />

• Light visibility determ<strong>in</strong>ed with ray traces<br />

• Separate static and dynamic environments


Creat<strong>in</strong>g the Light Environment<br />

• Static lights g ggo<br />

<strong>in</strong>to the static environment<br />

• For the static environment:<br />

– Update cost is spread across multiple frames<br />

– Update rate is determ<strong>in</strong>ed by visibility, distance to the viewer,<br />

and object importance


Every static update<br />

Creat<strong>in</strong>g the Light Environment<br />

Incident light<strong>in</strong>g from<br />

static lights calculated<br />

Every frame<br />

Incident light<strong>in</strong>g from<br />

dynamic lights calculated<br />

Static environment<br />

<strong>in</strong>terpolated<br />

F<strong>in</strong>al<br />

Representation


Apply<strong>in</strong>g the Light Environment<br />

• Directional light for dom<strong>in</strong>ant direction<br />

Virtual dom<strong>in</strong>ant light


Apply<strong>in</strong>g the Light Environment<br />

• Dual-Hemisphere p light g for rema<strong>in</strong><strong>in</strong>g g environment<br />

• Medium quality<br />

Direct term<br />

Dual-Hemisphere<br />

<strong>in</strong>direct term<br />

Comb<strong>in</strong>ed


Apply<strong>in</strong>g the Light Environment<br />

• Directly y evaluate rema<strong>in</strong><strong>in</strong>g g SH environment pper-pixel p<br />

• Gives highest quality<br />

Direct term<br />

Spherical Harmonic<br />

Indirect term<br />

Comb<strong>in</strong>ed


Fill light<br />

Apply<strong>in</strong>g the Light Environment<br />

Dom<strong>in</strong>ant light


Apply<strong>in</strong>g the Light Environment<br />

• Additional dynamic y lights g can be applied pp<br />

– Useful for quickly chang<strong>in</strong>g gameplay lights like muzzle flashes<br />

– Artist’s discretion


• Shadow direction<br />

Character Shadow<strong>in</strong>g<br />

– Determ<strong>in</strong>ed by dom<strong>in</strong>ant light direction<br />

– Fill lights are excluded


Dom<strong>in</strong>ant light<br />

Character Shadow<strong>in</strong>g<br />

Dom<strong>in</strong>ant light<br />

and shadow<br />

Dom<strong>in</strong>ant light, shadow,<br />

and unshadowed secondary light


C<strong>in</strong>ematic Character Light<strong>in</strong>g<br />

• Mix <strong>of</strong> light environments and multiple shadowed dynamic lights<br />

– Whatever looks best for each c<strong>in</strong>ematic


In Conclusion<br />

• Comb<strong>in</strong>e relevant lights g <strong>in</strong>to one efficient representation<br />

p


Topics p<br />

Daniel Wright<br />

• Gore techniques q<br />

• Blood techniques<br />

• Character light<strong>in</strong>g<br />

• Screen Space Ambient Occlusion optimizations


Topics p<br />

Daniel Wright<br />

• Gore techniques q<br />

• Blood techniques<br />

• Character light<strong>in</strong>g<br />

• Screen Space Ambient Occlusion optimizations<br />

– Review<br />

– Motivation<br />

– Down sampl<strong>in</strong>g<br />

– Temporal filter<strong>in</strong>g<br />

– Computation mask<strong>in</strong>g


Screen Space Ambient Occlusion<br />

RReview i<br />

• Sample neighbor depths<br />

• Compare depth differences<br />

Neighbor<br />

Samples<br />

Viewer<br />

Current Pixel<br />

Occlusion


Screen Space Ambient Occlusion<br />

RReview i<br />

• Noisy y output p<br />

Occlusion


Screen Space Ambient Occlusion<br />

RReview i<br />

• Spatial filter passes<br />

– Remo Removes es high frequency freq enc noise<br />

Ed Edges preserved d<br />

Occlusion<br />

Filter


Screen Space Ambient Occlusion<br />

RReview i<br />

• PC games g have shipped pp with SSAO as a high g end<br />

feature<br />

• <strong>Gears</strong> 2 first console game (that we’re aware <strong>of</strong>)<br />

– Many more com<strong>in</strong>g soon!<br />

• Lots <strong>of</strong> available <strong>in</strong>formation on mak<strong>in</strong>g it look good<br />

• Only talk<strong>in</strong>g about optimiz<strong>in</strong>g here


Basel<strong>in</strong>e<br />

• 720p, 16 occlusion samples, full res, 20 filter samples<br />

Ambient Occlusion only


Basel<strong>in</strong>e<br />

• 720p, 16 occlusion samples, full res, 20 filter samples<br />

Lit


Basel<strong>in</strong>e<br />

• 720p, 16 occlusion samples, full res, 20 filter samples<br />

Lit and Ambient Occlusion


• Motivation<br />

Screen Space Ambient Occlusion<br />

OOptimizations ti i ti<br />

– Shortage <strong>of</strong> GPU resources<br />

– Target<strong>in</strong>g console hardware<br />

• TTrade d <strong>of</strong>f ff quality lit ffor performance<br />

f


• Reduce neighbor samples<br />

Occlusion Pass<br />

– Multi-frequency occlusion is lost<br />

8 occlusion samples, 12 filter samples


• Reduce neighbor samples<br />

Occlusion Pass<br />

– Multi-frequency occlusion is lost<br />

16 occlusion samples, 20 filter samples 8 occlusion samples, 12 filter samples


• Texture cache thrash<strong>in</strong>g<br />

Occlusion Pass<br />

– Due to random per-pixel <strong>of</strong>fsets<br />

• Clamp <strong>of</strong>fset radius <strong>in</strong> screen space


• Downsized render target<br />

– AO is mostly low frequency<br />

Down sampl<strong>in</strong>g<br />

Down sampled by a factor <strong>of</strong> two


• Downsized render target<br />

– AO is mostly low frequency<br />

Down sampl<strong>in</strong>g<br />

Full resolution Down sampled by a factor <strong>of</strong> two


• Downsized render target<br />

Down sampl<strong>in</strong>g<br />

– Use furthest <strong>of</strong> source depths<br />

• Effectively shr<strong>in</strong>ks silhouettes <strong>of</strong> nearby objects<br />

Us<strong>in</strong>g one source depth Us<strong>in</strong>g furthest <strong>of</strong> source depths


Down sampl<strong>in</strong>g<br />

• Downsized render target<br />

– Store depth <strong>in</strong> same render target as occlusion<br />

• Occlusion and filter<strong>in</strong>g passes can reuse<br />

• Later passes can get occlusion and depth with one<br />

texture lookup<br />

• Us<strong>in</strong>g RG16F<br />

– Ended up us<strong>in</strong>g a down sample factor <strong>of</strong> two<br />

– Reduces Xbox 360 resolve cost by a factor <strong>of</strong> four<br />

Down<br />

sample<br />

Occlusion<br />

Filter


Results


• Motivation<br />

Temporal Filter<br />

– Large spatial filters needed to hide low occlusion samples<br />

– Detail is lost with large filters<br />

– Lots <strong>of</strong> variance between frames


Temporal Filter<br />

• Filter the occlusion factor over time<br />

– Reverse Reprojection Cach<strong>in</strong>g<br />

• Use as a filter <strong>in</strong>stead <strong>of</strong> an optimization<br />

Down<br />

sample<br />

Occlusion<br />

Filter<br />

Temporal<br />

Filter


Temporal Filter<br />

• Reverse Reprojection Cach<strong>in</strong>g<br />

Lookup this frame and<br />

last frame frame’ss occlusion<br />

values<br />

If last frame’s frame s value is<br />

<strong>in</strong>valid, throw it away<br />

Otherwise<br />

New = lerp(Current, Old, Rate)<br />

Update the history<br />

with new occlusion


Temporal Filter<br />

• Reverse Reprojection Cach<strong>in</strong>g<br />

Lookup this frame and<br />

last frame frame’ss occlusion<br />

values<br />

If last frame’s frame s value is<br />

<strong>in</strong>valid, throw it away<br />

Otherwise<br />

New = lerp(Current, Old, Rate)<br />

Update the history<br />

with new occlusion


Temporal Filter<br />

• Reverse Reprojection Cach<strong>in</strong>g<br />

Lookup this frame and<br />

last frame frame’ss occlusion<br />

values<br />

If last frame’s frame s value is<br />

<strong>in</strong>valid, throw it away<br />

Otherwise<br />

New = lerp(Current, Old, Rate)<br />

Update the history<br />

with new occlusion


Temporal Filter<br />

• Reverse Reprojection Cach<strong>in</strong>g<br />

Lookup this frame and<br />

last frame frame’ss occlusion<br />

values<br />

If last frame’s frame s value is<br />

<strong>in</strong>valid, throw it away<br />

Otherwise<br />

New = lerp(Current, Old, Rate)<br />

Update the history<br />

with new occlusion


• Dynamic objects<br />

Last Frame<br />

Animation<br />

World space<br />

position p<br />

Screen space<br />

position<br />

Temporal Filter<br />

Source Position<br />

This Frame<br />

Animation<br />

World space<br />

position p<br />

Screen space<br />

position


• Static objects<br />

Last Frame<br />

Temporal Filter<br />

Source Position<br />

Animation<br />

World space<br />

position<br />

This Frame<br />

Screen space<br />

Screen space<br />

position position


Temporal Filter<br />

• Update p history y <strong>of</strong> all pixels p as if they y were static<br />

• Overwrite with correct value for dynamic objects<br />

– Depth test<strong>in</strong>g<br />

Down<br />

sample<br />

Occlusion<br />

Filter<br />

Temporal<br />

Filter Static<br />

Temporal Filter<br />

Dynamic


• Newly Unoccluded pixels<br />

New Pixels<br />

Temporal Filter<br />

h<br />

Character<br />

movement<br />

direction<br />

Halo regions


Temporal Filter<br />

• Additional convergence control<br />

New pixels from camera<br />

rotation for one frame<br />

Pixels with an exist<strong>in</strong>g history<br />

Accelerat<strong>in</strong>g Convergence<br />

over multiple frames<br />

Constant Convergence Rate


Without Temporal Filter


With Temporal Filter


Temporal Filter<br />

• Doesn’t help with static camera/objects


Temporal Filter<br />

• Almost all flicker<strong>in</strong>g gone with mov<strong>in</strong>g camera<br />

• Can get away with less occlusion samples, less filter samples<br />

Camera mov<strong>in</strong>g


Temporal Filter Gotchas<br />

• Accurate last frame position p<br />

• Bil<strong>in</strong>ear filter<strong>in</strong>g<br />

• Double buffer<br />

• World space precision


Temporal Filter Limitations<br />

• Skeletal meshes<br />

• Not detect<strong>in</strong>g g cache misses for every y sample p<br />

Streaks where mov<strong>in</strong>g objects meet


Computation Mask<strong>in</strong>g<br />

• Pixels with m<strong>in</strong>imal occlusion


• First person weapon<br />

Computation Mask<strong>in</strong>g


• Distant pixels<br />

Computation Mask<strong>in</strong>g


Computation Mask<strong>in</strong>g<br />

• Cull these pixels p with Hi-Stencil<br />

– Requires use <strong>of</strong> down sampled depth/stencil buffer<br />

– Special fast case for distance<br />

Computation mask


In Conclusion<br />

• Use Reverse Reprojection p j Cach<strong>in</strong>g g as a temporal p filter<br />

• Use Computation Mask<strong>in</strong>g to avoid do<strong>in</strong>g work where it won’t<br />

be noticed


Questions?<br />

• niklas.smedberg@epicgames.com<br />

• ddaniel.wright@epicgames.com i l i h @ i

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!