47
اک پ دان ز ی ام ه پ ب

به نام یزدان پاک

  • Upload
    wenda

  • View
    50

  • Download
    7

Embed Size (px)

DESCRIPTION

به نام یزدان پاک. جزئیاتی از طراحی موتور بازی ایمان پولادین. مقدمه و معرفی. موضوع و سبک بازی فن آوری های مورد استفاده اهداف پروژه وبلاگ توسعه بازی: http://www.tochalco.com/blog. تاریخچه موتور. تکرار اول: ارتفاء موتور موجود تکرار دوم: تبدیل به DirectX10/11 - PowerPoint PPT Presentation

Citation preview

Page 1: به نام یزدان پاک

به نام یزدان پاک

Page 2: به نام یزدان پاک

جزئیاتی از طراحی موتور بازی ایمان پوالدین

Page 3: به نام یزدان پاک
Page 4: به نام یزدان پاک

مقدمه و معرفی

موضوع و سبک بازی•

فن آوری های مورد استفاده•

اهداف پروژه•

وبالگ توسعه بازی:•http://www.tochalco.com/blog

Page 5: به نام یزدان پاک

تاریخچه موتور

تکرار اول: ارتفاء موتور موجود•

DirectX10/11تکرار دوم: تبدیل به •

Deferred Renderingتکرار سوم: •

دمو•

Page 6: به نام یزدان پاک

تصمیمات استراتژیک

نوشتن موتور از پایه•

•Deferred Rendering

•DirectX 10/11 API

Page 7: به نام یزدان پاک

نوشتن موتور؟

مزایا

دنیا با موتور داخلی تولید شده اند AAA( بازیهای %75حدودا طبق تحقیقات انجام شده اکثر )•موجود است(وبالگ پروژه این تحقیق در مستندات)اطالعات و

عدم وابستگی، توسعه آسانتر، انعطاف پذیری•

معایب

زمان و هزینه باال•ریسک بسیار باال•عدم وجود تخصص و تجربه کافی•

“آقا جان !!! - نوشتن موتور، اختراع دوباره چرخ نیست ”

Page 8: به نام یزدان پاک

Deferred Rendering?

مزایا

قابلیت رندر تعداد زیادی نور دینامیک •\ در نور پردازی• کاهش ترکیب شیدرها مخصوصا Post Process (Depth of Field, SSAO، Motionوجود اطالعات الزم برای پیاده سازی افکت های •

Blur، Soft Particles) به علت وجود Gbufferدارا بودن سرعتی خطی به نسبت تعداد نورها •

• O = Number of Objects• L = Number of Lights• Forward: (O*L) Draws, example: 1000 objects + 20 lights = 20000 draw calls• Deferred: (O + L) Draws, example: 1000 objects + 20 lights = 1020 draw calls

با اعمال شیدرها فقط روی پیکسلهایی که دیده pixel processingصرفه جویی در زمان •میشوند

: استفاده می کنندdeferredاکثر موتورهای مطرح از نور پردازی •• CryEngine2, Battlefield3 (Next-gen), Rockstar RAGE (GTA4, Red dead redemption), X-Ray

engine (Stalker), Metro2033, Dead Space engine, KillZone2, 3, … and the list is growing.

Page 9: به نام یزدان پاک

DirectX 10+?

آینده

/Steam : http://store.steampowered.com/hwsurveyآمار از سایت •

با توجه موارد ذکر شده، در زمان اتمام پروژه سخت افزارها و سیستم عامل مورد نیاز متداول خواهند بود و

نوعی آینده نگری است.APIسرمایه گذاری روی این

Page 10: به نام یزدان پاک

تولید محتوای گرافیکی

Page 11: به نام یزدان پاک

تولید محتوای گرافیکی

Page 12: به نام یزدان پاک

تولید محتوای گرافیکی

Page 13: به نام یزدان پاک

تولید محتوای گرافیکی

Page 14: به نام یزدان پاک

Deferred Rendering - GBuffer

Material(MaterialD + AO)

Color + Specular

Depth Normals

Page 15: به نام یزدان پاک

Deferred Rendering - Lighting

• Tile based deferred lighting– Andrew Lauritzen -

http://visual-computing.intel-research.net/art/publications/deferred_rendering/lauritzen_deferred_shading_siggraph_2010.pptx

• Divide screen in tiles• Cull screen space lights with each tile• Do deferred lighting• Repeat for next tile

Page 16: به نام یزدان پاک

Deferred Rendering - Performance• Scene ~ 350k triangles – PSSM Shadows• Intel Core2 E5300 (low-end)• ATI – 4850 (mid-range)• 200 Lights - 1024x768 – 133fps• 100 Lights – 1024x768 – 200fps• 1000 Lights – 1024x768 – 31 fps• 1 Light (sun) – 1024x768 – 302 fps• Still room for more optimization• Isn’t it NICE ?!

– Throw dynamic lights everywhere. Explosions, gun fire, car head lights, city lights, etc.

Page 17: به نام یزدان پاک

Shadows - PSSM

• PSSM is just Cascaded shadow maps with efficient frustum spliting scheme– Split view frustum in N parts with PSSM splitting scheme– Adjust imaginary sun position on the bounding sphere of

the world– Detect shadow caster/receiver objects in each split from

light’s point of view– Draw shadow maps for each split (total N shadow maps)– When rendering objects, read back from proper shadow

map within position range

Page 18: به نام یزدان پاک

Shadows – PSSM 2• PROS

– Best looking shadows on big outdoor environments– Preseves shadow quality within the whole view range– Used in many big games : Red dead redemption, Assassin’s Creed,

KillZone2, Battlefield2, …

• CONS– Very GPU/CPU intensive (usually 3-4 big shadow map renders, and 3-4

shadow map read backs with branching, culling, etc.)

Page 19: به نام یزدان پاک

Shadows – PSSM – Speed Problem

• Here comes D3D10 !• Using D3D10 specific stuff

– Texture Arrays– Geometry shaders– D3D10 Instancing– Branching (also applicable to D3d9 sm3.0 hw)

• With the help of D3D10 : Generating 4 CSM shadow maps from …• Main Bottleneck – Object Culling , DrawCalls

80 Objects ~ 400 Draw calls

4 Render target changes

80 Objects~ 100 Draw calls

1 Render target change~ 3x speed increase

D3D9 D3D10/10.1

Page 20: به نام یزدان پاک

Shadows – PSSM

Page 21: به نام یزدان پاک

HDR Lighting

No HDR

Page 22: به نام یزدان پاک

HDR Lighting

HDR + Bloom

Page 23: به نام یزدان پاک

HDR Lighting

Luminance Map

Downscale

FinalLuminance Value

Bright Filter

Blur

Page 24: به نام یزدان پاک

Engine Core

• Memory Management: – Leak Detection– Memory Tracking (By ID)– Alignement– Data Structure : SkipList

• Profiling: – Hierarchal Profiling of subsystems– TOCHAL_BEGIN_PROFILE– TOCHAL_END_PROFILE– Live display of profiling data for debugging purposes, using

scaleform ui integration (discussed later)

Page 25: به نام یزدان پاک

Engine Core - Memory

• SkipList ->

Page 26: به نام یزدان پاک

Engine Core - Memory

// Allocate Rigid bodies into physics sybsystembyte* ptr = tnew(TOCHAL_MEMID_PHYSICS) tlCRigidBody[100];tdelete ptr;

Page 27: به نام یزدان پاک

Engine Core

• Exception Handling: – Suitable for Load/Initialization– We don’t use them in Render Frame – Call Stack, Details

• Error/Event Log: – LOG_TEXT, LOG_WARNING, LOG_LOAD, LOG_ERROR– Exceptions – Call Stack

• Containers:- We have our own custom Containers, Don’t use STL- STL: No custom memory management, code overhead

Page 28: به نام یزدان پاک

Terrain• History:

– Our Voxel Terrain Demo

• The Two Aspects: – Terrain Geometry (VSD, LOD,…)– Terrain Material

Page 29: به نام یزدان پاک

Terrain Contd• Geometry Algorithms:

– Brute Force– ROAM– Geo Mip Mapping– Quad Trees– Geo ClipMap

• Problems: – Some algorithms are not for games– Some algorithms are not GPU Friendly– Some algorithms do not use the modern hardware

features like instancing, geometry shaders, etc

Page 30: به نام یزدان پاک

Terrain Contd• Chunk Based Methods:

– Divide whole terrain into chunks– A Chunk must be drawn using 1 DrawCall– Use some scene management for visibility check & culling– Do some LOD management on chunks

• Problems: – LOD Switches and T-Junction removal

Page 31: به نام یزدان پاک

Terrain Contd• Scene Management/Partitioning:

– Quad Tree variant– More on this later

• LOD Management: – Heuristic function deciding which LOD Chunk to use– Take into account, distance, camera fov, viewing angle,

terrain height difference

Page 32: به نام یزدان پاک

T-Junction Problem

Page 33: به نام یزدان پاک

T-Junction Problem

Page 34: به نام یزدان پاک

T-Junction Problem

Page 35: به نام یزدان پاک

T-Junction Removal• Methods:

– Draw an skirt geometry (ugly)– Interpolate the middle vertex (process intensive)– The FrostBite Engine 1 method

• Method we have used (FrostBite One): – LOD level of adjacent chunks is limited to one– Prepare some connection strip in the borders of each

chunk– Generate permutations for each chunk connecting from

different sides to adjacent neighbors

Page 36: به نام یزدان پاک

T-Junction Problem Solved

Page 37: به نام یزدان پاک

Terrain Materials• Methods:

– Use a middle size texture map+detail textures– Use texture splatting– Use middle size texture map+detail weight map+detail

textures– Use a gigantic texture to paint and cover whole terrain

(MegaTexture: id Tech5 Engine)– Shader Splatting (FrostBite Engine)– Hybrid methods

Page 38: به نام یزدان پاک

Terrain Materials• Our Method:

– Hybrid one using both procedural and pre-calculated details

– Uses channels and layers like terrain Height, Slope, AO, Curvature, Angle to generate detail texture blend weights

– Uses several detail texture maps via DX10’s Texture Arrays to reduce draw calls

• Terrain Material Editor: – Node Based (Graph Based) material editor– Automatically generates shader code from user created

material graph

Page 39: به نام یزدان پاک

Scene Management• Why we need them?

– Visibility determination (reducing GPU load)– Update cancelation (reducing CPU load)– Fast ray intersection tests– Fast Line of Sight tests– …

• Methods :– Quad-Tree– BSP Tree– Octree– AABB Tree

Page 40: به نام یزدان پاک

Scene Management Contd• What we do

– Quad-Tree for terrain , why?– AABB-Tree for other geometry/objects, why?– Recursive data structure are bad for both instruction/data

cache– We use some trick to store a tree in a linear and non-

recursive structure– The traversal code is non-recursive tricky too– Does not disturb memory caching! – SSE optimized Box/Frustum test routine will be used on this

data (to be implemented)– The way we store/traverse trees, makes the possibility of

using multiple cores to speed-up culling routine

Page 41: به نام یزدان پاک

User interface• Strategies

– Writing your own controls and UI stuff (Pros/Cons)– Using third party custom controls (Pros/Cons)– Using Flash or HTML (Hikari, Webkit,…)– Scaleform Solution

• Why using scaleform– Widely used by well knows brands, AAA titles– The UI content creation and authoring tools are real pain!, Scaleform

uses flash so you have Adobe Flash as a powerful UI authoring tool– You can save too much budget by hiring a flash developer for your UI– Fancy game menus, in-game UI, HUDs are possible at no cost

• What we use– We integrated scaleform into our engine

Page 42: به نام یزدان پاک

User interface• Strategies

– Writing your own controls and UI stuff (Pros/Cons)– Using third party custom controls (Pros/Cons)– Using Flash or HTML (Hikari, Webkit,…)– Scaleform Solution

• Why using scaleform– Widely used by well knows brands, AAA titles– The UI content creation and authoring tools are real pain!, Scaleform

uses flash so you have Adobe Flash as a powerful UI authoring tool– You can save too much budget by hiring a flash developer for your UI– Fancy game menus, in-game UI, HUDs are possible at no cost

• What we use– We integrated scaleform into our engine

Page 43: به نام یزدان پاک

Current Tasks

• Havok Physics Integration• Animation Subsystem w/Havok Animation binding• Particle System Integration/Rendering• Game Entity System• Game World Editor• Terrain Stuff• AABB-Tree implementation

Page 44: به نام یزدان پاک

دمو

برنامه نویس: •سپهر تقدیسیانعلی سیداف

هادی رحیمی

گرافیست:•مهام بری

بهزاد حسین زاده

Page 45: به نام یزدان پاک

سوال؟

Page 46: به نام یزدان پاک

اطالعات پروژه

وبالگ توسعه بازی:•http://www.tochalco.com/blog

فرصت های شغلی موجود برای نیروهای برنامه •نویس، گرافیست،... )تماس از طریق ایمیل(

[email protected]

Page 47: به نام یزدان پاک

پایان