doom3 : the guts of a rendering enginepages.cpsc.ucalgary.ca/~bdstephe/585_w09/d204_doom.pdfgame...

23
DOOM DOOM 3 : The guts of a rendering engine : The guts of a rendering engine

Upload: others

Post on 17-Oct-2020

0 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: DOOM3 : The guts of a rendering enginepages.cpsc.ucalgary.ca/~bdstephe/585_W09/d204_doom.pdfGame design decisions • You always need to look at your game design to pick the best mix

DOOMDOOM33 : The guts of a rendering engine : The guts of a rendering engine

Page 2: DOOM3 : The guts of a rendering enginepages.cpsc.ucalgary.ca/~bdstephe/585_W09/d204_doom.pdfGame design decisions • You always need to look at your game design to pick the best mix

IntroductionIntroduction

• BackgroundBackground• Game DesignGame Design• TechniquesTechniques• TradeoffsTradeoffs• Problems and SolutionsProblems and Solutions

Page 3: DOOM3 : The guts of a rendering enginepages.cpsc.ucalgary.ca/~bdstephe/585_W09/d204_doom.pdfGame design decisions • You always need to look at your game design to pick the best mix

BackgroundBackground

• Doom Doom – One of the most successful PC games of all timeOne of the most successful PC games of all time– Kicked off “First Person Shooter” and “Deathmatch” gamesKicked off “First Person Shooter” and “Deathmatch” games– Visually stunning (at the time)Visually stunning (at the time)

• Doom III Doom III – Remake of DOOM using modern rendering technologyRemake of DOOM using modern rendering technology

• Why do we care?Why do we care?– Lots to learnLots to learn– One of the first games to really push modern rendering hardwareOne of the first games to really push modern rendering hardware– Several interesting design choices and tradeoffsSeveral interesting design choices and tradeoffs– Id Software very open about technologyId Software very open about technology

• It's one of the few non-Radical games that we can talk It's one of the few non-Radical games that we can talk knowledgeably aboutknowledgeably about

Page 4: DOOM3 : The guts of a rendering enginepages.cpsc.ucalgary.ca/~bdstephe/585_W09/d204_doom.pdfGame design decisions • You always need to look at your game design to pick the best mix

Game design decisionsGame design decisions

• You always need to look at your game design to pick the You always need to look at your game design to pick the best mix or rendering featuresbest mix or rendering features

• For DoomFor Doom– Mood : dark, scary Mood : dark, scary – Environment : Military base on Mars, HellEnvironment : Military base on Mars, Hell– Game-play : FPS, with shades of survival horror, single-player focusGame-play : FPS, with shades of survival horror, single-player focus

• Slower paced and fewer enemies than originalSlower paced and fewer enemies than original

• What does that mean?What does that mean?– Environment is constrained, few big vistasEnvironment is constrained, few big vistas

• Also, few organic environmentsAlso, few organic environments– Some performance can be sacrificed for lookSome performance can be sacrificed for look

• Lighting is crucial for generating atmosphereLighting is crucial for generating atmosphere

Page 5: DOOM3 : The guts of a rendering enginepages.cpsc.ucalgary.ca/~bdstephe/585_W09/d204_doom.pdfGame design decisions • You always need to look at your game design to pick the best mix

Game design decisions (cont'd)Game design decisions (cont'd)

• Example : Survival horrorExample : Survival horror– Want to be able to surprise playerWant to be able to surprise player

• ““Why is that wall a different colour?” problemWhy is that wall a different colour?” problem– Solution : Uniform surface renderingSolution : Uniform surface rendering

• All models in game are rendered the same wayAll models in game are rendered the same way– In most games, statics and dynamics are dealt with quite In most games, statics and dynamics are dealt with quite

differentlydifferently– ProblemsProblems

• Need to select general purpose techniquesNeed to select general purpose techniques– Lightmaps great for statics, but awful for dynamicsLightmaps great for statics, but awful for dynamics

Page 6: DOOM3 : The guts of a rendering enginepages.cpsc.ucalgary.ca/~bdstephe/585_W09/d204_doom.pdfGame design decisions • You always need to look at your game design to pick the best mix

TechniquesTechniques

• Uses several important techniques that fit together wellUses several important techniques that fit together well– Stencil volume shadowsStencil volume shadows– Bump mappingBump mapping– Projected texture lightsProjected texture lights– Pass per lightPass per light

• Ignores other important techniques that are not a good fitIgnores other important techniques that are not a good fit– Static lighting (light maps)Static lighting (light maps)– Shadow buffersShadow buffers– Projected texture shadowsProjected texture shadows– Height fieldsHeight fields– LODLOD– Hardware vertex processingHardware vertex processing

Page 7: DOOM3 : The guts of a rendering enginepages.cpsc.ucalgary.ca/~bdstephe/585_W09/d204_doom.pdfGame design decisions • You always need to look at your game design to pick the best mix

Stencil volume shadowsStencil volume shadows• Draw extruded shadow volumesDraw extruded shadow volumes

– Use z-test, write to stencil bufferUse z-test, write to stencil buffer• AdvantagesAdvantages

– Consistent – can apply to dynamics and staticsConsistent – can apply to dynamics and statics• Light maps don't work for dynamicsLight maps don't work for dynamics• Projected shadows don't work for staticsProjected shadows don't work for statics

– Handles self shadowingHandles self shadowing– Fully dynamic lighting at reasonable costFully dynamic lighting at reasonable cost

• DisadvantagesDisadvantages– Requires relatively low polygon count modelsRequires relatively low polygon count models

• Lots of CPU vertex processingLots of CPU vertex processing– High fill rate requirementHigh fill rate requirement– No soft shadowsNo soft shadows– Can only shadow from one lightCan only shadow from one light

Page 8: DOOM3 : The guts of a rendering enginepages.cpsc.ucalgary.ca/~bdstephe/585_W09/d204_doom.pdfGame design decisions • You always need to look at your game design to pick the best mix
Page 9: DOOM3 : The guts of a rendering enginepages.cpsc.ucalgary.ca/~bdstephe/585_W09/d204_doom.pdfGame design decisions • You always need to look at your game design to pick the best mix

Bump mappingBump mapping

• Store normal information for a surface in textureStore normal information for a surface in texture• AdvantagesAdvantages

– Adds lots of detail without adding polygonsAdds lots of detail without adding polygons• Fits well with stencil shadows, stencil shadows need low polygon Fits well with stencil shadows, stencil shadows need low polygon

counts, bump mapping fills in detailscounts, bump mapping fills in details– ScalableScalable

• Can be turned off with reasonable quality lossCan be turned off with reasonable quality loss• DisadvantagesDisadvantages

– Burns texture memory, read bandwidthBurns texture memory, read bandwidth– Needs sophisticated pixel processingNeeds sophisticated pixel processing

• Or lots of passes on older hardwareOr lots of passes on older hardware– Content generation is a real painContent generation is a real pain– Can only handle one lightCan only handle one light

Page 10: DOOM3 : The guts of a rendering enginepages.cpsc.ucalgary.ca/~bdstephe/585_W09/d204_doom.pdfGame design decisions • You always need to look at your game design to pick the best mix
Page 11: DOOM3 : The guts of a rendering enginepages.cpsc.ucalgary.ca/~bdstephe/585_W09/d204_doom.pdfGame design decisions • You always need to look at your game design to pick the best mix
Page 12: DOOM3 : The guts of a rendering enginepages.cpsc.ucalgary.ca/~bdstephe/585_W09/d204_doom.pdfGame design decisions • You always need to look at your game design to pick the best mix

Projected texture lightsProjected texture lights

• Don't use standard directional/point/spot lights at allDon't use standard directional/point/spot lights at all• For each light define a projector frustum and textureFor each light define a projector frustum and texture• Use projective UV co-ordinate generation to map onto Use projective UV co-ordinate generation to map onto

surfacessurfaces

Page 13: DOOM3 : The guts of a rendering enginepages.cpsc.ucalgary.ca/~bdstephe/585_W09/d204_doom.pdfGame design decisions • You always need to look at your game design to pick the best mix

Projected texture lights (cont'd)Projected texture lights (cont'd)

• AdvantagesAdvantages– Allows artists to “shape” lightAllows artists to “shape” light

• Flashlight beamFlashlight beam• Stained glassStained glass

– Can be used to fake certain effects that stencil shadows precludeCan be used to fake certain effects that stencil shadows preclude• Build soft/complex shadow into lightBuild soft/complex shadow into light

• DisadvantagesDisadvantages– Lights will appear on back of objectsLights will appear on back of objects

• Not a problem with universal stencil shadowingNot a problem with universal stencil shadowing– Uses lots of texture read bandwidthUses lots of texture read bandwidth– Can only handle one lightCan only handle one light

Page 14: DOOM3 : The guts of a rendering enginepages.cpsc.ucalgary.ca/~bdstephe/585_W09/d204_doom.pdfGame design decisions • You always need to look at your game design to pick the best mix
Page 15: DOOM3 : The guts of a rendering enginepages.cpsc.ucalgary.ca/~bdstephe/585_W09/d204_doom.pdfGame design decisions • You always need to look at your game design to pick the best mix

Pass per lightPass per light

• Bump mapping, stencil shadows and projected lights all have Bump mapping, stencil shadows and projected lights all have a big problema big problem– The can only deal with one light at a timeThe can only deal with one light at a time

• Solution : Do a rendering pass for every lightSolution : Do a rendering pass for every light– First – Draw world into z-bufferFirst – Draw world into z-buffer

• Simplifies stencil processing to have opaque world in z-buffer firstSimplifies stencil processing to have opaque world in z-buffer first– For each lightFor each light

• Calculate shadow extrusions for all meshes for current lightCalculate shadow extrusions for all meshes for current light• Render shadow volumes to stencil bufferRender shadow volumes to stencil buffer• Render each surface with stencil using current lights projected Render each surface with stencil using current lights projected

texture and sum to frame buffertexture and sum to frame buffer• ProblemProblem

– Lights become very expensiveLights become very expensive– This is okay for a dark, moody worldThis is okay for a dark, moody world

Page 16: DOOM3 : The guts of a rendering enginepages.cpsc.ucalgary.ca/~bdstephe/585_W09/d204_doom.pdfGame design decisions • You always need to look at your game design to pick the best mix
Page 17: DOOM3 : The guts of a rendering enginepages.cpsc.ucalgary.ca/~bdstephe/585_W09/d204_doom.pdfGame design decisions • You always need to look at your game design to pick the best mix

Other stuffOther stuff

• In rendering pass for each light, other stuff can be layered In rendering pass for each light, other stuff can be layered on for glitzon for glitz– SpecularSpecular

– Environment mapEnvironment map

– GlowGlow

– Etc.Etc.

Page 18: DOOM3 : The guts of a rendering enginepages.cpsc.ucalgary.ca/~bdstephe/585_W09/d204_doom.pdfGame design decisions • You always need to look at your game design to pick the best mix

TradeoffsTradeoffs

• What these techniques getWhat these techniques get– Extremely flexible lightingExtremely flexible lighting

– Consistent surface responseConsistent surface response

– High detail appearance inside polygonsHigh detail appearance inside polygons

• What they costWhat they cost– Need low polygon environments and objectsNeed low polygon environments and objects

– Lots of CPU work on verticesLots of CPU work on vertices

– No soft shadowing No soft shadowing

• So it's good for dark, dramatically lit interior environmentSo it's good for dark, dramatically lit interior environment– Surprise, surpriseSurprise, surprise

Page 19: DOOM3 : The guts of a rendering enginepages.cpsc.ucalgary.ca/~bdstephe/585_W09/d204_doom.pdfGame design decisions • You always need to look at your game design to pick the best mix

Problems & solutionsProblems & solutions

• Problem : Lights get expensiveProblem : Lights get expensive– Need to extrude shadow volumes for each lightNeed to extrude shadow volumes for each light– Need to render large shadow polygons for each lightNeed to render large shadow polygons for each light

• SolutionsSolutions– Need to determine occluding set for each light, as well as visible set Need to determine occluding set for each light, as well as visible set

for scenefor scene– Minimise rendering cost associated with each lightMinimise rendering cost associated with each light

• Discard meshes that are fully in shadowDiscard meshes that are fully in shadow• Minimise fill rate by using the “Fill the z-buffer first” trick Minimise fill rate by using the “Fill the z-buffer first” trick

– Educate artistsEducate artists• In FPS engines of the last five years, lights have been quite low In FPS engines of the last five years, lights have been quite low

cost, thanks to lightmapscost, thanks to lightmaps• Artists need to understand the costs associated with adding a Artists need to understand the costs associated with adding a

light in a system like thislight in a system like this

Page 20: DOOM3 : The guts of a rendering enginepages.cpsc.ucalgary.ca/~bdstephe/585_W09/d204_doom.pdfGame design decisions • You always need to look at your game design to pick the best mix

Problems & solutions (cont'd)Problems & solutions (cont'd)

• Problem : Creating bump maps is a problemProblem : Creating bump maps is a problem– Building them by hand in very unintuitiveBuilding them by hand in very unintuitive

• Solution : Calculate themSolution : Calculate them– Build geometry at high resolutionBuild geometry at high resolution– Use a tool to generate the bump map and a low resolution mesh Use a tool to generate the bump map and a low resolution mesh

from the geometryfrom the geometry• For characters, that's itFor characters, that's it• For environments, generated bump map is then applied to world For environments, generated bump map is then applied to world

by level designerby level designer

Page 21: DOOM3 : The guts of a rendering enginepages.cpsc.ucalgary.ca/~bdstephe/585_W09/d204_doom.pdfGame design decisions • You always need to look at your game design to pick the best mix

Problems & solutions (cont'd)Problems & solutions (cont'd)

• Many moreMany more– How to manage decalsHow to manage decals– Caching extruded shadow edgesCaching extruded shadow edges– Accelerating some vertex operations with hardwareAccelerating some vertex operations with hardware– Decomposing into multiple passes for older rendering hardwareDecomposing into multiple passes for older rendering hardware– Etc.Etc.

Page 22: DOOM3 : The guts of a rendering enginepages.cpsc.ucalgary.ca/~bdstephe/585_W09/d204_doom.pdfGame design decisions • You always need to look at your game design to pick the best mix

ConclusionsConclusions

• Consider game design issues when selecting rendering Consider game design issues when selecting rendering techniquestechniques

• Some techniques may compliment each otherSome techniques may compliment each other

• Don't be afraid to lose a feature that you don't really need to Don't be afraid to lose a feature that you don't really need to gain something elsegain something else

• Zombies are scaryZombies are scary

Page 23: DOOM3 : The guts of a rendering enginepages.cpsc.ucalgary.ca/~bdstephe/585_W09/d204_doom.pdfGame design decisions • You always need to look at your game design to pick the best mix