Introduction to Level Optimization Sai-Keung Wong Chiao Tung University, Taiwan, R.O.C. Reference:...

Post on 14-Dec-2015

222 views 2 download

Transcript of Introduction to Level Optimization Sai-Keung Wong Chiao Tung University, Taiwan, R.O.C. Reference:...

Introduction to Level Optimization

Sai-Keung WongChiao Tung University, Taiwan, R.O.C.

Reference: Mastering Unreal Technology (MUT)

Contents

• Introduction to level optimization

Introduction to Level Optimization• You just finish one half of the game after a game level is done. • Prepare to finish the second half

– Level optimization• Why?• Some players cannot play your game smoothly on their own computer

due to too high “complexity” of your game– Lighting– Texture density– Model complexity– Scene computation, e.g. occlusion

• The strategy– Remove something that is unnecessary– Reduce the texture density– Reduce the model complexity

Optimization:Simple approach

• Occlusion– If something cannot be seen, remove it

• If a model cannot hide something, don’t use it as an occluder

occluded visible

occluder

eye

System Consumption

• Total computation time in different items– Program execution• e.g. Data management, game control

– Rendering• e.g. Display objects on screen, lighting computation

In-Game Statistics

• An overview of the system consumption in different aspects

• Play the game and check the statistics– Press TAB, and enter “View scenerendering

• Examples– Frame rate– CPU Rendering time– GPU Rendering time

Commands for statistics

• STAT FPS ( Frames per second / frame rate ) – Show frames per second

• STAT SCENERENDERING (統計場景渲染) – Rendering time for lighting, translucent, occlusion

• STAT MEMORY (統計内存) – Memory usage

• STAT ENGINE (統計引擎) – Terrain, foliage, HUD, skeletal mesh

Commands for statistics

• STAT STREAMING (統計流) – Statistics about streaming

• STAT AUDIO (統計音频)

SHOW Commands ( 顯示命令 )

• Show or hide items

• SHOW BSP (顯示 BSP ) – Show binary space partition planes

• SHOW DYNAMICSHADOWS (顯示動態陰影)

• SHOW UNLITTRANSLUCENCY (顯示未照亮的半透明物體)

SHOW Commands ( 顯示命令 )

• SHOW POSTPROCESS (顯示後處理) • SHOW PARTICLES (顯示粒子) • SHOW FOLIAGE (顯示植被) – for terrain

• SHOW RIGIDBODY (顯示剛體)

VIEWMODE Commands ( 查看模式命令 )

• VIEWMODE commands: change the in-game view mode – Show information about rendering

• VIEWMODE WIREFRAME (綫框查看模式)

VIEWMODE Commands ( 查看模式命令 )

• VIEWMODE UNLIT (無光照查看模式) – No lighting and shadows

• VIEWMODE LIT (光照查看模式) – Display with textures, lightings and shadows

• VIEWMODE LIGHTINGONLY(僅光照查看模式) – No textures

VIEWMODE Commands ( 查看模式命令 )

• VIEWMODE LIGHTCOMPLEXITY(光照複雜度查看模式) – Display surfaces affected by lighting

VIEWMODE Commands ( 查看模式命令 )

• VIEWMODE TEXTUREDENSITY (貼圖密度查看模式) • High density: red• Medium density: green• Low density: blue

Optimization step one: statistics and lighting complexity

• Load a game level• Play from here • Press TAB or ‘`’

Optimization step one: statistics and lighting complexity

View modelcomplexity

Optimization step one: statistics and lighting complexity

VIEWMODE TEXTUREDENSITY

Optimization step one: statistics and lighting complexity

VIEWMODE LIGHTINGONLY

Optimization step one: statistics and lighting complexity

VIEWMODE UNLIT

STAT SCENERENDERING

Occlusion

• If an object is occluded, it is not rendered.• How to determine whether an object is

occluded or not?• Check whether its bounding volume is visible

or not.

Occlusion

• If an object is not good to be an occluder, disable it.

Optimization step two:lighting and shadows

• For dynamic shadows, shader is used for manipulating the shadow buffer for softening the edges of shadows.

• Move the light sources farther away from the objects so as to make the shadows smaller.

Light Maps

• Light maps are pre-computed. Consume memory space only.

• Almost no rendering penalty• Use them extensively• For example, if an object is not affected y

dynamic lighting, set bForceDirectLightMap = true– Shadow buffer will not be used

Lighting environments( 光源環境 )

• Create a single modulated shadow for several light sources.

• Better performance compared to dynamic lighting.

Light functions (光照函數)• Any light maps associated with a light source

cannot be used if light functions are applied for the light source.

• Avoid using them.

Lighting on MLM_Unlit materials

• Materials with MLM_Unlit

• If a material is not affected by lighting, set bAcceptsLights = false

Statistics browser for geometry

• Content browser->Primitive stats

Statistics browser for geometry • Type – types of the objects• Count – numbers • Triangles – number of triangles • Resource Size – memory size• Lights (avg LM) – number of light maps• Lights (avg other) – number of non-light maps • Lights (Avg total) – Lights (avg LM) + Lights (avg other) • Obj/ Light cost – number of times a mesh is drawn per frame

• Triangle cost – cost of rendering triangles• Lightmap – number of light maps• Shadowmap – number of shadow maps• LM Res – average light map resolution• Sections – number of sections• Radius (min) – minimum radius of bounding volumes• Radius (max) – maximum radius of bounding volumes• Radius (avg) – average radius of bounding volumes• Radius (min/max/avg) – the radius information of each mesh

Statistics browser for geometry

Material optimization

• Use fewer materials

Material optimization

• The most complex materials should not be too complex.

Unlit translucent Objects ( 無光照的半透明物體 )

• Overdraw problem

Optimization step three: light environment for dynamic shadows

• Use shadow volume• Light environment

Optimization step three: light environment for dynamic shadows

• Press F4->DynamicSMActor > Light Environment > LightEnvironmentComponent– bEnabled 。

• Make the environment brighter• LightShadowMode (光源陰影模式)

-> set as LightShadow_Modulate( 調制陰影 )

Level optimization

• Check fps after optimization