09.11.2012 Views

Design and Implementation of a 3D Action Puzzle Game

Design and Implementation of a 3D Action Puzzle Game

Design and Implementation of a 3D Action Puzzle Game

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

<strong>Design</strong> <strong>and</strong> <strong>Implementation</strong> <strong>of</strong> a<br />

<strong>3D</strong> <strong>Action</strong> <strong>Puzzle</strong> <strong>Game</strong><br />

Entwurf und Implementierung eines <strong>3D</strong> <strong>Action</strong>-<strong>Puzzle</strong> Spiels<br />

Falco Wockenfuß<br />

Bachelor degree dissertation attendant to<br />

“Realtime Techniques for Computer <strong>Game</strong>s”<br />

Supervising tutor: Pr<strong>of</strong>. Dr. Maic Masuch<br />

Trier, 03/06/2009


Gratitude<br />

This project would not have been possible without the support <strong>and</strong> collaboration <strong>of</strong> the whole<br />

Assembler Bay design team. Jörg Meyer <strong>and</strong> Pascal Leyrat provided the impressive visuals,<br />

the catchy soundtrack <strong>and</strong> made the idea <strong>of</strong> Assembler Bay become reality. My highest tribute<br />

goes to them <strong>and</strong> their long lasting motivation to create this game.<br />

I have to thank my family <strong>and</strong> friends for their permanent support <strong>and</strong> motivating<br />

words. Although I had hardly much spare time for them in the last 6 months, they kept on<br />

cheering me up <strong>and</strong> assisting me wherever they could.<br />

I am also grateful to Pr<strong>of</strong>. Dr. Maic Masuch, who helped to make this paper possible<br />

in its current form. Without his courtesy, this paper would miss some important parts. On the<br />

side <strong>of</strong> communications design Pr<strong>of</strong>. Dr. Franz Kluge was the supporting pillar, who believed<br />

in the success <strong>of</strong> this interdisciplinary project. Last but not least I have to thank the whole department<br />

<strong>of</strong> computer science <strong>and</strong> foremost its dean Pr<strong>of</strong>. Dr. Andres Künkler. Their backing<br />

helped to get this project to the point it is now. I hope the support <strong>of</strong> all these people will last<br />

until the game is finally complete.<br />

II


Outline<br />

This paper depicts the process <strong>of</strong> developing a prototype for a <strong>3D</strong> computer game <strong>and</strong> the underlying<br />

game engine. It includes in depth information about game design basics as well as<br />

detail about the implementation <strong>of</strong> various game engine features. These features include a<br />

physics engine, modern rendering techniques <strong>and</strong> advanced shadow mapping algorithms. The<br />

elaboration <strong>of</strong> a game concept <strong>and</strong> the resulting game design paper is detailed for the game<br />

Assembler Bay, which was developed in the scope <strong>of</strong> this project. Additionally modern games<br />

will be analyzed for requirements <strong>and</strong> expectations at their technologies. The most important<br />

<strong>of</strong> these features are included in the game Assembler Bay.<br />

Zusammenfassung (German)<br />

Diese Arbeit befasst sich mit der Entwicklung eines Prototyps für ein digitales <strong>3D</strong>-Spiel und<br />

der zugrunde liegenden Spielengine. Sie enthält sowohl detaillierte Informationen über die<br />

Grundlagen des Spieldesigns als auch Einzelheiten über die Implementierung verschiedener<br />

Komponenten der Spielengine. Diese Komponenten umfassen unter <strong>and</strong>erem eine Physikengine,<br />

moderne Rendering-Techniken und moderne Verfahren zur Schattenberechnung mit<br />

Hilfe von Texturen (Shadow Mapping). Die Ausarbeitung eines Spielkonzepts und der daraus<br />

Folgenden Spieldesign-Vorlage sind anh<strong>and</strong> des Spiels Assembler Bay beschrieben, welches<br />

im Rahmen dieses Projekts entwickelt wurde. Zusätzlich werden verschiedene moderne Computerspiele<br />

auf Anforderungen und Erwartungen an die verwendeten Technologien analysiert.<br />

Die wichtigsten dieser Technologien sind im Spiel Assembler Bay enthalten.<br />

III


Table <strong>of</strong> Contents<br />

1 Introduction.....................................................................................................1<br />

1.1 Motivation – We Want to Make a <strong>Game</strong>!...................................................................1<br />

1.2 Task – State <strong>of</strong> the Art <strong>Game</strong> <strong>Design</strong>..........................................................................2<br />

1.3 Planning a <strong>Game</strong> – From Concept to <strong>Implementation</strong>..............................................3<br />

1.4 Make it Different – Characteristics <strong>of</strong> a Unique <strong>Game</strong>.............................................5<br />

2 Engine <strong>Design</strong>...................................................................................................7<br />

2.1 Structure – Duties <strong>of</strong> a <strong>Game</strong> Engine..........................................................................7<br />

2.1.1 Basic Structure <strong>of</strong> a <strong>3D</strong> <strong>Game</strong> Engine.....................................................................8<br />

2.1.2 Why a Physics Engine is Required in Modern <strong>Game</strong>s............................................9<br />

2.1.3 Artificial Intelligence in Modern <strong>Game</strong>s...............................................................10<br />

2.1.4 Input H<strong>and</strong>ling for <strong>3D</strong> <strong>Game</strong>s...............................................................................11<br />

2.1.5 Content Management <strong>and</strong> Content Processing......................................................13<br />

2.1.6 <strong>Game</strong> Screen Management <strong>and</strong> Scene Administration.........................................13<br />

2.1.7 Hardware Compatibility........................................................................................14<br />

2.2 Graphics – Rendering Techniques <strong>and</strong> Lighting......................................................14<br />

2.2.1 Transform <strong>and</strong> Lighting – Rendering Techniques.................................................15<br />

2.2.2 Forward Rendering – A Single Pass <strong>and</strong> Many Possibilities................................16<br />

2.2.3 Deferred Shading – Multiple Passes for Multiple Lights......................................17<br />

2.2.4 Conclusion – Deferred Rendering Does the Job....................................................19<br />

2.3 Physics – Simulation or Feint.....................................................................................20<br />

2.3.1 Collision Detection <strong>and</strong> Collision Response.........................................................20<br />

2.3.2 Collisions Under Extreme Conditions...................................................................21<br />

3 Draft <strong>and</strong> Expectations – Assembler Bay....................................................23<br />

3.1 Story <strong>and</strong> Setting – A <strong>Game</strong> Concept is Born...........................................................23<br />

3.2 Presentation – The Look <strong>of</strong> a <strong>Game</strong>..........................................................................25<br />

3.2.1 Visual Features for Assembler Bay.......................................................................26<br />

3.2.2 Dynamic S<strong>of</strong>t Shadows – High Realism Through Shadows?...............................27<br />

3.2.3 Stencil Shadow Volumes – Pixel Perfect Hard Shadows......................................28<br />

3.2.4 Shadow Mapping – Simple, Compatible <strong>and</strong> Somewhat Blurry...........................29<br />

3.2.5 Ambient Occlusion – Realtime or Static ?............................................................30<br />

3.2.6 Additional Effects for an Unique Look.................................................................31<br />

3.3 <strong>Game</strong> Mechanics – Concepts for a <strong>3D</strong> <strong>Puzzle</strong> <strong>Game</strong>...............................................33<br />

IV


4 <strong>Implementation</strong>..............................................................................................36<br />

4.1 <strong>Game</strong> Engine – The Core for Assembler Bay...........................................................36<br />

4.1.1 Engine Structure – Organization is the key...........................................................36<br />

4.1.2 Smooth Skin Animation – Now It Can Walk!.......................................................39<br />

4.2 Physics Engine – Collisions <strong>and</strong> Reactions................................................................41<br />

4.2.1 Binary Space Partitioning – Divide <strong>and</strong> Conquer..................................................42<br />

4.2.2 Physics Calculations – Let It Bounce!...................................................................44<br />

4.2.3 Animated Objects – Neither Moving Nor Static...................................................46<br />

4.3 Deferred Shading – The Visual Part <strong>of</strong> QEE............................................................46<br />

4.3.1 Surface Formats – Compatibility <strong>and</strong> Storage.......................................................47<br />

4.3.2 Geometry-Buffer Attributes – Precision <strong>and</strong> Performance...................................48<br />

4.3.3 The Final G-Buffer Layout – Performance Takes the Lead..................................49<br />

4.3.4 <strong>Implementation</strong> <strong>of</strong> Deferred Lights.......................................................................50<br />

4.3.5 Stencil Buffer Light Volumes – Less Pixels More Performance..........................52<br />

4.4 Dynamic Shadows – Light Comes With Darkness...................................................53<br />

4.4.1 Shadow Map Aliasing – One Problem Many Answers.........................................54<br />

4.4.2 Variance Shadow Mapping – Smooth Shadows in Every Resolution...................57<br />

5 Achievement <strong>and</strong> Conclusion.......................................................................60<br />

5.1 Achievements <strong>and</strong> Tasks – Comparing Idea <strong>and</strong> Reality........................................60<br />

5.1.1 Primary Visual Features – Does it Look Good ?...................................................61<br />

5.1.2 Optional Graphics Effect – Does it Look Better ?.................................................63<br />

5.1.3 Open Source <strong>Game</strong> Engine – Is it Really Quick <strong>and</strong> Easy?..................................64<br />

5.2 Teamwork <strong>and</strong> Timetables – The Long Way <strong>of</strong> <strong>Game</strong> <strong>Design</strong>...............................65<br />

5.3 Comparison <strong>and</strong> Conclusion – Is it Really State <strong>of</strong> the Art?...................................66<br />

5.3.1 Dynamic S<strong>of</strong>t Shadows – Who is John Carmack?................................................66<br />

5.3.2 Colors <strong>and</strong> Atmosphere – It is Vivid, but is it Unique?.........................................68<br />

5.3.3 Conclusion – Not Perfect but Worth the Effort.....................................................68<br />

List <strong>of</strong> literature...............................................................................................70<br />

V


Table <strong>of</strong> Figures<br />

Figure 1.1: Bloom Effect <strong>and</strong> Ambiance in Prince <strong>of</strong> Persia: Warrior Within...........................6<br />

Figure 1.2: Unique Look <strong>of</strong> World <strong>of</strong> Warcraft..........................................................................6<br />

Figure 2.1: Part <strong>of</strong> a tile based level in Dune II........................................................................11<br />

Figure 2.2: Seamless world <strong>of</strong> Total Comm<strong>and</strong>er....................................................................11<br />

Figure 2.3: Visualization <strong>of</strong> 4 Preliminary Buffers used for Deferred Shading.......................18<br />

Figure 2.4: Screenshot <strong>of</strong> Killzone 2 showing capabilities <strong>of</strong> Deferred Shading.....................19<br />

Figure 3.1: Vivid Colors in Mirror's Edge................................................................................25<br />

Figure 3.2: Stencil Shadow Volumes in Doom 3, producing hard edges.................................28<br />

Figure 3.3: Shadow Map Aliasing (1024x1024 shadow maps) PCF only................................30<br />

Figure 3.4: Comparison <strong>of</strong> Overexposure <strong>and</strong> Normal Lighting in Assembler Bay................31<br />

Figure 3.5: Pre-Rendered Depth <strong>of</strong> Field <strong>and</strong> selective Bloom for Assembler Bay.................32<br />

Figure 3.6: Excerpt <strong>of</strong> a draft for the Assembler Bay manual..................................................34<br />

Figure 4.1: Class Diagram Showing the Basic Structure <strong>of</strong> the game engine..........................37<br />

Figure 4.2: Various Keyframes from a Jump Animation <strong>of</strong> the Main Character.....................39<br />

Figure 4.3: Quad-tree is redundant <strong>and</strong> very unbalanced when objects are grouped...............42<br />

Figure 4.4: Per Polygon Collision Detection Using Bounding Box Queries............................44<br />

Figure 4.5: Relevant Surface Formats for Direct X Hardware.................................................47<br />

Figure 4.6: Geometry-Buffer Configuration for QEE..............................................................49<br />

Figure 4.7: Using Light Volumes <strong>and</strong> the Stencil Buffer to Exclude Pixels............................53<br />

Figure 4.8: Shadow Map Alignment with Trapezoidal Shadow Maps.....................................56<br />

Figure 4.9: Fake Penumbra in Variance Shadow Mapping <strong>and</strong> Solutions...............................59<br />

Figure 5.1: Previews <strong>of</strong> additional Level <strong>Design</strong>s for future development..............................61<br />

Figure 5.2: Comparison <strong>of</strong> Shadow Mapping Filter Methods..................................................62<br />

Figure 5.3: Screenshot <strong>of</strong> Assembler Bay with active MSAA..................................................63<br />

Figure 5.4: Screenshot <strong>of</strong> a Physics Simulation in Assembler Bay..........................................65<br />

Figure 5.5: Close up Shadow Artifacts in Far Cry 2.................................................................67<br />

Figure 5.6: Magnified Shadow Details in Assembler Bay........................................................67<br />

Figure 5.7: Assembler Bay Logo..............................................................................................69<br />

VI


Introduction ::: Introduction 1<br />

1 Introduction<br />

The first chapter will provide a basic look into the distinctive features <strong>of</strong> computer<br />

games compared to other media. The motivation <strong>of</strong> the author <strong>and</strong> the goals <strong>of</strong> this project<br />

will be detailed in the first two sections. The third section will show concepts for<br />

the creation <strong>of</strong> an unique game, which will be used in the design process <strong>of</strong> this project.<br />

1.1 Motivation – We Want to Make a <strong>Game</strong>!<br />

Digital Entertainment S<strong>of</strong>tware (<strong>Game</strong>s) has been a growing phenomena ever since the<br />

first personal computers were available. But despite the first games being quite simple<br />

programs with just a few lines <strong>of</strong> code, developed by single computer scientists or small<br />

groups <strong>of</strong> them, current console or computer games play in a whole different league.<br />

State <strong>of</strong> the art titles (2008 / 2009) for the XBOX 360, PS 3 or modern Gaming PCs require<br />

some years <strong>of</strong> development, <strong>and</strong> teams with 30 programmers <strong>and</strong> at least as much<br />

designers are not uncommon 1 . But the wish to convert your very own ideas into a real<br />

game still remains <strong>and</strong> high quality st<strong>and</strong>ards just raise the expectations.<br />

Modern computer games open a field <strong>of</strong> creativity <strong>and</strong> freedom any other media<br />

can hardly achieve. Current graphics hardware allow a range <strong>of</strong> effects <strong>and</strong> highly detailed<br />

graphics, which can simulate nearly any environment thinkable. Nowadays real<br />

time graphics produce results not imaginable even in pre-rendered movies some years<br />

ago. Dynamic environments have the ability to immerse the user into a fantastic universe<br />

with its own rules. Realistic graphics are one <strong>of</strong> the main reasons the user accepts<br />

the fantastic reality presented to him. The second reason is the number <strong>of</strong> abilities <strong>of</strong> interactive<br />

story telling which lift the user from his audience position <strong>and</strong> take him into<br />

the middle <strong>of</strong> action. Virtual characters not only convince with their looks, but with<br />

their actions <strong>and</strong> reactions. Every action the user takes or does not take has a direct impact<br />

on the virtual reality surrounding him <strong>and</strong> the consequences his inactiveness entail,<br />

can persuade him to interact with the game.<br />

1 The development costs for a modern game can easily surpass 3 million dollars<br />

[http://news.bbc.co.uk/1/hi/technology/4442346.stm]


Introduction ::: Motivation – We Want to Make a <strong>Game</strong>! 2<br />

The motivation for this project was the ability to work in a team <strong>and</strong> produce a<br />

result not only for the records, but a game we could enjoy ourselves. We had a concept<br />

<strong>and</strong> many ideas at h<strong>and</strong>. We did not want to modify an existing game, or reuse any<br />

graphics, models or music, but intend to produce an original outcome. The incentive for<br />

this project is, to let an idea come true as a game.<br />

1.2 Task – State <strong>of</strong> the Art <strong>Game</strong> <strong>Design</strong><br />

The first, most important goal <strong>of</strong> this project was the design <strong>of</strong> a <strong>3D</strong> action game called<br />

“Assembler Bay”. The concept for Assembler Bay is depicted in detail in chapter 3. The<br />

game implemented in this project should be able to compare to current top titles for the<br />

XBOX 360, PlayStation 3 or the PC. Since the team for design <strong>and</strong> implementation <strong>of</strong><br />

this project consisted <strong>of</strong> only three members <strong>and</strong> the timespan available was as small as<br />

5 months from concept to implementation, the team members had to adapt their specifications<br />

to be adequate to their means. The task is the design <strong>of</strong> a game reaching the<br />

graphics quality <strong>of</strong> current top titles, utilizing the newest <strong>and</strong> most promising rendering<br />

techniques available. The final implementation shall include an original soundtrack<br />

composed for this game, as well as an unique look <strong>and</strong> story design.<br />

However the implementation <strong>of</strong> these high quality game assets would be very<br />

time intensive <strong>and</strong> it would be impossible to meet the quantitative requirements <strong>of</strong> modern<br />

games. A modern <strong>3D</strong> action game is expected to deliver several hours <strong>of</strong> gameplay,<br />

including a variety <strong>of</strong> levels <strong>and</strong> quests. Although it might have been possible for the<br />

team to produce this amount <strong>of</strong> assets, their quality would be severely worse as opposed<br />

to the design <strong>of</strong> a few high quality assets in the same time. The objective for this project<br />

was thus specified to scope at least the following features:<br />

The most important feature is one fully playable level, representing the stage for<br />

a tutorial, including all major gameplay elements for the final game. In addition to this<br />

at least two alternative stages are to be designed, as a foundation for future levels in the<br />

same environment. To preview the possible extensions to this game, the team will<br />

design concepts for two other realms with a design completely different from the three<br />

demo stages. At least one fully playable puzzle for the demo stage has to be designed<br />

<strong>and</strong> implemented, as well as the prototypes for at least two other types <strong>of</strong> puzzles. In addition<br />

to this the team will sketch at least two more puzzle drafts, to give an outlook to<br />

the possibilities <strong>of</strong> game elements in the final game.<br />

These are the objectives for this project, concerning its deadline as a final paper<br />

for the Bachelor degree <strong>of</strong> the author. But furthermore the whole team is convinced to<br />

lead this project to a final game. After graduation, the team will go on to implement the<br />

features canceled in the concept phase due to time limitations. The game will also be<br />

tested <strong>and</strong> if possible released on an online gaming platform.


Introduction ::: Planning a <strong>Game</strong> – From Concept to <strong>Implementation</strong> 3<br />

1.3 Planning a <strong>Game</strong> – From Concept to <strong>Implementation</strong><br />

The next step, after outlining the objective <strong>of</strong> this project is the design <strong>of</strong> a timing<br />

schedule for the whole venture from concept to implementation. But prior to the set up<br />

<strong>of</strong> this schedule, a review <strong>of</strong> the preconditions <strong>and</strong> available resources is inevitable. The<br />

first step was the decision for a framework, followed by the main design decision, if an<br />

already available game engine would be used <strong>and</strong> extended, or if a complete game engine<br />

was to be implemented from scratch.<br />

A game meeting the conditions set in the last section can be implemented in<br />

various programming languages <strong>and</strong> frameworks. The two main branches <strong>of</strong> computer<br />

languages suited for game design are object-oriented languages with fully managed<br />

code, or procedural programming languages. PPLs 2 usually deliver higher performance<br />

than OOPLs 3 , resulting from less type casting <strong>and</strong> a more direct access to hardware resources.<br />

In contrast to this OOPLs spend many resources on resource management <strong>and</strong><br />

type save programming. But this usually results in safer code, as the exception h<strong>and</strong>ling<br />

<strong>of</strong> an OOPL will usually h<strong>and</strong>le all occurring errors. Another benefit <strong>of</strong> OOPLs is the<br />

modularity <strong>and</strong> clear structure resulting from a clean object hierarchy. Since object oriented<br />

design is the preferred method, wherever the available performance allows for<br />

managed code, the author prefers this approach.<br />

The bottleneck for performance <strong>of</strong> modern games, is usually the speed <strong>and</strong> abilities<br />

<strong>of</strong> the graphics adapter or the size <strong>of</strong> available main memory. This results in a<br />

wider use <strong>of</strong> object oriented languages for game engines. Another factor in the decision<br />

for a framework was the motivation to make the game available for a console, preferably<br />

the Micros<strong>of</strong>t XBOX 360. The XNA framework by Micros<strong>of</strong>t is based on C# <strong>and</strong><br />

provides the ability to design games which are supported by PC <strong>and</strong> XBOX 360. In addition<br />

to this benefits, the author already has programming experience with XNA being an<br />

excellent tool for object oriented game design using Micros<strong>of</strong>t Direct X 9. These facts<br />

results in the decision to use XNA as the underlying framework for Assembler Bay.<br />

2 PPL st<strong>and</strong>s for Procedural Programming Language<br />

3 OOPL st<strong>and</strong>s for Object Oriented Programming Language


Introduction ::: Planning a <strong>Game</strong> – From Concept to <strong>Implementation</strong> 4<br />

A potential game engine for Assembler Bay should satisfy the following conditions:<br />

• The game engine has to be open source <strong>and</strong> free <strong>of</strong> any licensing obligations,<br />

because the team wants to hold all rights on the final<br />

product resulting from this project.<br />

• The second requirement is high flexibility <strong>and</strong> modularity, so the engine<br />

can be adapted to the special requirements <strong>of</strong> this game.<br />

• A potential game engine has to provide an adequate period <strong>of</strong> adaption,<br />

in comparison to the features it provides.<br />

• The required features <strong>of</strong> a <strong>3D</strong> game engine are detailed in section 2.1<br />

After thorough research about XNA <strong>and</strong> available <strong>3D</strong> game engines the author decided<br />

that there is no engine available fulfilling the depicted requirements. Most open source<br />

game engines are specialized on a single component, like a highly sophisticated physics<br />

engine, but lack at various other essential features. The time required to familiarize with<br />

an engine <strong>and</strong> rewrite the parts, which are not suited for the needs <strong>of</strong> this project, would<br />

most likely be comparable to the time needed to design a new game engine from<br />

scratch. This leads to the second main objective <strong>of</strong> this project: To design a reusable,<br />

flexible <strong>and</strong> modular <strong>3D</strong> game engine with XNA.<br />

After the decision for a framework <strong>and</strong> the implementation <strong>of</strong> a new game engine<br />

had been taken, a timing schedule was outlined. The corner points <strong>of</strong> this schedule<br />

were a concept phase, followed by a segment to set up the design for all engine components,<br />

calculated for the first 15% <strong>of</strong> the schedule. The main phase <strong>of</strong> the project was<br />

the implementation <strong>of</strong> the game engine, planned to take about 60% <strong>of</strong> the whole project<br />

time. After implementation, the specialization for the game was assigned 15% <strong>of</strong> the<br />

overall time, leaving the last 10% for testing <strong>and</strong> evaluation. Although the evaluation<br />

time was designed very short, evaluation <strong>of</strong> the game engine was included in the implementation<br />

part <strong>and</strong> the last step was only evaluation <strong>of</strong> the features original to the game.


Introduction ::: Make it Different – Characteristics <strong>of</strong> a Unique <strong>Game</strong> 5<br />

1.4 Make it Different – Characteristics <strong>of</strong> a Unique <strong>Game</strong><br />

A total <strong>of</strong> about 200 4 commercial computer games was published in 2008, most being in<br />

the traditional genres <strong>of</strong> sport, shooters, RPG 5 or strategy. Although many games with<br />

refreshing <strong>and</strong> unique gameplay mechanics were developed, the best sold <strong>and</strong> most discussed<br />

games were traditional games 6 using newest technologies. This clarifies that in<br />

most cases a visually stunning presentation is much more important for the acceptance<br />

<strong>of</strong> a game than original gameplay elements. The rare occasion <strong>of</strong> a visually deprecated<br />

game with an original concept becoming popular are games based on freeware games,<br />

which became popular beforeh<strong>and</strong>. An example for this phenomena is World <strong>of</strong> Goo.<br />

But the downside <strong>of</strong> many praised high end graphics games is the lack <strong>of</strong> an unique<br />

gameplay. Many modern games come without any new ideas, still making sales with<br />

their visual presentation. This leads to more <strong>and</strong> more sequels <strong>of</strong> popular games <strong>and</strong> a<br />

decreasing number <strong>of</strong> original games with a high budget 7 . Hence the goal for this project<br />

is a game which is both visually stunning <strong>and</strong> original in its gameplay.<br />

The difficult part in designing an original game is to make it unique enough to<br />

st<strong>and</strong> out, but still keep enough st<strong>and</strong>ards, so the user can easily adapt to the new game<br />

mechanics. Although unique gameplay is the main attribute <strong>of</strong> an original game, the<br />

first step towards it is an original look. This can include an outst<strong>and</strong>ing character or<br />

level design, but mostly an unique atmosphere. A game has an unique look, if the user<br />

can immediately distinct any <strong>of</strong> its scenes from other games. This can be achieved by<br />

special effects, such as a certain colored tinting <strong>of</strong> the whole scene like in Prince <strong>of</strong><br />

Persia: The Warrior Within. (see Figure 1.1 8 )<br />

The whole game is covered by a s<strong>and</strong> colored bloom effect, which makes the<br />

series st<strong>and</strong> visually out in contrast to other games. An other method to achieve a unique<br />

look can be an original style <strong>of</strong> characters <strong>and</strong> levels like it is used in World <strong>of</strong> Warcraft.<br />

The whole game has a very colorful <strong>and</strong> comic-style look, but without the use <strong>of</strong> cell<br />

shading or similar effects. The characters are designed to be very striking <strong>and</strong> burlesque.<br />

Although the whole HUD 9 has been copied by many other online RPGs, screenshots <strong>of</strong><br />

World <strong>of</strong> Warcraft are still distinctive in their looks. (see Figure 1.2 10 )<br />

4 Source: [ http://www.gamestar.de/ ]<br />

5 Role Play <strong>Game</strong><br />

6 Traditional refers to games using frequently used <strong>and</strong> long established game mechanics<br />

7 Source: [ http://www.nytimes.com/2005/08/08/technology/08game.html ]<br />

8 Cutout screenshot from [http://uk.media.pc.ign.com/media/672/672283/imgs_5.html]<br />

9 Head Up Display – An acronym adopted from the air force, meaning the informations projected right<br />

into the vision <strong>of</strong> the pilot. In games it refers to any information displayed on the screen as an overlay<br />

independent <strong>of</strong> the direction the camera pinpoints<br />

10 Cutout screenshot from [http://www.markeedragon.com/]


Introduction ::: Make it Different – Characteristics <strong>of</strong> a Unique <strong>Game</strong> 6<br />

Figure 1.1: Bloom Effect <strong>and</strong> Ambiance in Prince <strong>of</strong> Persia: Warrior Within<br />

Figure 1.2: Unique Look <strong>of</strong> World <strong>of</strong> Warcraft<br />

This being said the most significant feature <strong>of</strong> an original game is an original gameplay<br />

concept. <strong>Game</strong>play is a term used to merge the game mechanics, controls <strong>and</strong> main<br />

story elements in a single concept <strong>of</strong> the way it feels to play the game. Presenting the<br />

user with an unprecedented gameplay is the goal <strong>of</strong> an unique game. But confronting<br />

the user with too complex game mechanics, or game rules he does not underst<strong>and</strong> has to<br />

be avoided. One way to achieve this, is to combine a familiar environment utilizing<br />

common controls with new game mechanics. An unique game, which is easy to underst<strong>and</strong><br />

<strong>and</strong> provides easy access to original game mechanics, this is what Assembler Bay<br />

should finally incorporate.


Engine <strong>Design</strong> ::: Engine <strong>Design</strong> 7<br />

2 Engine <strong>Design</strong><br />

The first section <strong>of</strong> this chapter will provide a short outline about the history <strong>and</strong> benefits<br />

<strong>of</strong> game engines <strong>and</strong> introduce the problems a game engine addresses. Following<br />

this overview <strong>of</strong> features is a concept for the structure <strong>of</strong> a puzzle game engine.<br />

The second section will depict features the graphics component <strong>of</strong> a game engine<br />

has to <strong>of</strong>fer <strong>and</strong> subsequent compare the two major approaches to rendering. Where<br />

Deferred Rendering is chosen as the preferred technology for this project.<br />

The third section will explain the tasks a physics engine has to address. These<br />

tasks are divided into Collision Detection <strong>and</strong> Collision Response. Various methods to<br />

deal with both are mentioned <strong>and</strong> the different requirements <strong>of</strong> realistic simulations <strong>and</strong><br />

action games is explained.<br />

2.1 Structure – Duties <strong>of</strong> a <strong>Game</strong> Engine<br />

The first digital games in history did not need any game engine. In fact the first games<br />

did not even need any s<strong>of</strong>tware, referring to PONG 11 , which was first implemented<br />

solely in hardware. But as soon as the first Amiga personal computers arose early lines<br />

<strong>of</strong> gaming code were being written in machine language (ref. [BET03]). Following<br />

these assembler coded games the era <strong>of</strong> computer games really arose with s<strong>of</strong>tware development<br />

in higher computer languages. But even then games were written just line by<br />

line <strong>and</strong> the only kind <strong>of</strong> reusable code were I/O loops for keyboard or graphics. The<br />

first famous <strong>and</strong> highly reused game engine was probably the SCUMM 12 -Interpreter<br />

written by Lucas Arts in 1987 which was a virtual machine ported to various available<br />

platforms. Instead <strong>of</strong> writing games line by line from scratch for each platform, new<br />

point <strong>and</strong> click adventures could be written in a unified scripting language, which was<br />

interpreted by the SCUMM-Interpreter, which managed Input, Sound <strong>and</strong> Graphics on<br />

the target platform. But apart from this most games were still one hard coded program<br />

without any modular components, most due to hardware limitations.<br />

11 PONG is a video game published 1972 by Atari [ http://www.atarimuseum.com/ ]<br />

12 Script Creation Utility for Maniac Mansion developed by LucasArts [ http://www.lucasarts.com/ ]


Engine <strong>Design</strong> ::: Structure – Duties <strong>of</strong> a <strong>Game</strong> Engine 8<br />

2.1.1 Basic Structure <strong>of</strong> a <strong>3D</strong> <strong>Game</strong> Engine<br />

The core <strong>of</strong> every modern <strong>3D</strong> computer game is the game engine. The basic idea in creating<br />

a game engine is separating the reusable components from parts unique to one particular<br />

game. Reusable components <strong>of</strong> a first person shooter would be methods calculating<br />

physic reactions or processing input by keyboard <strong>and</strong> mouse. Unique components<br />

are pictures, like a splash screen, or the level data, textures <strong>and</strong> sounds. By convention<br />

all materials in a game, which are not implemented into the game code itself, but rather<br />

read from external files or imported on runtime are called assets (ref. [BET03]). The<br />

most common game assets are textures, geometry data, sounds <strong>and</strong> configuration files.<br />

The remaining unique parts <strong>of</strong> a game are methods or classes which are modified for<br />

this particular game, or completely new functions which are not common in similar<br />

games. There is a range <strong>of</strong> benefits in breaking up this three parts, including reusability<br />

<strong>of</strong> the game engine for similar games or whole assets for sequels or add-ons. Modern<br />

game engines are so complex <strong>and</strong> highly sophisticated, they created their own market.<br />

Some game companies make higher acquisition selling their engines than selling their<br />

games. Even parts <strong>of</strong> a game engine can be pr<strong>of</strong>itable enough for a whole company, like<br />

HAVOK 13 or SpeedTree 14 demonstrate.<br />

A game engine should provide the following features (ref. [MIC06]):<br />

• Graphics 15<br />

• Physics 16<br />

• Artificial intelligence<br />

• Input h<strong>and</strong>ling<br />

• Content import<br />

• Content management<br />

• <strong>Game</strong> screen management<br />

• Scene administration<br />

• Customization options<br />

• Hardware compatibility<br />

13 HAVOK is an Irish s<strong>of</strong>tware Company who's main product is a physics engine used in various<br />

games [ http://www.havok.com/ ]<br />

14 SpeedTree is a s<strong>of</strong>tware package produced by IDV with the sole purpose <strong>of</strong> generating realistic <strong>3D</strong><br />

trees in games [ http://www.speedtree.com/ ]<br />

15 The graphics component <strong>of</strong> the game engine will be explained in in detail in section 2.2<br />

16 The physics component will be explained in detail in section 2.3


Engine <strong>Design</strong> ::: Structure – Duties <strong>of</strong> a <strong>Game</strong> Engine 9<br />

2.1.2 Why a Physics Engine is Required in Modern <strong>Game</strong>s<br />

A pr<strong>of</strong>essional game engine has to provide modular <strong>and</strong> flexible solutions for each <strong>of</strong><br />

the addressed problems. While graphics quality is the most remarkable feature <strong>of</strong> a <strong>3D</strong><br />

engine, it is really just one aspect <strong>of</strong> many. But the first impression is always a visual<br />

one <strong>and</strong> graphics quality is still the first <strong>and</strong> most discussed topic in <strong>3D</strong> gaming. Next<br />

generation consoles 17 , modern graphic adapters <strong>and</strong> multi core CPUs 18 have paved the<br />

way for visually stunning games, which set the st<strong>and</strong>ards high for nowadays game developers.<br />

While top titles in 2004 19 were the first to present a convincing <strong>3D</strong> physics engine<br />

<strong>and</strong> some even made it a core element <strong>of</strong> their game, current action titles are expected<br />

to have a strong physics engine. Even if the simulation <strong>of</strong> realistic physics only play<br />

a marginal role in gameplay the user will be easily dissatisfied with the game experience<br />

if objects in the game do not behave physically correct (ref. [EBE04]).<br />

An example is a visually stunning game set in a tropical forest, the light<br />

only shimmers through the leaves in dark greens. The sound effects <strong>of</strong><br />

birds <strong>and</strong> distant howls add up to the atmosphere <strong>and</strong> have the user completely<br />

immersed in this virtual jungle. The user sights a clearance just<br />

some steps ahead <strong>and</strong> sets into motion. But he keeps walking on the spot<br />

not moving an inch, because a little twig one inch above the ground<br />

blocks his way. He tries to jump, but just can not pass the little twig, because<br />

this way was just not designed to be passed. The user will immediately<br />

be teared out <strong>of</strong> the fantastic story <strong>and</strong> complain about the stupid<br />

game not letting him do what should be physically possible. Or maybe he<br />

even carries some kind <strong>of</strong> weapon which can not harm the twig in any<br />

way, because the game was designed to only attack enemies with these<br />

weapons.<br />

To create a storyline <strong>and</strong> game experience really captivating the user is difficult to<br />

achieve, but even just a little glitch in physics calculations can easily destroy this atmosphere.<br />

17 The consoles: Micros<strong>of</strong>t XBOX 360, Nintendo Wii <strong>and</strong> Sony PlayStation 3 are referred to as “Next<br />

generation consoles” or “NextGen consoles”<br />

18 CPU meaning Central Processing Unit, will in the scope <strong>of</strong> this dissertation always refer to the main<br />

processing unit in a personal computer<br />

19 Top titles 2004 refers to top-rated games released for the PC in 2004, based on ratings <strong>of</strong> international<br />

gaming magazines [ http://www.gamerankings.com/ ] including Half-Life 2, Unreal Tournament<br />

2004, Rome: Total War, Doom 3, Far Cry, Warhammer 40,000: Dawn <strong>of</strong> War, Counter-Strike: Condition<br />

Zero


Engine <strong>Design</strong> ::: Structure – Duties <strong>of</strong> a <strong>Game</strong> Engine 10<br />

2.1.3 Artificial Intelligence in Modern <strong>Game</strong>s<br />

Virtually <strong>of</strong> equal importance in modern games is a good AI 20 , because just as bad as a<br />

barrel hanging in midair <strong>and</strong> making unexpected noises is an enemy running circles instead<br />

<strong>of</strong> attacking, or a strategy game where an unit just can not find a way to the location<br />

it should move to. The AI <strong>of</strong> a <strong>3D</strong> game has many tasks to coordinate <strong>and</strong> decisions<br />

to take. The most sophisticated AI nowadays can be found in strategy games, where the<br />

user can choose to play against the computer <strong>and</strong> wants to be challenged. Although current<br />

computers have finally caught up to the best international chess players <strong>and</strong> even<br />

home computers can beat most chess amateurs utilizing shortest thinking times, the requirements<br />

<strong>of</strong> an AI in a real time strategy game lie on a whole different level 21 .<br />

One basic difference is available calculation time <strong>and</strong> power 22 in realtime applications.<br />

While a turn based chess game poses very small load on the running system if<br />

two players play against each other, a modern real time strategy game might already be<br />

short on calculation power even if there is no strategy AI active at all. The hardware is<br />

already busy calculating physics, graphics effects, path finding <strong>and</strong> game mechanics.<br />

This leaves only small amount <strong>of</strong> calculation time for a strategic AI facing an amount <strong>of</strong><br />

possible turns far outweighing any board game on the planet. This is the second major<br />

difference between classic board games <strong>and</strong> digital strategy games – the amount <strong>of</strong> rules<br />

<strong>and</strong> possibilities. A board game has always a very limited number <strong>of</strong> positions where a<br />

unit can st<strong>and</strong>. There are (8x8) 64 fields in classic chess <strong>and</strong> even the Japanese Go 23 as<br />

one <strong>of</strong> the biggest board games has only (19x19) 361 possible positions for a token. In<br />

contrast to this even one <strong>of</strong> the oldest digital strategy games like Dune II 24 already had a<br />

game field about ten times as big <strong>and</strong> a variety <strong>of</strong> different units (see Figure 2.1 25 ). And<br />

many modern strategy games play on seemingly undivided game fields where a unit's<br />

position is not limited to a certain grid <strong>of</strong> positions, but saved in a floating point variable<br />

with high precision. Total Comm<strong>and</strong>er Is most likely the real time strategy game with<br />

the biggest seamless levels <strong>and</strong> most units on the battlefield <strong>and</strong> a good example how<br />

the complexity <strong>of</strong> real time strategy games evolved (see Figure 2.2).<br />

20 Artificial Intelligence, meaning the ability <strong>of</strong> computer games to perform seemingly intelligent tasks<br />

(like path finding or reacting like a human)<br />

21 The Chess Computer Deep Blue beats most chess players [ http://www.research.ibm.com/deepblue ]<br />

22 Calculation power refers to the CPU-load a certain task can occupy, equivalent to the number <strong>of</strong> CPU<br />

cycles used by this task<br />

23 Go is a Japanese strategy game played on a field with 19 horizontal <strong>and</strong> 19 vertical lines making up<br />

361 crossings where tokens can be placed<br />

24 Dune II was released 1992 for DOS developed by Westwood Studios. It was one <strong>of</strong> the first games<br />

comparable to modern strategy games utilizing economy, tactic <strong>and</strong> strategic warfare in realtime<br />

25 Screenshot found on [http://www.mobygames.com/]


Engine <strong>Design</strong> ::: Structure – Duties <strong>of</strong> a <strong>Game</strong> Engine 11<br />

Figure 2.1: Part <strong>of</strong> a tile based level in Dune II Figure 2.2: Seamless world <strong>of</strong> Total Comm<strong>and</strong>er<br />

The AI in first person shooters is not less dem<strong>and</strong>ing, because many modern shooters<br />

aim for high realism. High realism includes the enemies being human in most games<br />

<strong>and</strong> the player expects them to act like human beings <strong>and</strong> not like brainless monsters.<br />

This implies not only good path finding <strong>and</strong> fighting with tactics, but also acting based<br />

on emotions <strong>and</strong> character, for example enemies fleeing if they do not have any chance<br />

<strong>of</strong> winning (ref. [SUP07]). However this also means the level <strong>of</strong> AI required highly depends<br />

on the particular game being planned. <strong>Game</strong>s with computer controlled enemies<br />

or friends which represent intelligent beings (like humans) need to be equipped with a<br />

highly capable AI, controlling their movements <strong>and</strong> even communication with the player.<br />

Contrary games without intelligent entities besides the player need little to no AI at<br />

all. Examples for this are multiplayer-only first person shooters without computer controlled<br />

players. In this case state <strong>of</strong> the art graphics <strong>and</strong> a good physics engine are expected,<br />

but no AI is required at all, because all acting entities in the game are controlled<br />

by users. Another example are arcade or puzzle games without acting adversaries.<br />

The concept for Assembler Bay is a puzzle game 26 , which implies little to no AI<br />

will be required in the final game. This leads to the design decision an AI component<br />

will not be included in the primary engine structure.<br />

2.1.4 Input H<strong>and</strong>ling for <strong>3D</strong> <strong>Game</strong>s<br />

Input h<strong>and</strong>ling is another important component, which distributes a great part to the<br />

game experience. How a game feels, meaning how the virtual character <strong>and</strong> the environment<br />

react to the player is one <strong>of</strong> the most important points in the audiovisual experience<br />

called gameplay. The challenge <strong>of</strong> a good input component in <strong>3D</strong> action games is<br />

to let the virtual character act according to what the user wants him to do, as fast as possible.<br />

Too complex or unintuitive input controls can easily frustrate the user <strong>and</strong> lead to<br />

26 The concept <strong>and</strong> planning <strong>of</strong> Assembler Bay will be detailed in section 3.1


Engine <strong>Design</strong> ::: Structure – Duties <strong>of</strong> a <strong>Game</strong> Engine 12<br />

a high difficulty. Challenges resulting from unintuitive controls or long input latency<br />

will in most cases be a severe design failure. Even though there are some games using<br />

purposely counterintuitive controls as part <strong>of</strong> their gameplay, most other games try to<br />

avoid any difficulty resulting from the user not knowing certain controls. Some representatives<br />

<strong>of</strong> counterintuitive controls are fighting games 27 for consoles, providing a high<br />

challenge for the user in learning complex button combinations.<br />

Another design decision is the choice <strong>of</strong> input hardware. Apart from highly specialized<br />

input components like steering wheels, drum pads, guitars, rifle imitations <strong>and</strong><br />

data gloves the main input components for modern games are gamepad, keyboard <strong>and</strong><br />

mouse. Habit is the most important factor to obey in input design because most users do<br />

not want to learn new complex controls, but rather play the game with the controls they<br />

are used to. This fact can be witnessed as almost every game ported by a console to the<br />

PC or vice versa adapts to the common controls <strong>and</strong> input devices <strong>of</strong> the target platform.<br />

The easiest way to take on this problem is to support a wide spectrum <strong>of</strong> different input<br />

devices, as well as customization options for the user. None the less many games are restricted<br />

to certain input devices <strong>and</strong> even have certain unchangeable button assignments<br />

28 . Although full support <strong>of</strong> any input device or configuration should always be<br />

preferred, it is easier <strong>and</strong> more straightforward to accept certain constrains in the available<br />

configuration options. Certain control st<strong>and</strong>ards have been evolved over the last<br />

decade in popular genres such as first person shooters, racing simulations or real time<br />

strategy games (ref. [BOW06]). An example is the use <strong>of</strong> a mouse in first person shooters<br />

on the PC. Although the mouse movements could also be used to move the character<br />

around in the level or to open certain menus, almost every FPS 29 on the PC predefines<br />

the mouse to control the view direction <strong>of</strong> the character. Available configuration options<br />

may include mouse sensitivity, mirroring <strong>of</strong> the mouse y-axis or mouse acceleration <strong>and</strong><br />

frequently the mouse buttons can be assigned any function. But the mouse movements<br />

are fixed to control the view direction.<br />

The concept <strong>of</strong> Assembler Bay includes two target platforms, the PC <strong>and</strong> the<br />

XBOX 360. Subsequently the input component <strong>of</strong> the underlying game engine has to<br />

support the native input devices <strong>of</strong> both platforms. These are the XBOX 360 <strong>Game</strong>pad<br />

for the console <strong>and</strong> mouse <strong>and</strong> keyboard for the PC. Although the PC also supports a<br />

range <strong>of</strong> various gamepads <strong>and</strong> joysticks, support for these requires a high level <strong>of</strong> hardware<br />

compatibility <strong>and</strong> is optional, since most users on a PC use only the available input<br />

devices mouse <strong>and</strong> keyboard. Since Assembler Bay will be a <strong>3D</strong> action puzzle game introducing<br />

new gameplay elements 30 which can not be found in major genres, there are<br />

no established control st<strong>and</strong>ards to adapt. Hence the input system will be fully customizable<br />

<strong>and</strong> user tests will determine an intuitive st<strong>and</strong>ard configuration.<br />

27 Fighting games, also called “beat 'em up” are games where players have to fight each other in close<br />

combat, usually only one on one in a close up side view<br />

28 In many games functional keys like a pause or menu button or the escape key are not changeable<br />

29 FPS is used as an abbreviation for First Person Shooter in the scope <strong>of</strong> this dissertation<br />

30 The gameplay elements <strong>and</strong> design decisions for Assembler Bay will be depicted in section 3.1


Engine <strong>Design</strong> ::: Structure – Duties <strong>of</strong> a <strong>Game</strong> Engine 13<br />

2.1.5 Content Management <strong>and</strong> Content Processing<br />

Content management is a problem only barely recognized by the user in the form <strong>of</strong><br />

loading times <strong>and</strong> the size <strong>of</strong> a game installation. But a game engine has to administrate<br />

a whole database <strong>of</strong> game assets like sounds, textures 31 , level data, <strong>3D</strong> objects <strong>and</strong> lighting<br />

information. Whereas a game with small levels using only a few textures <strong>and</strong> sounds<br />

can just load all assets for the whole level into memory 32 , a game with huge outdoor<br />

levels or many detailed textures can easily overflow memory trying to load all assets at<br />

once. <strong>Game</strong>s with huge outdoor levels usually separate their levels into tiles. If the player<br />

moves close to a certain tile, all assets in this tile are loaded into memory <strong>and</strong> assets<br />

<strong>of</strong> tiles out <strong>of</strong> range for the player are discarded. If the content manager is designed well<br />

<strong>and</strong> the hardware has enough power, the loading <strong>of</strong> new tiles can be done in background<br />

without the user even noticing (ref [BET03]). But the concept for Assembler Bay uses<br />

small indoor levels requiring only content management between levels.<br />

Content processing is also part <strong>of</strong> a game engine, because the game assets are<br />

usually created in arbitrary formats, which differ from the internal format the game engine<br />

uses for assets. The two possibilities to h<strong>and</strong>le content import are at build time, or<br />

at runtime. If the content processing is done at build time, all assets (e.g. textures in<br />

JPEG format) are converted into an internal game engine format <strong>and</strong> saved using serialization.<br />

The advantage <strong>of</strong> this is shortened loading time, resulting from less content processing<br />

at runtime. But on the other h<strong>and</strong> all content for the game needs to be converted<br />

using the build time converter <strong>of</strong> the engine, which is usually not included in the final<br />

release. In this case users are unable to add their own content into the game without prior<br />

access to the content processor. Runtime content processing can easily import any<br />

content provided by the user, but requires analysis <strong>and</strong> processing <strong>of</strong> any content loaded<br />

at runtime. Most games use build time content processing for all available assets, but<br />

still provide runtime content import for individual assets by the user (like his own pictures<br />

as an ingame logo)<br />

2.1.6 <strong>Game</strong> Screen Management <strong>and</strong> Scene Administration<br />

<strong>Game</strong> screen management is a component designated to menu navigation, it h<strong>and</strong>les the<br />

various game states commonly beginning with a start screen being followed by the main<br />

menu. The game screen management component has to ensure the content manager<br />

loads <strong>and</strong> disposes all assets for a certain screen at the right time. Decisions about which<br />

screens are updated <strong>and</strong> displayed on various events are also part <strong>of</strong> game screen management,<br />

which is the fundamental component <strong>of</strong> a game engine structure.<br />

Scene administration is a topic getting more crucial as scenes in <strong>3D</strong> games become<br />

more complex. A scene in a <strong>3D</strong> game is the virtual space enclosing the entirety <strong>of</strong><br />

all loaded objects at a moment in time. It includes not only visible or movable objects in<br />

31 Textures meaning 2D or <strong>3D</strong> bitmap textures (including sprites, normal maps, diffuse textures...)<br />

32 Memory refers to PC main memory <strong>and</strong> memory <strong>of</strong> the graphics adapter


Engine <strong>Design</strong> ::: Structure – Duties <strong>of</strong> a <strong>Game</strong> Engine 14<br />

a level, but also the level architecture itself, all players or other characters, lights <strong>and</strong><br />

cameras 33 . This implies a scene in a <strong>3D</strong> game is very dynamic, as many objects including<br />

the characters can move around <strong>and</strong> new objects or characters can be instanced or<br />

removed any time. The scene administration component keeps track <strong>of</strong> all these objects<br />

<strong>and</strong> removes them if they are no longer needed, or their lifetime expired. The component<br />

also keeps track <strong>of</strong> the positions <strong>and</strong> relations <strong>of</strong> the objects to each other. A good<br />

scene administration can have a grave impact on graphics performance using a scene<br />

graph for early frustum culling 34 <strong>and</strong> is m<strong>and</strong>atory for a high performance physics engine<br />

35 .<br />

2.1.7 Hardware Compatibility<br />

The goal <strong>of</strong> the game engine for Assembler Bay is to be a reusable engine for many projects,<br />

but a level <strong>of</strong> hardware compatibility pr<strong>of</strong>essional modern PC games <strong>of</strong>fer can not<br />

be achieved in the scope <strong>of</strong> this project. This does not affect the target platform XBOX<br />

360, since the engine will be designed to work with the special requirements <strong>of</strong> this console.<br />

But to give an exhaustive compatibility to PC hardware or even operating systems<br />

would require multiple implementations <strong>of</strong> many parts <strong>of</strong> the engine. A pr<strong>of</strong>essional<br />

commercial engine is expected to run on virtually any system on the market having at<br />

least the calculation power to display the game at an adequate frame rate. The game engine<br />

developed in this project will try to maintain compatibility with many hardware<br />

configurations, but it will most likely only support a certain subset <strong>of</strong> operating systems<br />

<strong>and</strong> modern hardware.<br />

2.2 Graphics – Rendering Techniques <strong>and</strong> Lighting<br />

As depicted in the last section the graphics component is the most important component<br />

<strong>of</strong> a <strong>3D</strong> game engine. The render pipeline is the central part <strong>of</strong> <strong>3D</strong> visualization <strong>and</strong><br />

combines several steps to create the final image. The first step is always raw <strong>3D</strong> position<br />

data consisting <strong>of</strong> a list <strong>of</strong> <strong>3D</strong> vectors representing points in <strong>3D</strong> space <strong>and</strong> an index<br />

buffer 36 containing the relations <strong>of</strong> these points. These buffers are created by the content<br />

importer from a <strong>3D</strong> model file. The points representing the model are multiplied with<br />

matrices to transform them according to the absolute position <strong>of</strong> the model in the virtual<br />

world <strong>of</strong> the game <strong>and</strong> then multiplied by view <strong>and</strong> projection matrices generated by a<br />

virtual viewport 37 to project the points on the screen. After being projected, the points<br />

33 Cameras refer to the viewpoint by which the scene can be rendered<br />

34 Frustum culling is a rendering technique to omit objects which can not be seen by the camera<br />

35 A high-performance physics engine uses <strong>3D</strong> space partitioning techniques to find objects which can<br />

correlate <strong>and</strong> omit objects which can not influence each other at this point in time<br />

36 The index buffer contains information about which points in the position buffer make up a polygon,<br />

one point can be part <strong>of</strong> multiple polygons<br />

37 The virtual viewport is the virtual representation <strong>of</strong> a camera, based on a View <strong>and</strong> Projection matrix


Engine <strong>Design</strong> ::: Graphics – Rendering Techniques <strong>and</strong> Lighting 15<br />

represent 2D coordinates on the screen, where the points are connected to triangles using<br />

the index buffer data <strong>and</strong> these triangles are filled with the colors calculated from<br />

textures <strong>and</strong> lighting (ref. [MIC06]). Most <strong>of</strong> this calculations is done on the GPU 38 relieving<br />

the CPU for physics <strong>and</strong> AI calculations.<br />

2.2.1 Transform <strong>and</strong> Lighting – Rendering Techniques<br />

T&L 39 was the first attempt to source out <strong>3D</strong> calculations to the graphic adapter <strong>and</strong> has<br />

evolved to Vertex <strong>and</strong> Pixel Shader 3.0, supported by the newest generation <strong>of</strong> graphic<br />

adapters. Vertex Shader process the points <strong>and</strong> texture coordinates <strong>of</strong> a model <strong>and</strong> can<br />

manipulate them, before they are sent to the Pixel Shader. Pixel Shader process each<br />

pixel drawn by a polygon <strong>and</strong> can manipulate the final color. Together with modern rendering<br />

techniques shader allow games to have a unique look by using specific lighting<br />

calculations.<br />

Prior to each rendering technique certain culling <strong>and</strong> sorting algorithms may be<br />

applied to the scene to sort out irrelevant parts <strong>of</strong> the geometry 40 . One very basic technique<br />

<strong>of</strong> these is view frustum culling based on bounding volumes 41 . In a complex scene<br />

many parts are not visible in the viewport image, because they are either behind the<br />

camera, outside <strong>of</strong> the view angle, or too far away 42 . Processing the geometry <strong>of</strong> these<br />

objects in the rendering call would be wasted effort, because they will not be visible in<br />

the final image. The camera view frustum can be represented by a geometric volume<br />

<strong>and</strong> intersection tests <strong>of</strong> the bounding spheres <strong>of</strong> objects in the scene can decide if the<br />

objects can be visible in the final scene.<br />

Traditional Forward Rendering consists <strong>of</strong> a single rendering pass, where the<br />

polygons <strong>of</strong> all objects visible are drawn <strong>and</strong> the vertex <strong>and</strong> pixel shader compute lighting<br />

<strong>and</strong> other surface effects. But moder graphic hardware has made a different rendering<br />

approach possible. Deferred Rendering is a technique which has just recently become<br />

interesting, because <strong>of</strong> the possibilities <strong>of</strong> modern graphics adapters <strong>and</strong> the growing<br />

complexity <strong>of</strong> scenes in modern <strong>3D</strong> games. The following subsections will first introduce<br />

traditional Forward Rendering <strong>and</strong> depict some <strong>of</strong> its benefits <strong>and</strong> drawbacks.<br />

Afterwards Deferred Rendering will be explained <strong>and</strong> compared to Forward Rendering,<br />

concluding in the decision for the rendering technique used in this project.<br />

38 GPU means Graphics Processing Unit, in contrast to the CPU on the main board <strong>of</strong> the PC<br />

39 Transform <strong>and</strong> Lighting was first introduced by NVIDIA Corporation with the GeForce 256 in 1999<br />

40 Geometry which does not affect the output image <strong>of</strong> a particular rendering pass<br />

41 A bounding volume is a simplified geometric shape surrounding the whole object geometry<br />

42 For depth buffer precision <strong>and</strong> increased performance a virtual viewport has a near <strong>and</strong> a far clipping<br />

plane, all objects with greater distance to the camera than the far clipping plane are not drawn


Engine <strong>Design</strong> ::: Graphics – Rendering Techniques <strong>and</strong> Lighting 16<br />

2.2.2 Forward Rendering – A Single Pass <strong>and</strong> Many Possibilities<br />

Forward rendering processes all relevant geometry sequentially, r<strong>and</strong>om or sorted by a<br />

scene graph for improved performance. If transparent meshes exist in the scene, they<br />

have to be processed after solid geometry <strong>and</strong> sorted back to front. Since every object is<br />

drawn on a final bitmap, objects can only be drawn on top <strong>of</strong> each other. If a transparent<br />

object was rendered to early by accident, solid geometry further away from the camera,<br />

which is occluded by the transparent surface can not be drawn behind this transparent<br />

surface anymore.<br />

The object geometry is processed by a Vertex Shader, which applies WVP 43<br />

transformations <strong>and</strong> can also apply effects like skinning based on bones or other effects<br />

changing the geometry <strong>of</strong> an object. Lighting can also be done in the Vertex Shader, but<br />

calculating it in the Pixel Shader results in improved quality, since lighting information<br />

is not simply interpolated over the surface, but calculated for each pixel. Lighting calculation<br />

uses certain values <strong>of</strong> the lights in the scene, commonly including the position <strong>of</strong><br />

the light source, its direction <strong>and</strong> color. These informations together with the position,<br />

normal orientation <strong>and</strong> attributes <strong>of</strong> the surface <strong>of</strong> the processed object calculate the final<br />

color <strong>of</strong> each pixel filled by the object. Most lighting calculations are based on the<br />

Phong or Blinn-Phong lighting model, which is a slightly simplified version <strong>of</strong> Phong<br />

lighting with improved performance (ref. [EBE01]).<br />

Since lighting calculations require not only different values changing over time,<br />

but in many cases completely different calculations, several formulas have to be implemented<br />

for various materials or light types in the scene. If there are multiple lights in a<br />

scene, the lighting calculations have to be done for all lights affecting an object resulting<br />

in one drawback <strong>of</strong> forward rendering. Although shader units are freely programmable,<br />

they have many limitations regarding the complexity <strong>of</strong> shader code. As such<br />

Shader Model 2.0 <strong>of</strong>fered a maximum <strong>of</strong> 64 arithmetic instruction slots <strong>and</strong> a maximum<br />

<strong>of</strong> 32 constant value registers. Dynamic branching, function calls <strong>and</strong> loops are not supported<br />

<strong>and</strong> can only partially be replaced (ref. [DIE04]). Resulting from this limitations<br />

Shader Model 2.0 supports a maximum <strong>of</strong> three light sources affecting the same object.<br />

Another consequence from the lack <strong>of</strong> support for dynamic branching is the requirement<br />

<strong>of</strong> a unique shader for each material – light type combination with different lighting formulas.<br />

If a scene has 3 different light types <strong>and</strong> 2 different materials with a maximum<br />

support for 3 lights affecting an object, full support for all combinations <strong>of</strong> a material<br />

with 3 light types result in a total <strong>of</strong> 54 44 different shader which have to be implemented<br />

<strong>and</strong> updated, whenever something in the lighting model or materials changes.<br />

43 WVP = World View Projection means the transformation matrices resulting from scale, rotation <strong>and</strong><br />

position <strong>of</strong> an object in the scene <strong>and</strong> the view <strong>and</strong> projection matrices by the active viewport<br />

44 Two materials can be lit each by 3 lights at once, each light can be one <strong>of</strong> 3 types 2∗3 3 =54


Engine <strong>Design</strong> ::: Graphics – Rendering Techniques <strong>and</strong> Lighting 17<br />

Although Shader Model 3.0 solves some <strong>of</strong> these problems, providing support<br />

for dynamic branching <strong>and</strong> up to 512 arithmetic instruction slots, it still remains limited<br />

to a maximum <strong>of</strong> 8 lights affecting an object at once (ref. [HAR04]). All material shader<br />

can be unified in a single Meta Shader using a branch for each material. But the problem<br />

with a huge number <strong>of</strong> different shader for all light material combinations still remains.<br />

Shader Model 3.0 is only supported by the latest generation <strong>of</strong> graphic adapters,<br />

while the majority <strong>of</strong> graphic adapters only supports Shader Model 2.0 or even lower.<br />

To improve performance <strong>and</strong> deal with complex scenes including multiple light<br />

sources, a complex scene graph has to be maintained. To avoid complex lighting operations<br />

on geometry which is occluded by other solid geometry in the final image, all solid<br />

meshes in the scene can be sorted front to back in regards to the camera view. This way<br />

the closest objects are rendered first <strong>and</strong> if other objects processed later were to be<br />

rendered behind these objects the depth test fails <strong>and</strong> no shader operations have to be<br />

calculated. To comply with light numbers greater than the maximum number <strong>of</strong> lights<br />

supported, the lights can be sorted for each mesh by distance <strong>and</strong> intensity. Using this<br />

sorting only the most relevant lights for each object are processed by the shader. Scenes<br />

with a great number <strong>of</strong> dynamic lights are usually outdoor night scenes, where a whole<br />

scenery can easily be filled with more than 20 lights. But most <strong>of</strong> these lights only affect<br />

a small area <strong>of</strong> the whole scene, <strong>and</strong> a single object is probably not affected by more<br />

than 3 lights.<br />

2.2.3 Deferred Shading – Multiple Passes for Multiple Lights<br />

Deferred Shading is a whole different approach to rendering. It addresses the limitations<br />

<strong>of</strong> Shader Model 2.0 <strong>and</strong> Forward Rendering with a render design separating lighting<br />

from object geometry. Using Deferred Shading, the whole scene geometry is first<br />

rendered to multiple render targets. A render target is a bitmap just like the final output<br />

image, but render targets can not only save colors, but also position, normal direction, or<br />

other surface parameters <strong>of</strong> the underlying object 45 . No surface calculations are done in<br />

the first pass <strong>of</strong> Deferred Rendering, neither are any lighting computations or other surface<br />

effects. However the first pass includes all effects changing the geometry <strong>of</strong> an object,<br />

like skinning or displacement mapping using only Vertex Shader. The render targets<br />

used in this process usually save all information needed for lighting <strong>and</strong> sometimes<br />

special post processing effects like motion blur.<br />

In the next step the render targets are used as input textures for lighting calculations. All<br />

scene lights are applied per pixel to the geometry buffer, step by step filling the final<br />

scene with light. Since each light is rendered in a single shader pass, each light only<br />

needs one shader, which can access all required information already formatted 46 .<br />

45 Some <strong>of</strong> these parameters require the support <strong>of</strong> Floating Point Render Targets.<br />

46 The geometry buffer can already do light independent calculations <strong>and</strong> save the surface parameters as<br />

normalized values as needed for lighting calculations


Engine <strong>Design</strong> ::: Graphics – Rendering Techniques <strong>and</strong> Lighting 18<br />

Figure 2.3: Visualization <strong>of</strong> 4 Preliminary Buffers used for Deferred Shading<br />

The contents <strong>of</strong> the Geometry-Buffer can be visualized (see Figure 2.3). Using a discrete<br />

rendering pass for each light in the scene, the limitations <strong>of</strong> Shader Model 2.0 can<br />

be bypassed, as each light has a particular shader, only containing the lighting calculations<br />

for this particular light. As a result the only limitations for the number <strong>of</strong> lights is<br />

the available performance <strong>of</strong> the target system. Another benefit <strong>of</strong> Deferred Rendering<br />

is the per pixel calculation <strong>of</strong> lighting. Since all effects are only applied to the pixels<br />

making up the final scene, each light will only affect pixels which are visible on the final<br />

screen, even without any front to back sorting. Complex geometry will only be relevant<br />

in the geometry part <strong>of</strong> Deferred Shading <strong>and</strong> can be treated completely separated<br />

from any lighting or post processing effects. Another side effect <strong>of</strong> the screen space<br />

lighting per pixel is that the calculation time <strong>of</strong> light depends immediately on the screen<br />

space it covers 47 .<br />

But outweighing those benefits are some drawbacks <strong>of</strong> Deferred Rendering. The<br />

principal drawback is the limitation <strong>of</strong> the geometry buffer, which only <strong>of</strong>fers a single<br />

set <strong>of</strong> surface parameters for each pixel <strong>of</strong> the final image. Whereas transparent objects<br />

occupy the same pixels as the objects partially occluded by them. Resulting from this<br />

Deferred Rendering can only render lighting <strong>and</strong> effects for the transparent surface or<br />

the surface lying behind it. Since both surfaces require lighting, a second pass for transparent<br />

objects is inevitable. One option is to use a multi layer geometry buffer, which<br />

can store multiple sets <strong>of</strong> surface parameters for each pixel. This informations can then<br />

be used by multiple lighting passes to generate the final screen pixel. Another option is<br />

47 This is a desired effect, since small lights very far from the camera should only use minimal processing<br />

power, even if the light very complex geometry, which only covers a few pixels <strong>of</strong> the screen


Engine <strong>Design</strong> ::: Graphics – Rendering Techniques <strong>and</strong> Lighting 19<br />

to render a whole second pass <strong>of</strong> Deferred Shading rendering the transparent surfaces on<br />

top <strong>of</strong> the solid geometry processed in the first pass. But this would be very expensive,<br />

because it would almost double the rendering time <strong>of</strong> a single frame.<br />

The third <strong>and</strong> most widely used method to deal with transparent geometry results<br />

from the fact transparent surfaces not needing as precise lighting as solid geometry,<br />

since they are translucent. All solid geometry in the scene is rendered using Deferred<br />

Shading <strong>and</strong> the transparent surfaces are drawn using Forward Rendering. Since transparent<br />

surfaces are not as visible as solid geometry, only the main lights <strong>of</strong> a scene need<br />

to be considered in lighting. This allows the use <strong>of</strong> Shader Model 2.0 for a scene with an<br />

nearly unlimited number <strong>of</strong> lights affecting all solid geometry, <strong>and</strong> the three most important<br />

lights also affecting transparent surfaces.<br />

2.2.4 Conclusion – Deferred Rendering Does the Job<br />

Considering benefits <strong>and</strong> drawbacks <strong>of</strong> both rendering techniques, the author chooses<br />

Deferred Rendering for Assembler Bay. The game concept is designed to run on current<br />

hardware, but Shader Model 3.0 is only supported by the latest generation <strong>of</strong> graphic adapters<br />

<strong>and</strong> even state <strong>of</strong> the art titles released 2009 still support Shader Model 2.0. Since<br />

Assembler Bay aims to be a visually stunning game, the limitations <strong>of</strong> Forward Rendering<br />

with Shader Model 2.0 are too severe. Another motive is the use <strong>of</strong> new technologies<br />

in the game engine for this project. Whereas Forward Rendering is a traditional<br />

Rendering technique used by almost every game, Deferred Rendering has just been introduced<br />

to the market by some top titles each setting milestones in game graphics. One<br />

<strong>of</strong> these titles is Killzone 2 which releases 2009 for Sony's PlayStation3 (Figure 2.4 48 )<br />

Figure 2.4: Screenshot <strong>of</strong> Killzone 2 showing capabilities <strong>of</strong> Deferred Shading<br />

48 Screenshot found on [http://www.killzone.com/kz/media.psml]


Engine <strong>Design</strong> ::: Graphics – Rendering Techniques <strong>and</strong> Lighting 20<br />

2.3 Physics – Simulation or Feint<br />

The importance <strong>of</strong> a working Physics Engine in every modern <strong>3D</strong> game with action elements<br />

has been explained in section 2.1.2. This section will depict the variety <strong>of</strong> tasks a<br />

Physics Engine has to solve <strong>and</strong> problems arising from it. Without a Physics Engine a<br />

character could float like a ghost, no gravity would pull him down <strong>and</strong> he could just fly<br />

through walls <strong>and</strong> solid objects. A Physics Engine has two primary tasks – Collision<br />

Detection <strong>and</strong> Collision Response. The Collision Detection component uses various<br />

methods to decide if two objects intersect, or will intersect in the next frame if they keep<br />

on moving. The Collision Response component highly depends on the participating objects.<br />

While a massive stone should fall on the ground, breaking things under its weight,<br />

a rubber should deform <strong>and</strong> bounce. Characters or other living entities are a special<br />

case, because they react to collisions by moving their own body, if they are still alive.<br />

2.3.1 Collision Detection <strong>and</strong> Collision Response<br />

The straightforward method to check if two objects intersect would be to check each<br />

polygon <strong>of</strong> one object against each polygon <strong>of</strong> the other object for intersection. But with<br />

high polygon counts in current games, it is not uncommon to have about 500.000 polygons<br />

in a scene. This would result in about 250 billion polygon intersection checks per<br />

frame, even a 5 GHz CPU would still need about several minutes for a single frame 49 .<br />

To improve performance, a lot <strong>of</strong> objects can be excluded from Collision Detection using<br />

information about the scene (e.g. static geometry can not collide with each other, because<br />

it is not moving) The second step to reduce calculation costs is the use <strong>of</strong> bounding<br />

volumes, which can either be used to deny collision detection for a whole object, if<br />

its bounding volume does not intersect with any other bounding volume, or to simplify<br />

collision detection by using the bounding volume to replace the actual geometry for<br />

physics calculations.<br />

The second method is binary space partitioning, where a huge number <strong>of</strong> polygons<br />

or objects can be omitted from intersection tests, because they are in distinct parts<br />

<strong>of</strong> the scene <strong>and</strong> too far away from each other to intersect. Using binary space partitioning,<br />

polygon exact collision detection can be performed with high performance (see<br />

[EBE04]). This is desirable, because the use <strong>of</strong> collision meshes requires additional<br />

work in level design, as collision geometry has to be created for every object in a level.<br />

Although pr<strong>of</strong>essional games can afford high expenses in level design <strong>and</strong> additional<br />

work, the concept for the game engine designed in this project is an engine which can<br />

easily integrate new game assets without special requirements.<br />

49 Even if an intersection test were possible in as few as 10 CPU cycles, computation would still need<br />

about 250 billion∗10 cycles /5GHz=500seconds


Engine <strong>Design</strong> ::: Physics – Simulation or Feint 21<br />

The second task <strong>of</strong> a Physics Engine is Collision Response. This includes objects<br />

bouncing <strong>of</strong>f each other, objects lying on the ground <strong>and</strong> falling over edges. The easy<br />

part <strong>of</strong> Collision Response is the calculation <strong>of</strong> the velocity <strong>of</strong> colliding objects using<br />

the law <strong>of</strong> preservation <strong>of</strong> energy. More complex is the influence <strong>of</strong> angular velocity on<br />

the collision <strong>and</strong> the resulting torque. A Physics Engine for a game does not always<br />

need to be correct. In most cases a Physics Engine only has to look the way the user expect<br />

things to behave. <strong>Game</strong>s which require real physics simulations are usually sport<br />

games including golf simulations, racing or soccer games. Physics Engines for these<br />

kind <strong>of</strong> games need to simulate much more sophisticated physical phenomena like drag,<br />

friction or the Magnus-Force. In these cases numerical methods are required to simulate<br />

such complex phenomena. The most widespread used operation is the fourth-order<br />

Runge-Kutta method, which is a special case <strong>of</strong> the numerical Runge-Kutta method,<br />

used to solve ordinary differential equations. However such advanced effects are not required<br />

in games using the Physics Engine just as an optional component.<br />

<strong>Action</strong> games or first person shooters usually only require a Physics Engine<br />

which looks believable. This can be achieved using simplified equations which represent<br />

the physical phenomena with most influence, being gravity, friction <strong>and</strong> preservation<br />

<strong>of</strong> momentum. To accomplish a believable behavior <strong>of</strong> different objects with this<br />

simplified equations, many tests <strong>and</strong> fine tuning are required, because the values used<br />

are purely empirical 50 .<br />

2.3.2 Collisions Under Extreme Conditions<br />

Extreme conditions regarding Collision H<strong>and</strong>ling emerge when objects collide with<br />

very high or very low velocities or in special environments like underwater. High velocity<br />

collisions are critical, because a game runs in discrete cycles. Collision Detection is<br />

calculated every frame, but very high velocities can result in an object moving a huge<br />

gap in one frame. Especially if the distance an object travels in a single frame is larger<br />

than the diameter <strong>of</strong> the object itself. The object can be on one side <strong>of</strong> a wall in the first<br />

frame <strong>and</strong> on the other side in the next frame, without intersecting with the wall in<br />

either <strong>of</strong> these two frames. To comply with this problem, the physics component computes<br />

Collision H<strong>and</strong>ling each frame in advance to the movement <strong>of</strong> the object <strong>and</strong> does<br />

not use the actual position, but rather the forecast position <strong>of</strong> the object, if it keeps its<br />

velocity. In this matter, if the velocity <strong>of</strong> an object is too high, it can run through a loop<br />

<strong>of</strong> Collision Detections, moving just a part <strong>of</strong> the whole distance each time, until it<br />

either collides or Collision Detection is computed for the whole range.<br />

Another problem is an objects getting stuck between other objects or gaps in the<br />

level geometry. If an object collides with a wall, its velocity is adapted in a way repelling<br />

it from the wall, but if it immediately collides with an opposite wall it may get<br />

50 Although the formulas used are usually based on physic equations, values for mass, coefficient <strong>of</strong><br />

restitution or moment <strong>of</strong> inertia are just guesses for objects in a <strong>3D</strong>-<strong>Game</strong>


Engine <strong>Design</strong> ::: Physics – Simulation or Feint 22<br />

stuck inside the wall. Recursive Collision Detection would have to do a second cycle<br />

after the first Collision Response, to check if the object will collide with another object<br />

prior to moving it. But if an object gets stuck between two walls, this recursion would<br />

be infinite. Even a reasonable limit in recursions would still have a severe impact on<br />

performance. A reasonable way to deal with this problem is to halt the movements <strong>of</strong> an<br />

object completely if it collides with two opposite surfaces at once, if they both exceed<br />

the colliding object in weight. This leads to another problem: Preservation <strong>of</strong> momentum<br />

for whole groups <strong>of</strong> objects. In reality the lowest crate <strong>of</strong> a high stack <strong>of</strong> crates<br />

can not be moved easily, because the whole weight <strong>of</strong> all crates on top <strong>of</strong> it add up to its<br />

weight, being connected by static boundary friction. But to simulate this kind <strong>of</strong> influence<br />

<strong>of</strong> objects on each other is a complex task, which should only be implemented if a<br />

correct simulation <strong>of</strong> physics is a core element <strong>of</strong> the game. To feint the effect <strong>of</strong> static<br />

boundary friction resulting from gravity, each object can be assigned a list <strong>of</strong> objects<br />

which add their mass to the current objects mass. On Collision Response this calculated<br />

mass can be used. Each object, which collides with another object below its center <strong>of</strong><br />

gravity will add itself to the list <strong>of</strong> its partner as long as the collision occurs. Although<br />

this feint does not deal with all influences <strong>of</strong> static boundary friction, it is sufficient.<br />

The second problem are very low velocity collisions in conjunction with gravity.<br />

In our everyday environment it is natural, that objects fall to the ground <strong>and</strong> keep lying<br />

still if no external force is applied to them. But lying on the ground is in fact a permanent<br />

collision <strong>of</strong> an object accelerated by gravity. Naturally a big part <strong>of</strong> the surface <strong>of</strong> an<br />

object touches the ground, if it is lying still. A permanent collision results in positive<br />

Collision Detection for all polygons touching the floor, in every frame. This produces<br />

the need for many Collision Responses, as each colliding polygon has an influence on<br />

the movement <strong>of</strong> an object. Because most objects will be lying still on the ground most<br />

<strong>of</strong> the time, the permanent collisions will have a severe impact on performance. To<br />

comply with this, an object can be labeled static, as soon its velocity undercuts a certain<br />

minimum while it collides with the ground. But this results in a new problem, because<br />

an object can also be colliding with another object in midair. If both objects are st<strong>and</strong>ing<br />

relatively still, it could happen that both objects get stuck at each other <strong>and</strong> are both<br />

labeled static, keeping floating in midair. Again many tests <strong>and</strong> fine tuning is required to<br />

get an acceptable result.<br />

The goal <strong>of</strong> the physics component designed in this project is a compromise<br />

between performance <strong>and</strong> a realistic look. Although it is acceptable, if objects do not behave<br />

in a physical correct way, it is important the user does not notice this while playing<br />

the game.


Draft <strong>and</strong> Expectations – Assembler Bay ::: Draft <strong>and</strong> Expectations – Assembler Bay 23<br />

3 Draft <strong>and</strong> Expectations – Assembler Bay<br />

This chapter will depict the design process <strong>of</strong> the game Assembler Bay. The first section<br />

will introduce various ideas for gameplay, story <strong>and</strong> setting <strong>of</strong> Assembler Bay <strong>and</strong> detail<br />

the process <strong>of</strong> brainstorming <strong>and</strong> sorting out ideas.<br />

The second section will explain why certain ideas were modified or discarded<br />

due to limitations <strong>and</strong> features <strong>of</strong> the underlying game engine. It will detail the high dependency<br />

<strong>of</strong> a digital game on its engine.<br />

3.1 Story <strong>and</strong> Setting – A <strong>Game</strong> Concept is Born<br />

The first idea to Assembler Bay came from brainstorming for creative game ideas. It is a<br />

<strong>3D</strong> puzzle game, set in an science fiction environment. The interesting basic idea <strong>of</strong> it is<br />

to make a game where the user can puzzle together complex objects like a space ship,<br />

abstract figures, tools or weapons in a free <strong>3D</strong> space. The first game idea did neither include<br />

any means <strong>of</strong> collecting the parts nor an explicit main character or a particular<br />

story. But the strong point <strong>of</strong> the concept is the idea for a unique gameplay, because the<br />

central part <strong>of</strong> Assembler Bay is a <strong>3D</strong> puzzle game. There is no game available with a<br />

similar gameplay concept, which makes Assembler Bay original in its fundamentals.<br />

The crucial point for the success <strong>of</strong> this project is the implementation <strong>of</strong> this genuine<br />

idea into a state <strong>of</strong> the art video game. The basic idea <strong>of</strong> a puzzle game could also have<br />

been realized without any surrounding story or main character. The game Tetris points<br />

out, that a good game does neither need a captivating storyline nor a great presentation<br />

to be successful. But the team decided at the very beginning to create a game with a<br />

continuous story <strong>and</strong> a real main character with emotions <strong>and</strong> his own history. Although<br />

a story based game requires a lot more work to be done, it is a whole different experience<br />

for the user, because he is able to identify with the protagonist.<br />

For the successful creation <strong>of</strong> a game, a sophisticated concept scoping details in<br />

gameplay as well as the intended design is inevitable, unless the game is designed by a<br />

single person. The first step for the whole team or at least all leading game designers is<br />

to sit together <strong>and</strong> envision their ideas for the final game. The images for the final game<br />

will naturally differ from person to person. This means a compromise has to be found in<br />

the form <strong>of</strong> a detailed paper, including all features <strong>and</strong> design specifications for the final


Draft <strong>and</strong> Expectations – Assembler Bay ::: Story <strong>and</strong> Setting – A <strong>Game</strong> Concept is Born 24<br />

game. The first concept session for Assembler Bay brought up more questions than answers,<br />

because the visions <strong>of</strong> the three team members differed greatly. If a concept session<br />

starts with too many differences, it has to be subdivided.<br />

A game concept can be divided in four main categories:<br />

• Setting<br />

• Presentation<br />

• <strong>Game</strong> Mechanics<br />

• Story<br />

The setting <strong>of</strong> a game is the basic situation the game represents. It includes the fundamentals<br />

<strong>of</strong> the virtual reality wherein the game is situated. A setting can even be represented<br />

by just a single sentence or even just a few drafts. Although it may seem the three<br />

last categories include the setting as part <strong>of</strong> the presentation <strong>and</strong> the story, it is important<br />

to agree on a certain setting, before the following points are discussed. Because the setting<br />

<strong>of</strong> a game will limit the possible game mechanics <strong>and</strong> even features <strong>of</strong> the presentation,<br />

it is the first point to be h<strong>and</strong>led. The different ideas <strong>of</strong> the team members are unified<br />

to the setting <strong>of</strong> Assembler Bay:<br />

Assembler Bay is a <strong>3D</strong> <strong>Puzzle</strong> <strong>Game</strong>, taking place in a fantastic future<br />

virtual reality. The main character is represented by his virtual alter ego<br />

in the computer world. His mission is the recovery <strong>of</strong> the virtual network,<br />

which is threatened by a superior entity. To do so, the protagonist has to<br />

reconstruct several parts <strong>of</strong> the virtual reality, which were destroyed by<br />

the hostile entity <strong>and</strong> subsequent defeat the antagonist.<br />

Although many details <strong>of</strong> story <strong>and</strong> gameplay are not defined in this outline, it is a good<br />

setting for a game. For a setting to be good, it has to be accepted by all team members<br />

<strong>and</strong> must not specify details, which will certainly be subject to change afterwards. An<br />

early agreement on a certain setting allows the team to spend their energy on the right<br />

topics. If a setting is too vague, whole concepts will be developed in vain, because they<br />

do not have any common base. This setting provides enough key points to start the<br />

design <strong>of</strong> concepts for game mechanics, presentation <strong>and</strong> story elements.<br />

Since the protagonist is a virtual character in a computer generated environment,<br />

he can have exceptional abilities. The whole environment can be designed in any imaginable<br />

shape, since it does not represent a continuous world, but parts <strong>of</strong> a damaged<br />

virtual network. These are particular key points for game mechanics, even though it was<br />

not even needed to decide if the protagonist is male or female or not even human. The<br />

same is true for the antagonist. Although his influence on the game <strong>and</strong> the virtual real-


Draft <strong>and</strong> Expectations – Assembler Bay ::: Story <strong>and</strong> Setting – A <strong>Game</strong> Concept is Born 25<br />

ity is stated, no details about his nature are determined. The antagonist could be a human,<br />

but he could also be a program or a group <strong>of</strong> various programs. The antagonist<br />

could be hostile or just accidentally causing problems without having influence on the<br />

game mechanics. This setting leaves enough story points open for later discussion, but<br />

sets a concrete base for the development <strong>of</strong> game mechanics <strong>and</strong> presentation.<br />

3.2 Presentation – The Look <strong>of</strong> a <strong>Game</strong><br />

Although many points were still very vague in the first idea for Assembler Bay, including<br />

the name itself, the target ambiance <strong>of</strong> the game was already determined. Assembler<br />

Bay will take place in a clean science fiction environment with very clear <strong>and</strong> shining<br />

colors. The main color in the first draws is white, with strong color accents in the level<br />

architecture. An obvious inspiration is the game Mirror's Edge by Electronic Arts,<br />

which impresses with vivid colors <strong>and</strong> various effects. One <strong>of</strong> these effects is HDR Rendering<br />

51 , which gives every scene a maximum <strong>of</strong> contrast <strong>and</strong> saturation. Another effect<br />

is a subtle bloom effect on the brightest tints, furthermore increasing the feeling <strong>of</strong> shining<br />

colors. The combination <strong>of</strong> these effects together with strong color accents creates<br />

an unique look (see Figure 3.1 52 )<br />

Figure 3.1: Vivid Colors in Mirror's Edge<br />

51 HDRR = High Dynamic Range Rendering, a rendering technique using a higher range <strong>of</strong> possible colors<br />

than the output display naturally supports. This results in a higher contrast <strong>and</strong> more details<br />

52 Picture taken from [http://on-mirrors-edge.com/incgalleryview.php?file=14.jpg]


Draft <strong>and</strong> Expectations – Assembler Bay ::: Presentation – The Look <strong>of</strong> a <strong>Game</strong> 26<br />

Although being a guide for Assembler Bay, this project does not try to copy the look <strong>of</strong><br />

Mirror's Edge, but rather to evolve its own look inspired by it. One key difference for<br />

Assembler Bay is lighting, because it takes place in a virtual environment, which does<br />

not need to obey natural laws. The concept for Assembler Bay suggests a discrete level<br />

architecture, where each level is situated in its own environment <strong>and</strong> transfer between<br />

levels is restricted, because they represent separated parts <strong>of</strong> a virtual network. A virtual<br />

reality can be equipped with a number <strong>of</strong> different light sources, while a game in a real<br />

outside environment needs to simulate the sky. This includes sunlight, moon <strong>and</strong> depending<br />

on the game even a realistic day <strong>and</strong> night circle. Indoor scenes are still bound<br />

to visible light sources, such as light bulbs or neon lamps (see [MIC06]). If a scene is<br />

just lighted, without the presence <strong>of</strong> a traceable light source, the game will look unrealistic.<br />

But Assembler Bay wants to achieve a look between realism <strong>and</strong> fiction, the virtual<br />

reality is reminiscent <strong>of</strong> the real world in obeying some laws <strong>of</strong> reality. But on the<br />

other h<strong>and</strong> some features <strong>of</strong> the world in Assembler Bay will always look unrealistic<br />

<strong>and</strong> remind <strong>of</strong> the uncertainty <strong>and</strong> the threats this virtual world bears.<br />

The second key difference <strong>of</strong> Assembler Bay to realistic games is level architecture.<br />

A level in Assembler Bay can use any imaginable geometry, without the need <strong>of</strong><br />

being physically possible. Furthermore discontinuous levels allow for great differences<br />

between levels, whereas a coherent world needs to have a coherent representation. The<br />

presentation <strong>of</strong> Assembler Bay is designed to create an ambiance <strong>of</strong> a virtual reality reminding<br />

<strong>of</strong> a high technology science fiction world. The key point to create this look is<br />

the design <strong>of</strong> a detailed <strong>and</strong> clear level architecture. But the level design alone is not<br />

enough to create a unique look. The rendering component <strong>of</strong> the game engine greatly<br />

contributes to the final look <strong>of</strong> the game. The resulting ambiance or style <strong>of</strong> a game is a<br />

composition <strong>of</strong> object design, texturing <strong>and</strong> rendering.<br />

3.2.1 Visual Features for Assembler Bay<br />

The concept phase <strong>of</strong> a game includes setting up requirements for the game engine. The<br />

requirements for the rendering component have to be adapted to the game, since a high<br />

quality graphics engine is specialized for certain circumstances. As such, many different<br />

rendering techniques for various effects <strong>and</strong> situations exist. But there was neither a<br />

need, nor the time to implement all promising available techniques. The team created a<br />

list with effects <strong>and</strong> techniques which would improve the image quality <strong>of</strong> Assembler<br />

Bay <strong>and</strong> contribute to the aspired look. This list is ordered by importance <strong>and</strong> will be<br />

processed <strong>and</strong> implemented from top to bottom.


Draft <strong>and</strong> Expectations – Assembler Bay ::: Presentation – The Look <strong>of</strong> a <strong>Game</strong> 27<br />

Desirable Graphic Features for Assembler Bay:<br />

• High Quality Dynamic Lighting<br />

• Dynamic S<strong>of</strong>t Shadows<br />

• Ambient Occlusion<br />

• Overexposure<br />

• Multi Sample Anti Aliasing (optional)<br />

• Bloom Effect (optional)<br />

• Depth <strong>of</strong> Field (optional)<br />

• HDR Post Processing (optional)<br />

The first required feature is high quality dynamic lighting, which is different from<br />

st<strong>and</strong>ard lighting supplied by Direct X 9 graphics adapters. The lighting model for Assembler<br />

Bay should include various types <strong>of</strong> different lights in particular shapes. These<br />

light types <strong>and</strong> respective parameters are aimed at the lighting model provided by the<br />

<strong>3D</strong> CAD 53 s<strong>of</strong>tware the team used – 3ds Max by Autodesk. An implementation using the<br />

same parameters as specified in the <strong>3D</strong> modeling s<strong>of</strong>tware had one big advantage. The<br />

designed geometry could be completely lighted in the <strong>3D</strong> modeling s<strong>of</strong>tware, which allows<br />

for instant rendering <strong>of</strong> lighted scenes. The lighting information could be transferred<br />

to the game afterwards <strong>and</strong> provide the lighting, which was desired by the architect<br />

<strong>of</strong> the level. High quality dynamic lighting also includes the features <strong>of</strong> Deferred<br />

Shading detailed in section 2.3.3.<br />

3.2.2 Dynamic S<strong>of</strong>t Shadows – High Realism Through Shadows?<br />

Dynamic shadows are a feature expected in every modern <strong>3D</strong> engine. Because Ray Tracing,<br />

or Radiation are still far from being applicable in real time applications, the last<br />

years established two major approaches for shadow generation. Shadow generation in<br />

games has to deal with performance <strong>and</strong> visual appearance, while realism does not matter<br />

to the user, as long as the result looks believable. This two major approaches will be<br />

discussed in the following sections, since the shadowing algorithm has a great influence<br />

on the final look <strong>of</strong> a game. The first approach are Stencil Shadow Volumes.<br />

53 <strong>3D</strong> Computer Aided <strong>Design</strong> – S<strong>of</strong>tware for <strong>3D</strong> modeling <strong>and</strong> animation


Draft <strong>and</strong> Expectations – Assembler Bay ::: Presentation – The Look <strong>of</strong> a <strong>Game</strong> 28<br />

3.2.3 Stencil Shadow Volumes – Pixel Perfect Hard Shadows<br />

The basic idea behind Stencil Shadow Volumes is to generate a polygonal shadow<br />

volume from the object mesh itself. This shadow volume represents the volume where<br />

light is occluded by the object. This volume is rendered to the Stencil Buffer 54 in a way<br />

similar to the rendering <strong>of</strong> light volumes in Deferred Shading (see section 4.3.5). Once<br />

the Stencil Buffer holds information about which parts <strong>of</strong> the scene are in shadow, the<br />

light can be applied to all pixels not marked in the Stencil Buffer. The benefit <strong>of</strong> Stencil<br />

Shadow Volumes is resolution independence. All shadows will always produce pixelperfect<br />

sharp edges, because polygons are used for shadow determination (Figure 3.2).<br />

Figure 3.2: Stencil Shadow Volumes in Doom 3, producing hard edges<br />

However the complex part <strong>of</strong> producing Stencil Shadow Volumes is the generation <strong>of</strong><br />

the shadow volume geometry. To generate a shadow volume, the boundary between<br />

lighted <strong>and</strong> shadowed polygons in respect to a certain light source has to be found. This<br />

can be done by separating the polygons into front-facing <strong>and</strong> back-facing polygons as<br />

seen from the center <strong>of</strong> the light source. The edges between those polygons are extruded<br />

away from the light source towards infinity. This extrusion really needs to be done to infinity,<br />

because any static value could be too small, if the light source is very close to an<br />

object. For objects with complex geometry the generation <strong>of</strong> shadow volumes can be<br />

very time consuming, as many polygons have to be drawn. Although an approach using<br />

the Depth Buffer for geometry independent shadow volume generation exists, it is not<br />

very practical, as it introduces aliasing <strong>and</strong> does not scale well on complex objects.<br />

54 The Stencil Buffer is an arbitrary rendering buffer, which can save additional information


Draft <strong>and</strong> Expectations – Assembler Bay ::: Presentation – The Look <strong>of</strong> a <strong>Game</strong> 29<br />

Although being used in some recent games (e.g. Doom 3) Stencil Shadow<br />

Volumes have some serious drawbacks. One drawback is the performance for complex<br />

geometry, as the shadow volumes will have many small edges stretched over the whole<br />

screen, but filling only a few pixels. This will produce high drawing costs. Another<br />

downside are the perfectly sharp shadow edges, which seem very unnatural if a game<br />

uses ambient occlusion, or other s<strong>of</strong>t shadowing effects.<br />

But the most important reason, this project will not use Stencil Shadow Volumes<br />

in an open source community engine, is the strict requirement to mesh geometry. Because<br />

the shadow volumes are created from object polygons, all objects are required to<br />

be completely closed meshes. A single open polygon or unconnected edge could crash<br />

the whole game, or at least produce severe artifacts. Pr<strong>of</strong>essional studios can invest a<br />

great amount <strong>of</strong> time into the quality <strong>of</strong> <strong>3D</strong>-models, but community games are usually<br />

developed as a hobby <strong>and</strong> use models which can not guarantee these strict requirements.<br />

3.2.4 Shadow Mapping – Simple, Compatible <strong>and</strong> Somewhat Blurry<br />

The second technique, which is used in most games is Shadow Mapping. The idea behind<br />

Shadow Mapping is that every shadowed pixel in a scene needs to be occluded by<br />

something, e.g. something is blocking the light rays from reaching this pixel. If a pixel<br />

is occluded, this means this pixel is not visible from the view <strong>of</strong> the light, as another<br />

pixel is closer to the light at this particular point. Since the Depth Buffer is designed to<br />

save the distance <strong>of</strong> pixels to a viewport, Shadow Mapping uses this available technology.<br />

First the whole scene is rendered to a Depth Buffer from the light viewport 55 . This<br />

Depth Buffer is used in the lighting draw call, where every pixel drawn from the camera<br />

viewport will be projected to the light viewport <strong>and</strong> compared against the stored value<br />

in the Depth Buffer. If the stored value is smaller than the calculated depth value <strong>of</strong> the<br />

pixel, the pixel is shaded. Otherwise the pixel is directly lit by the light source <strong>and</strong> lighting<br />

can be applied as usual.<br />

However Shadow Mapping has one severe drawback in contrast to Stencil Shadow<br />

Volumes, which is aliasing. Because the shadow map is a bitmap, it has limited resolution,<br />

which results in visible pixel borders, if one shadow map pixel is projected to<br />

multiple pixels <strong>of</strong> the final image. This aliasing will not occur with Stencil Shadow<br />

Volumes, because the Stencil Buffer used is mapped 1:1 to the final image. Another<br />

drawback is the limited precision <strong>of</strong> the Depth Buffer, which leads to self shadowing or<br />

discontinuous shadow boundaries. Because the difference in the depth values <strong>of</strong> two<br />

surfaces very close to each other can be smaller than the smallest step in the Depth Buffer.<br />

The aliasing problem <strong>of</strong> Shadow Mapping can be witnessed in Figure 3.3.<br />

55 The light viewport is a virtual camera, which can see everything directly illuminated by this light


Draft <strong>and</strong> Expectations – Assembler Bay ::: Presentation – The Look <strong>of</strong> a <strong>Game</strong> 30<br />

Figure 3.3: Shadow Map Aliasing (1024x1024 shadow maps) PCF only<br />

But many drawbacks <strong>of</strong> Shadow Mapping can be addressed by using more sophisticated<br />

algorithms. The comparison <strong>and</strong> implementation <strong>of</strong> these algorithms will be detailed in<br />

section 4.4, where Variance Shadow Mapping is implemented for Assembler Bay.<br />

3.2.5 Ambient Occlusion – Realtime or Static ?<br />

Ambient Occlusion is another shading technique, which simulates diffuse reflections<br />

<strong>and</strong> occlusion <strong>of</strong> surfaces. The basis for Ambient Occlusion is the fact, that even objects<br />

which are not directly lit by a light, receive indirect lighting by diffuse reflections <strong>of</strong> the<br />

surrounding surfaces. On the other h<strong>and</strong> surfaces which are close, block the light for<br />

each other, darkening both surfaces. Ambient Occlusion creates a strong depth pr<strong>of</strong>ile<br />

for scenes, even with only few light sources. Using this effect, scenes can have a convincing<br />

spatial look, even without the use <strong>of</strong> any textures or different colors.<br />

However since Ambient Occlusion depends on the relation <strong>of</strong> many surfaces to<br />

each other, calculation costs for dynamic real time Ambient Occlusion are very high.<br />

Various methods for the simulation <strong>of</strong> Ambient Occlusion exist, but none <strong>of</strong> them is<br />

really suited for a real time application on current hardware. NVIDIA released a paper<br />

on Screen Space Ambient Occlusion in September 2008, describing a method <strong>of</strong> feinting<br />

Global Illumination by using the depth buffer (ref. [BUN05]). The depth buffer contains<br />

a height map <strong>of</strong> the part <strong>of</strong> the scene visible to the camera. Although SSAO 56<br />

misses out on a great part <strong>of</strong> the scene, which is not visible to the camera, it still produces<br />

convincing results <strong>and</strong> is used in titles like S.T.A.L.K.E.R or Assassins Creed.<br />

56 Screen Space Ambient Occlusion uses the Depth <strong>and</strong> Normal-Buffer <strong>of</strong> the final image for calculations<br />

rather than the whole scene geometry.


Draft <strong>and</strong> Expectations – Assembler Bay ::: Presentation – The Look <strong>of</strong> a <strong>Game</strong> 31<br />

Still, even this feint effect produces a severe impact on performance, which is<br />

why the team decided to use pre rendered Static Ambient Occlusion. Static Ambient<br />

Occlusion is calculated in the <strong>3D</strong> modeling s<strong>of</strong>tware beforeh<strong>and</strong>, utilizing Global Illumination<br />

<strong>and</strong> Radiosity. The resulting light maps <strong>of</strong> these calculations are written to textures<br />

<strong>and</strong> used in the final game as basis for the diffuse color textures. These method requires<br />

no calculations in the final game <strong>and</strong> produces great results for static geometry.<br />

However, since the lighting textures are static in the final game, moving objects will not<br />

have dynamic Ambient Occlusion, leading to wrong lighting for these objects in the<br />

game. But Ambient Occlusion is a very subtle effect, having the biggest impact on self<br />

shading surfaces or the occlusion resulting from very big objects. Small moving objects<br />

have only little effect as occluders <strong>and</strong> will not decrease visual quality.<br />

3.2.6 Additional Effects for an Unique Look<br />

Another important effect for the desired look <strong>of</strong> Assembler Bay is Overexposure, which<br />

adds an ambient lighting to the scene, resulting in shining colors. The basic idea <strong>of</strong><br />

Overexposure is to let all colors shine with maximum intensity regardless <strong>of</strong> how much<br />

light actually reaches the surface. Without other effects this would result in a completely<br />

plain picture, lacking any sense <strong>of</strong> depth. But in combination with Ambient Occlusion,<br />

specular highlights <strong>and</strong> dynamic shadows an unique look can be achieved. The whole<br />

scene has a bright <strong>and</strong> illuminated look including bright specular reflections on glossy<br />

surfaces. On the other h<strong>and</strong> rifts, or occluded pieces are darker <strong>and</strong> all objects project<br />

strong cast shadows on their surroundings. The effect <strong>of</strong> Overexposure can be seen in<br />

Figure 3.4.<br />

Figure 3.4: Comparison <strong>of</strong> Overexposure <strong>and</strong> Normal Lighting in Assembler Bay


Draft <strong>and</strong> Expectations – Assembler Bay ::: Presentation – The Look <strong>of</strong> a <strong>Game</strong> 32<br />

The left side <strong>of</strong> Figure 3.4 shows traditional lighting <strong>of</strong> a scene, the right side shows<br />

only colors with Ambient Occlusion <strong>and</strong> the center part shows the result <strong>of</strong> Overexposure<br />

with shadows <strong>and</strong> highlights. Since time <strong>and</strong> resources for this project are limited,<br />

all effects which are not essential for the look <strong>of</strong> the game are labeled optional. These<br />

effects would be beneficial for the final visuals, but are not required as essential features.<br />

The first effect is Multi Sample Anti Aliasing (MSAA), which improves visual<br />

quality by interpolating edges from multiple samples for a single pixel in the final image.<br />

MSAA is natively supported by modern graphic adapters <strong>and</strong> hence available in<br />

most games. But MSAA has some limitations, if special rendering techniques or effects<br />

are used which utilize multiple render targets or floating point textures. These effects include<br />

Deferred Shading, HDRR <strong>and</strong> certain methods <strong>of</strong> motion blur or Depth <strong>of</strong> Field.<br />

Since Assembler Bay uses Deferred Shading, which is incompatible with MSAA, the<br />

implementation would only work via certain changes in the render architecture.<br />

The next optional feature is a Bloom effect. Bloom is an post processing effect,<br />

which is addressed in section 1.4. It operates solely on 2D color data <strong>and</strong> can be implemented<br />

independent <strong>of</strong> any rendering technique used. Bloom usually works on certain<br />

colored or exceptional bright parts <strong>of</strong> an image <strong>and</strong> blurs these colors, resulting in<br />

bleeding <strong>of</strong> these shades over neighboring objects. Bloom simulates a natural effect, for<br />

example if light shines into a dark room through a small window, the light will bleed<br />

over the window border <strong>and</strong> appear brighter (ref. [MIC06]) Depth <strong>of</strong> Field is another<br />

post processing effect, but in contrast to bloom, it requires additional spatial information<br />

to the pixel color. Depth <strong>of</strong> Field simulates the limited depth <strong>of</strong> focus a camera or the<br />

human eye can only see sharp at once. Everything outside <strong>of</strong> this depth range will appear<br />

blurred. Depth <strong>of</strong> field uses a certain predefined or calculated depth range for the<br />

viewport <strong>and</strong> blurs every part <strong>of</strong> the image, which is closer or further away.<br />

Figure 3.5: Pre-Rendered Depth <strong>of</strong> Field <strong>and</strong> selective Bloom for Assembler Bay


Draft <strong>and</strong> Expectations – Assembler Bay ::: Presentation – The Look <strong>of</strong> a <strong>Game</strong> 33<br />

Depth <strong>of</strong> Field can concentrate the user's attention on a certain space or object in<br />

the scene <strong>and</strong> create a feeling <strong>of</strong> great distances. Figure 3.5 shows a pre rendered simulation<br />

<strong>of</strong> depth <strong>of</strong> field in addition to a selective Bloom filter. A selective Bloom filter is<br />

a special case <strong>of</strong> Bloom effect. Selective Bloom does not filter the picture with a lowpass<br />

filter to extract the regions which should be affected, but rather uses scene information,<br />

like a certain object-id rendered in an arbitrary buffer.<br />

3.3 <strong>Game</strong> Mechanics – Concepts for a <strong>3D</strong> <strong>Puzzle</strong> <strong>Game</strong><br />

The basic concept <strong>of</strong> Assembler Bay is a <strong>3D</strong> puzzle game, but a much more detailed<br />

concept <strong>of</strong> game mechanics is needed for the final paper 57 . Since a game is not limited<br />

to its primary game element, the possible game elements for a puzzle game can be divided<br />

in three sections.<br />

These three sections make up the final game experience:<br />

• Primary <strong>Puzzle</strong> Mechanics<br />

• Supplemental Elements<br />

• Secondary <strong>Game</strong> Mechanics<br />

Primary <strong>Puzzle</strong> Mechanics are the core gameplay <strong>of</strong> a puzzle game. If a game is designed<br />

without any storyline or additional features, the primary game mechanics will be<br />

sufficient for the whole game. In Assembler Bay Primary <strong>Puzzle</strong> Mechanics are required<br />

for the user to interact with the <strong>3D</strong> puzzle. To assemble complex objects in free<br />

<strong>3D</strong> space is a difficult task with about 8 degrees <strong>of</strong> freedom for position <strong>and</strong> alignment<br />

<strong>of</strong> a tile. It would be very difficult for the user to start with any tile free floating in <strong>3D</strong><br />

space <strong>and</strong> attach other parts. In addition to the complex task <strong>of</strong> finding the right part to<br />

attach, the user would also have to look out for the surrounding free space remaining<br />

<strong>and</strong> adjust the tiles to fit exactly. The team decided Assembler Bay is designed to be an<br />

action oriented game <strong>and</strong> subsequent the <strong>Puzzle</strong> Mechanics should be as intuitive as<br />

possible. Assembler Bay will have time limited puzzle stages, where the user has to react<br />

fast <strong>and</strong> attach the right tiles in rapid succession.<br />

A speed oriented gameplay requires a less complex puzzle structure. The team<br />

decided on a hierarchical puzzle structure, where each puzzle would include a single<br />

center part as a starting point for assembly. This center part will be placed automatically<br />

in the right spot <strong>and</strong> the user has to attach the remaining parts to this center part. But the<br />

puzzle will not be limited to a single layer, although independent parts can be attached<br />

to the center part in any sequence, other tiles require the prior attachment <strong>of</strong> certain<br />

57 Final paper refers to the final game design document, including all guidelines for the game


Draft <strong>and</strong> Expectations – Assembler Bay ::: <strong>Game</strong> Mechanics – Concepts for a <strong>3D</strong> <strong>Puzzle</strong> <strong>Game</strong> 34<br />

parts. Any attached tile can also provide additional connectors for subsequent tiles,<br />

which can only be attached, after their parent tile has been attached. To limit the degrees<br />

<strong>of</strong> freedom <strong>and</strong> the precision required by the user, each connection between two parts is<br />

represented by two compatible connectors. This way the user has a discrete amount <strong>of</strong><br />

possible positions where a puzzle tile can be attached, leaving only the rotation around<br />

the connector as an stepless degree <strong>of</strong> freedom. Another idea is the introduction <strong>of</strong> particular<br />

patterns on the connectors, which would identify the correct orientation <strong>of</strong> a tile.<br />

However this idea is labeled optional, because tests are needed to verify if it improves<br />

gameplay.<br />

The Primary <strong>Puzzle</strong> Mechanics are detailed enough with these facts, but Assembler<br />

Bay is aimed to be a game with a continuous story <strong>and</strong> an elaborate main character.<br />

A simple row <strong>of</strong> puzzle stages can neither tell a dramatic story nor include an individual<br />

protagonist, because a storyline needs continuous interaction with the character. This<br />

leads to the requirement <strong>of</strong> a continuous level design, which allows the user to identify<br />

with his character <strong>and</strong> spend time with him.<br />

One way to integrate a story into a puzzle game is the implementation <strong>of</strong> cinematic<br />

sequences between stages, which tell a story using cut- scenes, pictures or ingame<br />

animations. An other way is the design <strong>of</strong> freely accessible worlds around the puzzle<br />

stages. If the player can walk around <strong>and</strong> interact freely with the environment, he will<br />

spend more time in direct control <strong>of</strong> the protagonist. This form <strong>of</strong> free interaction helps<br />

the user to identify with the main character <strong>and</strong> promotes the level geometry from<br />

simple background scenery to an active element <strong>of</strong> gameplay. The story can be experienced<br />

in direct interaction with the environment or other characters.<br />

Supplemental Elements are the parts <strong>of</strong> game mechanics, which have a direct<br />

connection to the core element <strong>of</strong> gameplay, but are not included in the Primary <strong>Game</strong><br />

Mechanics. There are several Supplemental Elements in Assembler Bay. The first is the<br />

collection <strong>of</strong> the puzzle tiles, which are scattered throughout the level. The protagonist<br />

has to master several jump <strong>and</strong> run passages <strong>and</strong> gather all tiles at the puzzle stage. The<br />

collection part includes smaller challenges, where certain obstacles have to be cleared<br />

to reach a tile. Examples for these obstacles are closed doors, lowered bridges or inactive<br />

lifts, which have to be activated. An excerpt <strong>of</strong> the draft for a manual to Assembler<br />

Bay, concerning the interaction with the environment using collected puzzle tiles can be<br />

seen in Figure 3.6. The user can use collected tiles to activate unreachable buttons.<br />

Figure 3.6: Excerpt <strong>of</strong> a draft for the Assembler Bay manual


Draft <strong>and</strong> Expectations – Assembler Bay ::: <strong>Game</strong> Mechanics – Concepts for a <strong>3D</strong> <strong>Puzzle</strong> <strong>Game</strong> 35<br />

Secondary <strong>Game</strong> Mechanics are additional features in gameplay, which are not immediately<br />

related to the Primary <strong>Puzzle</strong> Mechanics. Since the team wants to concentrate on<br />

the core gameplay, they are only optional in the design <strong>of</strong> Assembler Bay. As an additional<br />

reward for clearing a level, the user may be able to access an action game sequence,<br />

where he uses an assembled object to reach the next level. This action sequence<br />

should be a simple <strong>and</strong> very fast game <strong>of</strong> reaction in contrast to the calm atmosphere <strong>of</strong><br />

assembling the puzzle. This could be a high speed flying sequence with an assembled<br />

glider through a canyon, or a shoot out with an assembled battle robot. But these elements<br />

are only optional since they are contrary to the idea <strong>of</strong> an unique gameplay, <strong>and</strong><br />

may lead to frustration with certain users, who dislike action games <strong>and</strong> prefer Assembler<br />

Bay because <strong>of</strong> its lack <strong>of</strong> fighting sequences.


<strong>Implementation</strong> ::: <strong>Implementation</strong> 36<br />

4 <strong>Implementation</strong><br />

This chapter will detail the main parts <strong>of</strong> the implementation <strong>of</strong> the features mentioned<br />

in the previous chapters. The first section will depict the implementation <strong>of</strong> the game<br />

engine as a base for Assembler Bay. Included in the game engine is a physics engine,<br />

which provides a good <strong>and</strong> robust simulation <strong>of</strong> physics for the game.<br />

The second <strong>and</strong> third chapter will depict the implementation <strong>of</strong> the graphics engine<br />

for Assembler Bay <strong>and</strong> detail the implementation <strong>of</strong> its two main features – Deferred<br />

Shading <strong>and</strong> Shadow Mapping.<br />

4.1 <strong>Game</strong> Engine – The Core for Assembler Bay<br />

The required features <strong>of</strong> a game engine have been depicted in section 2.1. The subsequent<br />

sections will detail the implementation <strong>of</strong> these features in the form <strong>of</strong> an open<br />

source game engine. The engine developed in this project is titled QuicknEasy Engine<br />

(QEE). The programming language used in this project is C# utilizing XNA libraries.<br />

The Micros<strong>of</strong>t XNA Framework is a game development framework extending the .NET<br />

s<strong>of</strong>tware platform <strong>and</strong> supporting DirectX9 or DirectX10. The use <strong>of</strong> these widely distributed<br />

technologies is preferable, because most hardware will support the interfaces<br />

provided by DirectX9 <strong>and</strong> many hardware specific issues can be ignored.<br />

Although the game was originally planned primary for the XBOX 360, the platform<br />

used for development is a PC running Micros<strong>of</strong>t Windows XP. This decision is<br />

based on the fact that development on the XBOX 360 is paired with several complications.<br />

Micros<strong>of</strong>t restricts development on the XBOX 360 by particular licensing obligations.<br />

Costly accessories <strong>and</strong> special licenses have to be acquired, which would have<br />

been a hindrance for this project. The subsequent sections will detail certain aspects <strong>of</strong><br />

the implementation, which represent important milestones in the development <strong>of</strong> this<br />

project. Many less important details <strong>of</strong> the implementation will not be explained in detail,<br />

as the whole source code for the engine is publicly available.<br />

4.1.1 Engine Structure – Organization is the key<br />

The implementation <strong>of</strong> the mentioned features for a game engine requires a coherent<br />

draft for classes <strong>and</strong> relations. This diagram includes all important classes, which<br />

provide basic functionality for the final game engine. A class diagram with the basic en-


<strong>Implementation</strong> ::: <strong>Game</strong> Engine – The Core for Assembler Bay 37<br />

gine structure <strong>of</strong> QEE 58 can be seen in Figure 4.1. The classes are connected with three<br />

different types <strong>of</strong> arrows to symbolize single references, multiple references <strong>and</strong> inheritance.<br />

This diagram is hierarchically arranged to provide an overview over the control<br />

mechanisms between various classes.<br />

Each class in the diagram is designed to control all classes underneath itself.<br />

Control is an abstract design concept, which will be implemented as initialization, regular<br />

update calls <strong>and</strong> disposal <strong>of</strong> the controlled classes. To organize a game engine in a<br />

hierarchical way has the advantage that every class only needs to manage a particular<br />

subset <strong>of</strong> classes. If all classes are registered as independent game components, which<br />

are updated <strong>and</strong> drawn by the framework engine, an additional structure is needed to<br />

manage groups <strong>of</strong> entities. In contrast to this, a hierarchical engine provides easy methods<br />

to pause or reactivate a whole group <strong>of</strong> entities via its controller.<br />

Figure 4.1: Class Diagram Showing the Basic Structure <strong>of</strong> the game engine<br />

The basic class in this structure is the QEE<strong>Game</strong> class, which holds references to several<br />

instances <strong>of</strong> the Screen class. A Screen represents a certain state <strong>of</strong> the game, like the<br />

main menu or the ingame view <strong>of</strong> the game. The QEE<strong>Game</strong> class also provides a reference<br />

to the InputManager <strong>and</strong> the preferred DirectX graphics device. It can be accessed<br />

by any class in the game via a static attribute referencing the sole active instance.<br />

Each Screen contains a BindingSet, which is promoted to the InputManager, <strong>and</strong><br />

represents a list <strong>of</strong> key bindings which are active as long as the owning Screen is active.<br />

The InputManager stores a list <strong>of</strong> all BindingSets <strong>and</strong> calls the stored call back method<br />

<strong>of</strong> any active key binding if the mapped event occurs. A Screen contains multiple Lay-<br />

58 QEE = QuicknEasy Engine, the game engine developed for Assembler Bay


<strong>Implementation</strong> ::: <strong>Game</strong> Engine – The Core for Assembler Bay 38<br />

ers, each representing a graphical viewport <strong>of</strong> a scene. Every Layer contains a graphics<br />

component which will draw all relevant objects for this Layer in a Scene. All update <strong>and</strong><br />

draw calls by the game engine are forwarded through the hierarchy if all members are<br />

set active respectively visible.<br />

The Scene class is the third component besides the InputManager <strong>and</strong> the<br />

Screen, which is immediately updated by the engine. A Scene controls a collection <strong>of</strong><br />

Entities, which can interact with each other. This represents the collection <strong>of</strong> all objects<br />

in a level or in the whole game world which can possibly interact with each other. A<br />

Scene can be drawn by multiple Layers, but each object can only be present in a single<br />

Scene at a point in time. 2D <strong>and</strong> <strong>3D</strong> objects can be present in the same Scene, including<br />

HUD-Elements <strong>and</strong> for example the ingame character. The renderer <strong>of</strong> each Layer decides<br />

which Entities in the collection should be drawn on this particular Layer.<br />

An Entity can represent any object in a scene, regardless <strong>of</strong> being visible or interacting<br />

with other objects. Two basic classes are derived from the Entity class, which<br />

are Entity2D <strong>and</strong> Entity<strong>3D</strong>. Although most objects can be assigned to one <strong>of</strong> these two<br />

classes, it is possible to add Entities to a scene, which are only derived from the base<br />

class Entity. These are objects, which can neither be assigned to a certain owning Entity,<br />

nor represent <strong>and</strong> object in 2D or <strong>3D</strong> space. In contrast to this Entity2D represents<br />

objects in the 2D screen space <strong>of</strong> the final image. The class includes attributes for position,<br />

scale <strong>and</strong> orientation <strong>of</strong> the object, as well as its velocity <strong>and</strong> angular velocity. This<br />

class is used for HUD-Elements, menus <strong>and</strong> on-screen messages.<br />

Entity<strong>3D</strong> represents an object in the <strong>3D</strong> space <strong>of</strong> the game world. It provides the<br />

<strong>3D</strong> counterparts to the attributes <strong>of</strong> an Entity2D object, as well as a relative velocity <strong>and</strong><br />

a relative angular velocity. These attributes specify velocities relatively to the local<br />

world orientation <strong>of</strong> the object. Although these attributes are not required for some objects<br />

in <strong>3D</strong> space, they are m<strong>and</strong>atory as it simplifies interaction with most objects <strong>and</strong><br />

only produces minimal calculation overhead.<br />

Objects derived from Entity<strong>3D</strong> are the main character, lights, puzzle tiles, the<br />

camera, collision geometry or the level architecture. Because all attributes <strong>of</strong> Entity2D<br />

<strong>and</strong> Entity<strong>3D</strong> are designed to be distinct, it is possible to derive a class from both. This<br />

object can provide a 2D <strong>and</strong> <strong>3D</strong> representation for the same Entity. Each Entity<strong>3D</strong> includes<br />

a List <strong>of</strong> Updater<strong>3D</strong> objects, which are controlled by the Entity <strong>and</strong> provide<br />

modular features for its owner. To control the interaction <strong>of</strong> all Entities participating in<br />

physical reactions, the CollisionManager class is updated by the Scene. It holds reference<br />

to all physics-activated Entities in the scene <strong>and</strong> informs their Physics Updaters <strong>of</strong><br />

any collisions with other objects, before their positions are changed.


<strong>Implementation</strong> ::: <strong>Game</strong> Engine – The Core for Assembler Bay 39<br />

4.1.2 Smooth Skin Animation – Now It Can Walk!<br />

The basics <strong>of</strong> animation are the same for television or video games. A sequence <strong>of</strong><br />

frames with slight variations to each other is displayed with at least 24 fps <strong>and</strong> it is perceived<br />

as animation. Most modern computer displays feature a refresh rate <strong>of</strong> 60Hz<br />

which implies that 60 fps is the desired frame rate for every modern game. Although<br />

higher frame rates are possible, the animation may even deteriorate if the game is running<br />

on a frame rate, which is not a multiple <strong>of</strong> 60fps, since an irregular number <strong>of</strong><br />

frames has to be skipped. Although this part <strong>of</strong> smooth animations depends on performance<br />

<strong>and</strong> the renderer <strong>and</strong> framework architecture, modern animations introduce different<br />

problems. Since the frame rate for an animation is very high <strong>and</strong> not even predetermined<br />

beforeh<strong>and</strong>, animations are specified via keyframes. Concerning <strong>3D</strong> animations a<br />

keyframe specifies the exact position 59 <strong>of</strong> all vertices or bones at a certain point in time.<br />

To get the state <strong>of</strong> this object at a moment not specified by a keyframe, the neighboring<br />

keyframes have to be interpolated to a satisfying result.<br />

Figure 4.2: Various Keyframes from a Jump Animation <strong>of</strong> the Main Character<br />

This blending results in much lower storing costs for <strong>3D</strong> animations, since only a few<br />

keyframes need to be stored instead <strong>of</strong> the whole frame sequence. Three different types<br />

<strong>of</strong> <strong>3D</strong> animations are used in modern games. The first is Morph Target Animation,<br />

which is the most fundamental type. A Morph Target Animation specifies the position<br />

<strong>of</strong> each vertex in a Mesh for every keyframe. The Positions are interpolated between<br />

keyframes <strong>and</strong> result in a smooth animation. Morph Target Animations can be used for<br />

almost every type <strong>of</strong> animation, because each vertex can move independently. But the<br />

downside <strong>of</strong> this high flexibility is the high b<strong>and</strong>width needed for storage <strong>and</strong> transfer <strong>of</strong><br />

the vertex data. If a character model with 100.000 vertices is animated, each frame the<br />

position <strong>of</strong> all those vertices has to be recalculated <strong>and</strong> sent to the rendering pipeline.<br />

59 If bone animation is used, the orientation is the most important feature saved for a certain time


<strong>Implementation</strong> ::: <strong>Game</strong> Engine – The Core for Assembler Bay 40<br />

Because Morph Target Animations have this high b<strong>and</strong>width usage, Bone Animations<br />

are needed for objects with high polygon count. Bone Animations are separated in<br />

two categories: Simple Bone Animations <strong>and</strong> Weighted Bone Animations<br />

A Simple Bone Animation attaches all meshes contained by an object to individual<br />

bones. A bone is an abstract component, which is only represented by a transformation<br />

matrix, but can be visualized using geometry. If a bone is moved, rotated or<br />

scaled, the attached meshes will be transformed respectively. If a mesh only needs to be<br />

transformed with linear transformations, Simple Bone Animation only needs to transfer a<br />

single transformation matrix to the graphics adapter. More complex animations are possible<br />

using Weighted Bone Animation. Each vertex in the mesh is influenced by one or<br />

more bones with different strength. Only the updated bone transformation matrices have<br />

to be transferred to the graphics adapter. Smooth skin animation can be achieved using<br />

minimal b<strong>and</strong>width <strong>and</strong> only a few matrix interpolations for the animated bones.<br />

Because Bone Animations are not suited for complex varying movements like facial<br />

expressions or fluid simulations, a third type <strong>of</strong> <strong>3D</strong> animation covers these cases.<br />

Procedural Animations save animation data using an individual format specialized for<br />

an individual type <strong>of</strong> animation. Facial Expressions can be saved as the cooperation <strong>of</strong><br />

various individual mimic phenomena. Assembler Bay uses only Bone Animation for all<br />

types <strong>of</strong> <strong>3D</strong> animation. Bone Animation requires smooth interpolation, not only between<br />

neighboring keyframes, but also between different animations.<br />

The main character can perform a variety <strong>of</strong> different actions, each requiring its<br />

own animation. Smooth transitions are required between all consequent animations.<br />

This could be realized by adding transitional animations for every possible combination<br />

<strong>of</strong> subsequent animations. This would result in a high number <strong>of</strong> animations, which can<br />

also be calculated at runtime. Smooth interpolation between neighboring keyframes can<br />

be adapted to interpolate subsequent animations. These interpolated transformation<br />

matrices have to be calculated for every bone <strong>and</strong> sent to the graphics adapter.<br />

Every keyframe contains transformation matrices only for bones, which move in<br />

this particular frame. These matrices have to be blended with the matrices <strong>of</strong> the following<br />

keyframe. But linear interpolation between transformation matrices results in unwanted<br />

artifacts, as the blending between two matrices containing rotational <strong>and</strong> translational<br />

components may introduce deformation 60 . To deal with this problem, the matrices<br />

are decomposed into scale, rotation <strong>and</strong> translation <strong>and</strong> each component is interpolated<br />

individually. Additionally the interpolation between animations is done in a way that<br />

both animations keep playing while gradually being interpolated.<br />

60 Deformation refers to non uniform scaling or unwanted scaling <strong>of</strong> certain parts <strong>of</strong> an object.


<strong>Implementation</strong> ::: <strong>Game</strong> Engine – The Core for Assembler Bay 41<br />

// For all Bones attached to a mesh<br />

for (int i = 0; i < BoneCount; i++)<br />

{<br />

// The blendamount is a value between 0 <strong>and</strong> 1 indicating<br />

// the relative time position between the two frames<br />

if (!nextframe.HasTransform(i) || blendamount == 0)<br />

{<br />

// If the next frame does not specify a new matrix, keep the active matrix<br />

boneTransforms[i] = lastKeyTransforms[i];<br />

}<br />

else if (blendamount == 1)<br />

{<br />

boneTransforms[i] = nextframe.GetTransform(i);<br />

}<br />

else<br />

{<br />

Vector3 scale, scale2, trans, trans2;<br />

Quaternion rot, rot2;<br />

}<br />

}<br />

// Both matrices are decomposed into their scale|rotation|translation parts<br />

lastKeyTransforms[i].Decompose(out scale, out rot, out trans);<br />

nextframe.GetTransform(i).Decompose(out scale2, out rot2, out trans2);<br />

// All parts are interpolated individually <strong>and</strong> composed to the final matrix<br />

boneTransforms[i] =<br />

Matrix.CreateScale(Vector3.SmoothStep(scale, scale2, blendamount)) *<br />

Matrix.CreateFromQuaternion(Quaternion.Slerp(rot, rot2, blendamount)) *<br />

Matrix.CreateTranslation(Vector3.SmoothStep(trans, trans2, blendamount));<br />

Code Segment 4.1: SkinnedModel.AnimationPlayer : line 178-198 (commented)<br />

4.2 Physics Engine – Collisions <strong>and</strong> Reactions<br />

As depicted in section 2.3.1 the first important step for every physics engine is collision<br />

detection. This can be done via various bounding volumes or per polygon <strong>and</strong> needs <strong>3D</strong><br />

space partitioning algorithms for complex scenes. Different methods <strong>of</strong> space partitioning<br />

are available <strong>and</strong> each suits a certain need. The key in finding the right space partitioning<br />

for a game is to analyze the level architecture <strong>and</strong> possible locations <strong>of</strong> objects<br />

to each other. A space flight game for example takes place in a widespread space, where<br />

only a few objects fly around -collision detection is only needed when two objects are<br />

somewhat close to each other. Jump <strong>and</strong> Run games on the other h<strong>and</strong> are usually quite<br />

one dimensional in their level design, which means a single axis is sufficient for space<br />

partitioning. The deciding factor is the distribution <strong>of</strong> objects in the level.<br />

Most <strong>3D</strong> games will need at least two axes for space partitioning, because the<br />

level spreads across a big l<strong>and</strong>scape, but the vertical position <strong>of</strong> objects is usually within<br />

a certain smaller range. Space partitioning can be applied for the objects in a scene, but<br />

also for the polygons in a mesh. Both methods are required depending on the game <strong>and</strong><br />

in most cases both are used independently.


<strong>Implementation</strong> ::: Physics Engine – Collisions <strong>and</strong> Reactions 42<br />

4.2.1 Binary Space Partitioning – Divide <strong>and</strong> Conquer<br />

Since Assembler Bay is designed for small indoor levels, global space partitioning<br />

would not be <strong>of</strong> much use. The whole level geometry is a single entity in the game,<br />

which results in all objects being inside the collision range <strong>of</strong> the level at all times. Instead<br />

<strong>of</strong> implementing a complex space partitioning for objects, all moving objects are<br />

tested if they are within range <strong>of</strong> another objects bounding sphere. The complex part is<br />

the per polygon collision detection, if the first test is positive. The available possibilities<br />

include oct-trees <strong>and</strong> kd-trees 61 . An oct-tree separates the space into 8 cuboid volumes<br />

with the same size. Each <strong>of</strong> these volumes containing more than one polygon will again<br />

be divided in 8 cuboids. Although the generation <strong>of</strong> an oct-tree is very simple, it is not<br />

very efficient, because the space is evenly divided by size, regardless <strong>of</strong> how many<br />

polygons are in each part. Another downside is the possibility <strong>of</strong> many polygons being<br />

in more than one cuboid, which makes the tree redundant. An example for the drawbacks<br />

<strong>of</strong> oct-trees can be seen on the basis <strong>of</strong> a quad-tree in Figure 4.3.<br />

Figure 4.3: Quad-tree is redundant <strong>and</strong> very unbalanced when objects are grouped<br />

In contrast to oct-trees, kd-trees are a bit more complex to generate, but can guarantee<br />

an optimal balanced tree for any arrangement <strong>of</strong> objects. An kd-tree sorts vectors by using<br />

one <strong>of</strong> their dimensions depending on the level <strong>of</strong> the tree. QEE uses 3-dimensional<br />

binary trees for space partitioning. Each level <strong>of</strong> the tree splits the remaining volume in<br />

two, leaving half <strong>of</strong> the remaining points on either side. This split plane is normal to the<br />

X-axis at the root <strong>of</strong> the kd-tree. Mathematically all vectors are sorted by their X-coordinate<br />

values <strong>and</strong> the vector with the median X-value is attached to the root, the lower<br />

half <strong>of</strong> the remaining vectors is forwarded to the left child node <strong>and</strong> the other half to the<br />

61 kd-tree st<strong>and</strong>s for a k dimensional tree (in most cases a 3-dimensional binary tree)


<strong>Implementation</strong> ::: Physics Engine – Collisions <strong>and</strong> Reactions 43<br />

right child node. On the next level the procedure is repeated for the Y-coordinates, following<br />

the Z-coordinates in the third level. The fourth level again uses the X-coordinate,<br />

repeating the cycle until an empty node is reached <strong>and</strong> the vector can be inserted.<br />

If the kd-tree is generated or updated at runtime, sorting all objects for each node<br />

in the tree is too expensive 62 . This results in the use <strong>of</strong> an either unbalanced or static kdtree.<br />

Since Assembler Bay uses Simple Bone Animation for most objects, a static kdtree<br />

can be generated at build time for every mesh. The only object with Weighted Bone<br />

Animation is the main character, which can not use a kd-tree for per polygon collision<br />

detection, since the positions <strong>of</strong> the vertices change based on the bone animation.<br />

However a per polygon collision detection for a moving character is not desirable anyways,<br />

since jump <strong>and</strong> run elements work much better with collision geometry. Another<br />

drawback <strong>of</strong> the runtime generation <strong>of</strong> BSP-trees for bone animated meshes, is the calculation<br />

<strong>of</strong> the resulting vertex positions. Space partitioning operations are usually calculated<br />

on the CPU, whereas the skinning <strong>of</strong> meshes using Weighted Bone Animation is<br />

calculated solely on the GPU, saving many CPU cycles. The implementation <strong>of</strong> the<br />

build time generation <strong>of</strong> a kd-tree can be seen below.<br />

// index <strong>and</strong> count specify the part <strong>of</strong> the Array, which is relevant for this branch<br />

public static KDTree CreateFromPolyArray(Poly3[] Polys, int index, int count, int depth)<br />

{<br />

// xyz indicates the coordinate which is used on this level <strong>of</strong> the tree<br />

int xyz = depth % 3;<br />

}<br />

// If only a single node remains, recursion ends <strong>and</strong> the leaf is returned<br />

if (count == 1) return new KDTree(Polys[index], depth);<br />

// The relevant part <strong>of</strong> the Array is sorted by the active coordinate<br />

if (xyz == 0) Array.Sort(Polys, index, count, PolyCompareX);<br />

else if (xyz == 1) Array.Sort(Polys, index, count, PolyCompareY);<br />

else Array.Sort(Polys, index, count, PolyCompareZ);<br />

int center = index + count/2;<br />

int odd = count % 2 – 1;<br />

KDTree tree = new KDTree(Polys[center], depth);<br />

/// 17 lines <strong>of</strong> code skipped ///<br />

// Left <strong>and</strong> right branches are recursively generated if needed<br />

tree.LeftChild = CreateFromPolys(Polys, index, count/2, depth + 1);<br />

if (count > 2)<br />

{<br />

tree.RightChild =<br />

CreateFromPolys(Polys, center + 1, count / 2 + odd, depth + 1);<br />

}<br />

return tree;<br />

Code Segment 4.2: KDModelPipeLine.KDTree : line 47-77 (commented)<br />

62 Calculation complexity: sorting � O �n⋅log�n�� ⇒ for each node� O � n 2 ⋅log �n��


<strong>Implementation</strong> ::: Physics Engine – Collisions <strong>and</strong> Reactions 44<br />

Using this Space partitioning, collisions can be detected by bounding box queries on the<br />

kd-trees <strong>of</strong> both objects. The bounding box <strong>of</strong> the first object is used in a volume query<br />

on the kd-tree <strong>of</strong> the second object, which returns a bounding box for all polygons <strong>of</strong> the<br />

second object which intersect with the bounding box <strong>of</strong> the first object. Using this smaller<br />

volume, the query is repeated on the first object, resulting in an even smaller bounding<br />

box. The remaining bounding volume is used in a query on both kd-trees to get all<br />

polygons which are possibly intersecting. If at any step <strong>of</strong> this process a qurey returns<br />

null, no collision can occur <strong>and</strong> the path returns without further processing. The process<br />

<strong>of</strong> narrowing down bounding volumes is visualized in Figure 4.4.<br />

Figure 4.4: Per Polygon Collision Detection Using Bounding Box Queries<br />

4.2.2 Physics Calculations – Let It Bounce!<br />

If Collision Detection returns positive, the Physics Updater component <strong>of</strong> both colliding<br />

objects is called by the Collision Manager. The Physics Updater <strong>of</strong> each object h<strong>and</strong>les<br />

the reactions resulting from the collision. If two objects intersect with more than one<br />

polygon, the Physics Updaters are called multiple times, once for each collision to produce<br />

an adequate reaction. Most objects in the game use the same Physics Updater, they<br />

are assigned a mass <strong>and</strong> a coefficient <strong>of</strong> restitution <strong>and</strong> their reactions on collisions are<br />

calculated using simple Newton Physics. Exceptions from this general h<strong>and</strong>ling are static<br />

level geometry, which does not possess a Physics Updater <strong>and</strong> is treated as not movable<br />

by other objects, <strong>and</strong> the Character, which reacts different on collisions, since he<br />

represents an acting entity.


<strong>Implementation</strong> ::: Physics Engine – Collisions <strong>and</strong> Reactions 45<br />

A special case is the h<strong>and</strong>ling <strong>of</strong> very low velocity collisions, which require special<br />

attention, because they can severely deteriorate performance. Most objects in the<br />

game have a coefficient <strong>of</strong> restitution below one 63 <strong>and</strong> will become slower after time.<br />

After a short time most objects will lie on the floor, accelerated by gravity <strong>and</strong> immediately<br />

repelled by the floor with very small velocity. This results in a high number <strong>of</strong> collision<br />

h<strong>and</strong>ling, without much movements. To improve performance, these objects are<br />

detected by their low velocities <strong>and</strong> normal <strong>of</strong> the colliding surface (which has to face<br />

down, if the object is lying on the floor) These objects are marked <strong>and</strong> gradually moved<br />

away from the colliding surface with low velocity until they do not touch the floor anymore.<br />

// The partner has to be marked as static<br />

if (CPartner.Bounds<strong>3D</strong>.Moving == Boundings<strong>3D</strong>.MovingModes.Still<br />

// The surface normals have to point up respectively down<br />

&& Vector3.Dot(CNormal,Vector3.Up) > 0.8f<br />

&& Vector3.Dot(CenterDist, Vector3.Up) > 0<br />

// The velocity <strong>and</strong> angular velocity have to be very low already<br />

&& Owner.Speed<strong>3D</strong>.Length() < (Bounce / 0.4f) + 0.01f<br />

&& Math.Abs(Math.Acos(Owner.Rotation<strong>3D</strong>.W)) < Bounce * 10 + 0.5f)<br />

{<br />

Owner.RotationSpeed<strong>3D</strong> = Quaternion.Identity;<br />

Owner.Speed<strong>3D</strong> = Vector3.Zero;<br />

// The object is moved slightly away from its collision partner<br />

Owner.Position<strong>3D</strong> += CNormal * radius / 1000;<br />

Marked = true;<br />

}<br />

Code Segment 4.3: QuicknEasyEngine.PhysicsUpdater<strong>3D</strong> : line 68-76 (commented)<br />

Although this code fixes the performance problems <strong>and</strong> other glitches resulting from<br />

low velocity collisions, it introduces some new problems. One <strong>of</strong> these problems is the<br />

balance <strong>of</strong> objects. Although an object is barely moving <strong>and</strong> colliding with the ground at<br />

certain points, this information is not sufficient to label the object static. A Cube could<br />

collide only with one edge on the ground, the anticipated reaction for the cube would be<br />

to fall over <strong>and</strong> l<strong>and</strong> on one side. To achieve this effect, the position <strong>of</strong> all occurring collisions<br />

for an object are saved in a list <strong>and</strong> forwarded to the Physics Updater. The relative<br />

position <strong>of</strong> these points to the center <strong>of</strong> gravity <strong>of</strong> the object is calculated <strong>and</strong> compared.<br />

If a plane can be found passing through the center <strong>of</strong> gravity with all points on<br />

one side <strong>of</strong> this plane, the object is not lying stable. If this case is encountered the object<br />

receives torque in the direction missing collision points.<br />

63 The coefficient <strong>of</strong> restitution is a number indicating how much an object is repelled by another object,<br />

in reality this number is limited between 0 <strong>and</strong> 1 (e.g. a chunk <strong>of</strong> butter would have a small value, as it<br />

sticks to the floor when dropped, whereas a rubber ball would have a high value)


<strong>Implementation</strong> ::: Physics Engine – Collisions <strong>and</strong> Reactions 46<br />

4.2.3 Animated Objects – Neither Moving Nor Static<br />

The second problem introduced by the marking <strong>of</strong> static objects is caused by animations.<br />

Since a big entity like the whole level geometry can be partially animated, marking<br />

the whole object as static can result in objects floating in midair or passing through<br />

each other, because the Collision Manager ignores static objects. To deal with this, the<br />

whole Level geometry could be separated in individual entities for all meshes. But this<br />

would increase scene complexity <strong>and</strong> difficulties when debugging the game. The approach<br />

taken for QEE is the assignment <strong>of</strong> a Marker Array for each animated object.<br />

The Marker Array saves the animation state <strong>of</strong> each mesh in the object. This introduces<br />

a new object state for physics, in addition to moving <strong>and</strong> static, which is animated. If an<br />

object is animated some <strong>of</strong> its meshes can be treated as static, while others have to be<br />

processed as moving. The Animation Updater <strong>of</strong> an object saves this information in the<br />

Marker Array, which is evaluated by the Collision Manager.<br />

Because performance can still break down under particular circumstances, an additional<br />

measure is implemented in the Collision Manager. If the number <strong>of</strong> polygons<br />

encountered after the final tree queries is too high, a certain number <strong>of</strong> polygons is<br />

skipped in collision h<strong>and</strong>ling. Because the list <strong>of</strong> polygons resulting from a kd-tree<br />

query is localized 64 , skipping adjacent polygons will most likely result in skipping redundant<br />

collision h<strong>and</strong>ling. For most polygons in a mesh, collision h<strong>and</strong>ling <strong>of</strong> neighboring<br />

polygons will result in a similar effect. If only one <strong>of</strong> these polygons is processed,<br />

the resulting reaction will not differ much.<br />

4.3 Deferred Shading – The Visual Part <strong>of</strong> QEE<br />

As depicted in section 2.2.3 Assembler Bay tries to create an unique look using Deferred<br />

Shading as a basis. The first important decision to take when choosing Deferred<br />

Shading, is the format <strong>and</strong> distribution <strong>of</strong> attributes in the Geometry-Buffer. The Geometry-Buffer<br />

usually consists <strong>of</strong> multiple Render Targets, which store all necessary information<br />

for lighting <strong>and</strong> post processing. Although the most simple way would be the<br />

storage <strong>of</strong> all attributes in the needed format in a single <strong>of</strong>f-screen surface, which would<br />

have to support a range <strong>of</strong> different values. However current Direct<strong>3D</strong> compatible hardware<br />

is limited to particular surface formats. Subsequently the G-Buffer 65 has to be simulated<br />

by multiple <strong>of</strong>f screen surface Render Targets. Since many <strong>of</strong> the possible surface<br />

formats are not supported by various graphics adapters, it is best to choose only from<br />

the most widely supported formats (ref. [VAL07]).<br />

64 In a list received from a kd-tree query, polygons which are spatially close are also close in the list<br />

65 Geometry-Buffer


<strong>Implementation</strong> ::: Deferred Shading – The Visual Part <strong>of</strong> QEE 47<br />

4.3.1 Surface Formats – Compatibility <strong>and</strong> Storage<br />

When using multiple Render Targets the scene would have to be rendered multiple<br />

times to all different surfaces. This would result in a severe loss <strong>of</strong> performance, since<br />

the scene geometry would have to be processed multiple times, although the whole G-<br />

Buffer uses the same geometry calculations. To keep up with this, most modern graphics<br />

adapters support drawing to multiple Render Targets in a single draw call. Although<br />

these surfaces may have a different format, all require to have the same bit-depth. The<br />

usual format for textures is 32 bit Color, but newer hardware also supports rendering to<br />

64 or 128 bit Render Targets. A maximum <strong>of</strong> 4 simultaneous Render Targets is the limit<br />

for many graphic adapters. Since 128 bit textures are still a new feature with poor performance,<br />

the available space in the G-Buffer are either four 32 or four 64 bit Render<br />

Targets. Whereas the 32 bit Render Targets operate at higher performance.<br />

The relevant Render Target formats for the PC <strong>and</strong> the XBOX 360 are listed in<br />

Figure 4.5. Relevant are all formats supported by PC <strong>and</strong> XBOX 360, providing a surface<br />

format, which is neither included nor analog to another surface format. These surface<br />

formats can be combined to store all required attributes in the G-Buffer. 66<br />

Surface<br />

Format<br />

bitdepth<br />

Red<br />

Channel<br />

Green<br />

Channel<br />

Blue<br />

Channel<br />

Alpha<br />

Channel<br />

Color 32 bit 8-bit unsigned 8-bit unsigned 8-bit unsigned 8-bit unsigned<br />

Single 32 bit 32-bit IEEE format<br />

HalfVector2 32 bit 16-bit floating point 16-bit floating point<br />

10-10-10-2 32 bit 10-bit float. point 10-bit float. point 10-bit float. point 2-bit<br />

Vector2 64 bit 32-bit IEEE format 32-bit IEEE format<br />

HalfVector4 64 bit 16-bit float. 16-bit float. 16-bit float. 16-bit float.<br />

Figure 4.5: Relevant Surface Formats for Direct X Hardware<br />

These register formats provide a different range <strong>of</strong> possible values, depending on their<br />

bit-depth. An 8-bit unsigned normalized integer maps 2^8 = 256 possible values onto<br />

the range from 0 to 1 resulting in a very poor precision, which may be used for colors.<br />

The 32-bit IEEE format provides storage for a full float value, <strong>of</strong> the same type which<br />

is used for storage in the underlying computer language C#. The 16-bit floating point<br />

register maps 2^16 = 65,536 values onto the range from 0 to 1, which provides excellent<br />

precision for normalized values like surface normal coordinates. The 10-bit floating<br />

point register maps 2^10 = 1024 values onto the range from 0 to 1, which provides a<br />

66 Information on the XBOX 360 Render Targets from [ http://msdn.micros<strong>of</strong>t.com/en-us/library/ ]


<strong>Implementation</strong> ::: Deferred Shading – The Visual Part <strong>of</strong> QEE 48<br />

compromise between 8 <strong>and</strong> 16-bit registers, allowing the storage <strong>of</strong> e.g. 3 surface normal<br />

components in a single surface. The 2-bit register maps 4 values onto the range<br />

from 0 to 1, which is only useful for certain flags like the type <strong>of</strong> a surface.<br />

Multiple attributes can be calculated in the first draw call <strong>and</strong> may be saved in<br />

the G-Buffer. Some attributes are required for lighting calculations, but others are optional<br />

for the use in post processing effects, or complex material shaders. Since the<br />

available capacity <strong>of</strong> the Render Targets is limited, only important attributes will be<br />

saved. The attributes can be stored in different formats. The world position <strong>of</strong> an object<br />

can also be recalculated by its depth <strong>and</strong> screen space position. All these attributes are<br />

stored per pixel at the position <strong>of</strong> the color pixel in the final image.<br />

4.3.2 Geometry-Buffer Attributes – Precision <strong>and</strong> Performance<br />

The following list will include all important attributes for QEE, including storage requirements<br />

for each type. Each type <strong>of</strong> storage has benefits <strong>and</strong> drawbacks in the fields<br />

<strong>of</strong> performance <strong>and</strong> precision. Performance depends on the number <strong>of</strong> operations<br />

needed to transform an attribute into the format required for calculations. The world position<br />

can be saved as the depth <strong>of</strong> an object, but this value has to be projected into<br />

space using its screen position <strong>and</strong> the matrices. If the world position is stored as a three<br />

component vector with the world coordinates, no extra calculations have to be done.<br />

Precision is the other factor. A surface normal vector can be stored with three 8<br />

bit registers, but it has to be normalized in the 0 to 1 range, leaving only 128 different<br />

values for the normal direction on a particular axis. This can result in visible lines on the<br />

surface <strong>of</strong> big curved objects, as the available colors allow for more precision than the<br />

normal directions can provide. Using a 16-bit register for each component <strong>of</strong> the normal<br />

vector results in optimal precision <strong>and</strong> improved image quality, but it requires twice as<br />

much storage capacity. The attributes marked with asterisk in the following list are required<br />

for basic Blinn lighting calculations.<br />

A list <strong>of</strong> attributes for storage in the G-Buffer:<br />

• Diffuse Color* (3x 8-bit or 3x 16-bit for HDRR)<br />

• World Position* (32-bit depth-value or as 3x 32-bit vector)<br />

• Normal Direction* (3x 8-bit, 3x 10-bit or 3x 32-bit)<br />

• Specular Intensity* (2-bit, 8-bit, 10-bit or 16-bit)<br />

• Specular Power* (2-bit, 8-bit, 10-bit or 16-bit)<br />

• Glow Color (2-bit, 8-bit, 3x 8-bit or 3x 32-bit color)<br />

• 2D Velocity (2x 8-bit or 2x16-bit)<br />

• Bloom Color (2-bit, 8bit, 3x 8-bit or 3x 32-bit color)


<strong>Implementation</strong> ::: Deferred Shading – The Visual Part <strong>of</strong> QEE 49<br />

Since the graphic features which require the last three attributes are optional in this project,<br />

the Geometry-Buffer will be designed for the five required attributes. The Color <strong>of</strong><br />

an object will always suffice with three 8-bit registers in this project, since no HDR textures<br />

are used. The world position is stored in a single depth channel, since the only alternative<br />

with acceptable quality would require three whole 32-bit render targets or at<br />

least two 64-bit render targets. The additional processing time resulting from calculating<br />

the world coordinates is much lower compared to the use <strong>of</strong> 64-bit Render Targets.<br />

Specular Intensity is a number in the range <strong>of</strong> 0 to 1, representing how much a<br />

surface reflects the light. Specular Power is a positive integer representing the collimating<br />

<strong>of</strong> this reflected light. Both require no more precision than an 8-bit register each.<br />

The normal direction has higher requirements, but the artifacts resulting from the usage<br />

<strong>of</strong> 8-bit registers for normals are barely noticeable in the game. Wasting 64-bit render<br />

targets on all other attributes would result in severe processing overhead.<br />

4.3.3 The Final G-Buffer Layout – Performance Takes the Lead<br />

The author decided for the higher performance <strong>and</strong> compatibility, using the layout in<br />

Figure 4.6. This buffer stores all required values in three 32-bit Render Targets, which<br />

provide best performance. The two Surface Types Color <strong>and</strong> Single are the two basic<br />

<strong>and</strong> most supported Render Target formats, since usually images are rendered to a Color<br />

Surface, using a 32-bit Single or 24-bit depth buffer. The fourth register is an optional<br />

surface for further development <strong>of</strong> this project <strong>and</strong> will support additional effects. This<br />

fourth Render Target is not yet implemented to save memory b<strong>and</strong>width.<br />

# Format Red Green Blue Alpha<br />

1 Color Diffuse R Diffuse G Diffuse B S. Intensity<br />

2 Color Normal X Normal Y Normal Z S. Power<br />

3 Single 32-bit Depth Value<br />

4 Color Glow R Glow G Glow B Bloom<br />

Figure 4.6: Geometry-Buffer Configuration for QEE<br />

The Deferred Renderer renders the whole solid scene geometry to this three buffers in a<br />

single draw call. The second draw call renders the remaining transparent geometry to<br />

the Color Buffer only, using the active depth buffer. The second draw call uses traditional<br />

shading, providing lighting for the three most important lights on transparent geometry.<br />

The Geometry Buffer is now filled with all required information <strong>and</strong> all lighting<br />

calculation can be applied per pixel like any post processing effect.


<strong>Implementation</strong> ::: Deferred Shading – The Visual Part <strong>of</strong> QEE 50<br />

A drawback <strong>of</strong> this technique is the inability to use MSAA 67 with multiple<br />

Render Targets on DirectX 9 hardware. MSAA is a feature, which severely improves image<br />

quality <strong>and</strong> is supported by most major titles. However even some commercial state<br />

<strong>of</strong> the art titles lack support for MSAA, because they use Deferred Shading. This is a<br />

downside <strong>of</strong> Deferred Shading, as many users with expensive hardware dem<strong>and</strong> the improved<br />

image quality <strong>of</strong> MSAA. One option would be the use <strong>of</strong> a single Render Target<br />

for each draw call, resulting in three draw calls for the G-Buffer creation. But a compromise<br />

is to outsource rendering <strong>of</strong> the Color Buffer into a separate draw call. This will<br />

result in degraded performance, because scene geometry has to be processed a second<br />

time. But since MSAA always has an impact on performance, being an optional feature<br />

for better hardware, this can be accepted.<br />

4.3.4 <strong>Implementation</strong> <strong>of</strong> Deferred Lights<br />

A light in a scene drawn with Deferred Shading is just a special type <strong>of</strong> a per pixel post<br />

processing effect. All required parameters to light a surface are stored in the G-Buffer at<br />

the position <strong>of</strong> each pixel. The resulting colors <strong>of</strong> each light are stored in an Accumulation<br />

Buffer, which gathers the shading <strong>of</strong> all lights <strong>and</strong> combines it in a final full screen<br />

processing with the Color Buffer. The Accumulation Buffer is used, because the added<br />

values for the brightness <strong>of</strong> each light could surpass the maximum value which can be<br />

saved in a buffer, turning the pixel completely white. However this effect is only wanted<br />

for specular highlights, but not for the diffuse component <strong>of</strong> the lights. For this reason<br />

the Accumulation Buffer uses two surfaces to save separate values for diffuse <strong>and</strong> specular<br />

light. In the final draw, the diffuse component is added to the ambient light in the<br />

scene <strong>and</strong> clamped in the range [0;1]. This value is multiplied with the color read from<br />

the Color Buffer <strong>and</strong> added to the value in the Specular Buffer.<br />

The lighting calculations in the Pixel Shader <strong>of</strong> each light type are processed like<br />

the st<strong>and</strong>ard Blinn-Phong lighting. The only difference is the source <strong>of</strong> the parameters,<br />

which are unpacked from the Geometry-Buffer instead <strong>of</strong> being read from the Vertex<br />

Buffer. Most lights have additional parameters like Near Attenuation, Far Attenuation,<br />

Hot-Spot <strong>and</strong> Fall<strong>of</strong>f. The effect <strong>of</strong> these parameters, as well as the effect <strong>of</strong> shadow calculations<br />

is applied to the resulting intensities. These intensities are finally multiplied<br />

with the light color <strong>and</strong> saved in the Accumulation Buffer. Each light type has an individual<br />

Pixel Shader for these calculations. An excerpt <strong>of</strong> the Sunlight Pixel Shader featuring<br />

all <strong>of</strong> the mentioned details is pasted on the next page:<br />

67 Multi Sample Anti Aliasing – A technique which improves image quality by using multiple samples<br />

for each pixel


<strong>Implementation</strong> ::: Deferred Shading – The Visual Part <strong>of</strong> QEE 51<br />

PixelShaderOutput LightMap(VertexShaderOutput input)<br />

{<br />

PixelShaderOutput output = (PixelShaderOutput)0;<br />

}<br />

// Unpack Normals<br />

float4 normalData = tex2D(normalSampler, input.TexCoord);<br />

float3 Normal = 2.0f * normalData.xyz - 1;<br />

// Unpack Specular Power & Intensity<br />

float specularIntensity = tex2D(colorSampler, input.TexCoord).w;<br />

float specularPower = normalData.w * 255;<br />

// Unpack Depth <strong>and</strong> recalculate World Position from Depth<br />

float depthVal = tex2D(depthSampler,input.TexCoord).r;<br />

float4 position;<br />

position.x = input.TexCoord.x * 2.0f - 1;<br />

position.y = -(input.TexCoord.y * 2.0f - 1);<br />

position.z = depthVal;<br />

position.w = 1.0f;<br />

position = mul(position, InvertedProjection);<br />

position /= position.w;<br />

// Calculate Diffuse Intensity from Light- <strong>and</strong> Normal Direction<br />

float diffuse = saturate(dot(-LightDirection, Normal));<br />

// Calculate Phong components per-pixel<br />

float3 reflectionVector = normalize(reflect(LightDirection, Normal));<br />

float3 directionToCamera = normalize(CameraPosition - position.xyz);<br />

float specular = specularIntensity<br />

* pow(saturate(dot(reflectionVector, directionToCamera)), specularPower);<br />

if (ShadowsActive) /// Skipped 23 lines <strong>of</strong> code for shadow mapping<br />

// Diffuse Lightcolor <strong>and</strong> Specular Color are saved in the Accumulation Buffer<br />

output.Color = float4(LightColor * saturate(diffuse) * lightscale, 0);<br />

output.Specular = float4(LightColor * saturate(specular) * lightscale, 0);<br />

return output;<br />

Code Segment 4.4: QuicknEasyEngine.Content.Shader.SunLight.fx : line 101-177 (commented)<br />

One requirement for the graphics component <strong>of</strong> QEE is the compatibility with<br />

PixelShader 2.0, because the limitations <strong>of</strong> this revisions benefit the most from the features<br />

<strong>of</strong> Deferred Shading <strong>and</strong> it is supported by the widest range <strong>of</strong> graphics adapters<br />

<strong>and</strong> s<strong>of</strong>tware. But to deal with the limitations <strong>of</strong> PixelShader 2.0 more complex light<br />

sources had to use the less complex Blinn-Phong lighting model. As for Shadow Mapping<br />

all components calculating shadows had to be sourced out into individual Shaders.<br />

Although this results in the need <strong>of</strong> more draw calls per frame, the overall performance<br />

will be scalable by the number <strong>and</strong> size <strong>of</strong> active light sources <strong>and</strong> shadow resolution.


<strong>Implementation</strong> ::: Deferred Shading – The Visual Part <strong>of</strong> QEE 52<br />

4.3.5 Stencil Buffer Light Volumes – Less Pixels More Performance<br />

The performance <strong>of</strong> rendering lights can be further improved by narrowing down the affected<br />

area for each light. Because a light is applied as a Pixel Shader post processing<br />

effect, the performance can be increased by processing a smaller amount <strong>of</strong> pixels. Each<br />

light source can be represented by a bounding volume, which encloses every part <strong>of</strong> the<br />

scene, which is directly lit by this light source. A spotlight can be represented by a pyramid<br />

or a cone, depending on the projected shape. Whereas a directional light can be<br />

enclosed by a cylinder or cuboid. If the bounding volume <strong>of</strong> a light source is rendered,<br />

using the same viewport as the scene geometry, only possible lit pixels will be processed<br />

by the Pixel Shader. But there are still many pixels being processed, which are<br />

not affected by the light, because they are either in front or behind the bounding<br />

volume. The Depth Buffer <strong>and</strong> the Stencil Buffer can be used to exclude these pixels<br />

when drawing the bounding volume. The Depth Buffer holds the information about the<br />

distance <strong>of</strong> every pixel to the camera. The only pixels affected by the light source are<br />

those, which lie inside the bounding volume. These are pixels which have a depth value<br />

greater than the front-facing 68 <strong>and</strong> smaller than the back-facing polygon <strong>of</strong> the bounding<br />

volume at that position.<br />

The Stencil Buffer can be used to mark pixels when drawing polygons. To affect<br />

only pixel which are inside the bounding volume, two draw calls are needed. The Stencil<br />

Buffer is cleared to zero beforeh<strong>and</strong>. The first draw call is a stencil write only call,<br />

drawing only the front-facing polygons. The depth value <strong>of</strong> every rastered pixel is compared<br />

to its corresponding value stored in the Depth Buffer. If the stored value is lower<br />

than the new value, the Stencil Buffer is set to one at this position. The second draw call<br />

uses the Pixel Shader <strong>of</strong> the light to write to the Accumulation Buffer, but each pixel is<br />

tested against its corresponding values stored in the Depth <strong>and</strong> Stencil Buffer. Only<br />

pixels with a stencil value <strong>of</strong> one <strong>and</strong> a new depth value smaller than the stored one are<br />

processed by the Pixel Shader. This process is visualized in Figure 4.7.<br />

Using bounding volumes for light rendering reduces fill-rate costs 69 immensely. Because<br />

the size <strong>of</strong> the light volume in the final image is proportional to the number <strong>of</strong><br />

pixels processed for this light, small lights will only need small drawing costs. This<br />

means many small lights (e.g. in an outdoor night scene) will require about the same<br />

amount <strong>of</strong> processing time as one full screen light, like the sun does. This is a huge difference<br />

to traditional forward rendering, as the design team <strong>of</strong> Assembler Bay will be<br />

free to place a great number <strong>of</strong> small lights in a scene to create atmospheric lighting,<br />

which would not be possible without Deferred Shading.<br />

But using the bounding volume <strong>of</strong> the light as a way to improve performance<br />

only works, if these bounding volumes are scaled properly when placed in the level.<br />

68 Front-facing polygons have surface normals which point towards the camera<br />

69 Fill-rate costs refer to the time needed by the Pixel Shader units to draw a certain amount <strong>of</strong> pixels


<strong>Implementation</strong> ::: Deferred Shading – The Visual Part <strong>of</strong> QEE 53<br />

Figure 4.7: Using Light Volumes <strong>and</strong> the Stencil Buffer to Exclude Pixels<br />

The far plane <strong>of</strong> each light should be set to a reasonable amount, as small as possible to<br />

reduce overdrawing <strong>and</strong> avoid the light volume being clipped by the camera far plane.<br />

4.4 Dynamic Shadows – Light Comes With Darkness<br />

As depicted in section 3.2.4 dynamic shadows are a required feature for every modern<br />

<strong>3D</strong>-Engine. Assembler Bay will use Shadow Mapping in favor <strong>of</strong> Stencil Shadow<br />

Volumes, because Shadow Maps are independent <strong>of</strong> geometry <strong>and</strong> will scale flawless to<br />

any kind <strong>of</strong> scene geometry. Since Shadow Mapping renders the scene to a bitmap, it is<br />

not only independent from object geometry, but it also natively supports alpha textures.<br />

Even semi transparent shadows can be applied using Shadow Mapping, but with restrictions<br />

similar to Deferred Shading. Because a single bitmap is used to store depth information,<br />

only a single object can cast a shadow along a straight line from the light<br />

source. If a transparent object is in front <strong>of</strong> another occluder, only the transparent shadow<br />

or the solid shadow can be cast on both objects, since they are represented by the<br />

same pixels in the shadow map. Because the technologies used by Shadow Mapping are<br />

similar to Deferred Shading, the two require similar hardware capabilities <strong>and</strong> hence<br />

pr<strong>of</strong>it from the same features <strong>and</strong> improvements.<br />

Despite this Shadow Mapping introduces new problems severely deteriorating<br />

image quality if not addressed. Depth Buffer imprecision is one problem, because it can<br />

lead to artifacts at touching surfaces. But the main hurdle <strong>of</strong> Shadow Mapping is aliasing,<br />

which occurs in any algorithm, since the shadow map is always represented by a<br />

bitmap. Various approaches to deal with aliasing <strong>and</strong> limited depth buffer precision exist.<br />

However shadow map aliasing is clearly noticeable in every frame <strong>and</strong> severely de-


<strong>Implementation</strong> ::: Dynamic Shadows – Light Comes With Darkness 54<br />

teriorates image quality, whereas depth buffer imprecision only leads to small artifacts,<br />

which are only visible on certain objects. Subsequently the primary target <strong>of</strong> the shadow<br />

mapper implemented in QEE will be to deal with shadow map aliasing.<br />

The first <strong>and</strong> most obvious step to reduce aliasing <strong>of</strong> a map is to increase the resolution<br />

<strong>of</strong> the bitmap. But even with a maximum resolution <strong>of</strong> 2048x2048, which is the<br />

limit in texture size for many graphics adapters, will result in severe aliasing for light<br />

sources which affect a wide area, like an outdoor sunlight. To increase the number <strong>of</strong><br />

available pixels beyond this limitation, multiple shadow maps can be used. But multiple<br />

maps will consume a huge amount <strong>of</strong> memory <strong>and</strong> require several draw calls. The<br />

source for aliasing is the projection <strong>of</strong> a single shadow map pixel to multiple pixels <strong>of</strong><br />

the final image, if these could be mapped 1:1, the shadow map could have the same resolution<br />

as the screen <strong>and</strong> no aliasing would occur at all. However the shadow map needs<br />

to be aligned with the light viewport, which makes a direct projection to the screen<br />

plane impossible.<br />

4.4.1 Shadow Map Aliasing – One Problem Many Answers<br />

Despite a direct projection being not available, the basic idea <strong>of</strong> adapting the shadow<br />

map to the camera viewport is the source for many different approaches to improve<br />

Shadow Mapping. Other approaches try to enhance shadow quality, by introducing s<strong>of</strong>t<br />

shadow edges <strong>and</strong> simulating penumbrae 70 . The author tested <strong>and</strong> reviewed a range <strong>of</strong><br />

different papers <strong>and</strong> dissertations on improved Shadow Mapping variants. The following<br />

list provides an overview <strong>of</strong> available techniques to improve Shadow Mapping, the<br />

entries marked with an asterisk are partially implemented in Assembler Bay.<br />

Technologies reviewed in the scope <strong>of</strong> Shadow Mapping for QEE:<br />

• Trapezoidal Shadow Maps* (ref. [MAR04])<br />

• Adaptive Shadow Projection* (ref. [NEA05])<br />

• Variance Shadow Maps* (ref. [DON05])<br />

• Cascaded Shadow Maps (ref. [NEA05])<br />

• Shadow Map Percentage Closer Filtering (ref. [BUN04])<br />

• Shadow Silhouette Maps (ref. [SEN03])<br />

• Penumbra Faking with Smoothies (ref. [CHA03])<br />

• Light Space Perspective Shadow Maps (ref. [WIM05])<br />

• Layered Variance Shadow Maps (ref. [LAU08])<br />

• Dual Paraboloid Point-Light Shadows (ref. [Hay08])<br />

70 Penumbra is the blurred shadow edge resulting from scattered light


<strong>Implementation</strong> ::: Dynamic Shadows – Light Comes With Darkness 55<br />

Although a variant <strong>of</strong> Shadow Silhouette Maps <strong>and</strong> Shadow Map Percentage Closer<br />

Filtering were completely implemented in the development <strong>of</strong> Assembler Bay, they will<br />

not be detailed in this dissertation, because they were discarded in favor <strong>of</strong> techniques<br />

providing better image quality for the desired look <strong>of</strong> Assembler Bay. The details for all<br />

techniques can be accessed via the referenced papers, but the scope <strong>of</strong> this paper will<br />

only cover the implementation <strong>of</strong> the algorithms which were at least partially implemented<br />

for the final game.<br />

Trapezoidal Shadow Mapping tries to align the shadow map with the camera's<br />

bounding frustum to use a maximum <strong>of</strong> the available resolution for visible parts <strong>of</strong> the<br />

final image. Big light sources, like the sun in outdoor scenes, will most likely illuminate<br />

a much greater part <strong>of</strong> the scene than actually visible to the camera. Calculating shadows<br />

for these parts wastes processing time <strong>and</strong> shadow map capacity. The camera's<br />

bounding frustum is a trapezoid, which is projected to an irregular octagon in the 2D<br />

view space <strong>of</strong> the light source. Every pixel which is not part <strong>of</strong> this shape represents a<br />

point in <strong>3D</strong>-space which is not visible to the camera. Minimizing these wasted pixels is<br />

the first step <strong>of</strong> Trapezoidal Shadow Mapping (see Figure 4.8-1) .<br />

The easiest way to increase the used area <strong>of</strong> the shadow map, is linear scaling.<br />

The whole bounding shape can be enclosed in a rectangle, which provides Translation<br />

<strong>and</strong> Scaling factors. However since the camera may look in any direction, the bounding<br />

shape could face diagonally <strong>and</strong> almost half <strong>of</strong> the shadow map would be wasted in<br />

many cases. But the bounding shape can be rotated, so it always faces upwards along<br />

the Y-Axis (see Figure 4.8-2). Now the only wasted parts in the shadow map are the<br />

small gaps resulting from the trapezoid shape <strong>of</strong> the projected bounding frustum. Minimizing<br />

these parts is a bit more complex, since each transformation needs to be represented<br />

by a transformation matrix, so that all can be multiplied with the projection matrix<br />

<strong>of</strong> the light viewport. The only available transformations to change the trapezoid shape<br />

are scaling, rotations <strong>and</strong> shearing, which also results in non-linear scaling.<br />

Trapezoidal Shadow Maps use concentrated applications <strong>of</strong> these matrices not<br />

only to transform the trapezoid into a square, but also to distribute the resolution nonlinear<br />

(see Figure 4.8-3). Since objects close to the camera require a higher level <strong>of</strong> detail,<br />

shadow maps too need a higher level <strong>of</strong> detail on surfaces close to the camera. Objects<br />

which are very far away, are only represented by a few pixels in the final image.<br />

High resolution shadows would thus be wasted on these shadows.<br />

Trapezoidal Shadow Maps provide a projection matrix, which will distribute<br />

points close to the Near Plane <strong>of</strong> the camera over a great vertical range in the shadow<br />

map. Since a perspective view point has a smaller Near Plane than Far Plane, the points<br />

are also spread over a wider horizontal range, when the trapezoid is transformed to a<br />

unit square.


<strong>Implementation</strong> ::: Dynamic Shadows – Light Comes With Darkness 56<br />

Figure 4.8: Shadow Map Alignment with Trapezoidal Shadow Maps<br />

The shadow mapper <strong>of</strong> QEE utilizes certain steps <strong>of</strong> Trapezoidal Shadow Maps, but not<br />

the whole algorithm. Although greatly improving image quality, the algorithm <strong>of</strong><br />

Trapezoidal Shadow Mapping uses a great deal <strong>of</strong> processing power for the calculation<br />

<strong>of</strong> the non-linear transform matrices. Since shadow quality is only slightly improved<br />

after the rotation step, QEE uses a different amount <strong>of</strong> adaptation for different light<br />

sources. All light sources except the Sunlight utilize only translation <strong>and</strong> scaling, since<br />

most <strong>of</strong> the time the camera frustum <strong>and</strong> the light volume will partially intersect, where<br />

rotation would need extra calculations to deal with the partially visible frustum.<br />

However Sunlight utilizes rotation, since the sun will always light the complete Scene<br />

<strong>and</strong> the whole camera frustum will always be completely included in the shadow map.<br />

To improve the quality <strong>of</strong> Sunlight shadows further, the points are distributed using a<br />

quadratic scaling for the Y-Axis. This results in a non-linear scaling, which is comparable<br />

in effect <strong>and</strong> quality to the non-linear scaling <strong>of</strong> Trapezoidal Shadow Maps.<br />

Another improvement is achieved by moving the Far Plane <strong>of</strong> the camera frustum<br />

as close to the viewer as possible. QEE does this by reading whole Depth Buffer<br />

after the Geometry-Buffer is filled. The greatest value smaller than 1 is the most distant<br />

point still visible. The Far Plane is adapted to be exactly at that point. This technique increases<br />

shadow resolution usage to a reasonable amount. But the shadows still suffer<br />

from smaller aliasing. Even percentage closer filtering, which can be used by the graphics<br />

adapter, can not generate smooth shadows with a medium resolution for big light<br />

sources. A desired effect would be the simulation <strong>of</strong> s<strong>of</strong>t penumbrae.


<strong>Implementation</strong> ::: Dynamic Shadows – Light Comes With Darkness 57<br />

4.4.2 Variance Shadow Mapping – Smooth Shadows in Every Resolution<br />

Various techniques to smooth shadow maps by simulating penumbrae have become<br />

available for real time applications in the last years. Because shadow mapping is the<br />

preferred shadow generation approach in most modern games, the development <strong>of</strong> these<br />

techniques has been pushed in recent time. Most <strong>of</strong> the methods use either additionally<br />

created geometry around object silhouettes to cast penumbrae wedges 71 or modify the<br />

generated shadow maps with image processing algorithms. The generation <strong>of</strong> additional<br />

geometry suffers from the same drawbacks as Shadow Volumes, which are not acceptable<br />

for this project. Image processing algorithms generate good results too, but are instable<br />

<strong>and</strong> subject to severe artifacts under certain conditions. Algorithms <strong>of</strong> each categories<br />

have been reviewed by the author, but both require a big amount <strong>of</strong> specialization<br />

for compatibility, which is not acceptable for QEE.<br />

Another approach is Variance Shadow Mapping, which is a completely empirical<br />

method <strong>of</strong> generating penumbrae. The basic idea <strong>of</strong> VSM 72 is utilizing a stochastic algorithm<br />

to analyze the distribution <strong>of</strong> surrounding depth values <strong>of</strong> a pixel. If the pixel is<br />

near to a shadow silhouette, the surrounding depth values will vary between the two<br />

heights <strong>of</strong> the shadow caster <strong>and</strong> shadow receiver. On the other h<strong>and</strong>, if the pixel is<br />

completely in the umbra 73 <strong>of</strong> a shadow, all surrounding pixels will show the same depth<br />

value <strong>and</strong> variance will be close to zero. VSM is applied in two steps. The first step is<br />

the generation <strong>of</strong> a tw<strong>of</strong>old shadow map, which not only stores distance, but also the<br />

square <strong>of</strong> it. This shadow map is processed by a Gaussian Blur filter, providing a parameter<br />

for the size <strong>of</strong> penumbrae by the size <strong>of</strong> its filter kernel.<br />

The second step is the shadow test itself. Instead <strong>of</strong> just comparing the depth<br />

value <strong>of</strong> the processed pixel to the one stored in the shadow map, the variance <strong>of</strong> the<br />

neighboring pixels can be calculated using the stored value depthsqare <strong>and</strong> the stored<br />

value depth:<br />

Var=depthsqare−depth 2 �bias<br />

The bias is a value to account for depth buffer imprecision. The variance is clamped<br />

between one <strong>and</strong> zero, but has to be mapped to a value proportional to the distance <strong>of</strong><br />

the shaded pixel, by using the value newdepth <strong>of</strong> the processed pixel:<br />

shadow=Var÷�Var�newdepth−depth 2 � 74<br />

71 A Penumbrae wedge is the gradient between light <strong>and</strong> darkness at a shadow edge<br />

72 VSM = Variance Shadow Mapping<br />

73 The umbra is the core shadow <strong>of</strong> an object, it is not affected by any direct illumination <strong>of</strong> the light<br />

74 Original formula found by [DON05]


<strong>Implementation</strong> ::: Dynamic Shadows – Light Comes With Darkness 58<br />

With this, being the st<strong>and</strong>ard theory <strong>of</strong> VSM, the look <strong>of</strong> shadows can be further improved.<br />

The author tested various values <strong>and</strong> calculations to get better image quality <strong>and</strong><br />

changed the formula to use the square <strong>of</strong> the results as the actual shadow value. This<br />

formula for VSM results in much smoother visuals <strong>and</strong> almost no noticeable gap<br />

between umbra <strong>and</strong> penumbra, which is visible in st<strong>and</strong>ard VSM.<br />

However VSM has one big downside, which is introduced with higher depth<br />

complexity <strong>of</strong> the scene. Although VSM generates perfectly smooth shadows for a<br />

single shadow caster <strong>and</strong> multiple receivers, a problem arises if two shadow casters<br />

overlap. Because the distribution <strong>of</strong> surrounding pixels will not only be high at shadow<br />

edges, but at any variance in the shadow map. If a little object is closer to the light<br />

source than a large object, which casts a shadow on a surface below both <strong>of</strong> them, a<br />

wrong penumbra occurs. The small object causes a high variance at its edge, leaving a<br />

bright silhouette inside a complete shadow (see Figure 4.9-1). This problem is addressed<br />

by different papers, which propose the use <strong>of</strong> Layered Shadow Maps or complex depth<br />

tests. But the author decided to try an original way <strong>of</strong> dealing with this problem, inspired<br />

by discussions about this topic.<br />

The problem <strong>of</strong> identifying wrong penumbrae can be reduced to the problem <strong>of</strong><br />

deciding if a pixel is in the umbra. If a pixel is in the umbra can be decided by revisiting<br />

all surrounding pixels <strong>and</strong> check if they are shaded. However checking all surrounding<br />

pixels for every probably shaded pixel in the image would cost too much calculation<br />

time <strong>and</strong> could not be h<strong>and</strong>led in a single Pixel Shader 2.0-compatible shader. But this<br />

value can also be calculated beforeh<strong>and</strong>, utilizing the Gaussian Blur shade, which is<br />

processing the surrounding pixels <strong>of</strong> each pixel to recalculate its value. This is exactly<br />

what needs to be done for the absolute shadow value. A second shadow map is generated,<br />

where the maximum <strong>of</strong> all surrounding pixels is saved for each pixel. The maximum<br />

depth value represents the pixel farthest aways from the light source. If this value is<br />

still smaller than the depth value <strong>of</strong> a processed pixel in the final image, the pixel is<br />

completely occluded from the light <strong>and</strong> can be rendered in shadow, regardless <strong>of</strong> the<br />

calculated variance. The result <strong>of</strong> this step can be seen in Figure 4.9-2.<br />

However using the maximum shadow value to darken the umbra results in new<br />

artifacts at the border between different shadow casters. Since the silhouettes <strong>of</strong> both<br />

casters intersect at this point, the high variance produces a very bright penumbra. But<br />

this penumbra will start to be a fake penumbra at a certain point, where the pixels will<br />

be completely unlit. This produces aliased artifacts at these critical locations, which are<br />

slightly noticeable. To deal with these artifacts, another shadow map is introduced. But<br />

since the original shadow map already saved two values (depth <strong>and</strong> square <strong>of</strong> depth) a<br />

fourth register will be available anyway.


<strong>Implementation</strong> ::: Dynamic Shadows – Light Comes With Darkness 59<br />

Figure 4.9: Fake Penumbra in Variance Shadow Mapping <strong>and</strong> Solutions<br />

Using this register a second version <strong>of</strong> the maximum-depth shadow map is generated<br />

with a smaller neighborhood <strong>of</strong> surrounding pixels. This maximum-depth map with<br />

smaller range will be used to identify the umbra, whereas the wider ranged first maximum-depth<br />

map will be used to identify the silhouette <strong>of</strong> penumbra. Combining these<br />

two, any pixels at the silhouette <strong>of</strong> the penumbra will be darkened by squaring their<br />

shadow value 75 , whereas pixels in the umbra will be set to zero. The result <strong>of</strong> this techniques<br />

can be seen in Figure 4.9-3.<br />

These steps minimize the appearance <strong>of</strong> artifacts, although umbra artifacts can<br />

not be completely avoided using simple shadow mapping. This approach produces results<br />

comparable to Layered Shadow Mapping, but uses only one additional Render Target<br />

<strong>and</strong> no additional passes. Because the shadowing process is always a consideration<br />

between performance <strong>and</strong> visual quality, VSM seems to be the best compromise.<br />

75 Since the shadow value is clamped between 0 <strong>and</strong> 1, squaring will result in darker pixels


Achievement <strong>and</strong> Conclusion ::: Achievement <strong>and</strong> Conclusion 60<br />

5 Achievement <strong>and</strong> Conclusion<br />

This final chapter will give a detailed review <strong>and</strong> rating <strong>of</strong> the project outcome. The first<br />

section will show the achievements <strong>of</strong> this project <strong>and</strong> compare them to the intended<br />

tasks. Accomplished tasks will be compared against the prior set targets for quality <strong>and</strong><br />

performance, while uncompleted tasks will be analyzed critically.<br />

The second section will revolve around the whole process <strong>of</strong> completing this<br />

project. It will point out certain hurdles in the development <strong>of</strong> a game engine, as well as<br />

the pros <strong>and</strong> cons <strong>of</strong> working in an interdisciplinary team on a game design project.<br />

The third section will compare the result <strong>of</strong> this project against commercial<br />

games <strong>and</strong> try to rate its level <strong>of</strong> quality. The final chapter will finish with a conclusion<br />

<strong>of</strong> the whole project.<br />

5.1 Achievements <strong>and</strong> Tasks – Comparing Idea <strong>and</strong> Reality<br />

The goals for this project have been detailed mainly in the sections 1.2 <strong>and</strong> 3.2.1. They<br />

include certain requirements for the technical features <strong>of</strong> the game engine, the overall<br />

look <strong>of</strong> the game as well as the extend <strong>of</strong> included content. Like anticipated in the<br />

concept phase <strong>of</strong> Assembler Bay, the ultimate objective <strong>of</strong> designing a complete game<br />

could not be achieved in the scope <strong>of</strong> this project. However the design <strong>of</strong> a playable prototype<br />

was possible, which fulfills most <strong>of</strong> the required tasks.<br />

The foremost objective for Assembler Bay was the implementation <strong>of</strong> a fully<br />

playable demo level <strong>of</strong>fering all important features <strong>of</strong> the final game <strong>and</strong> being expendable<br />

into a tutorial level. This objective is for the most parts achieved by the prototype<br />

<strong>of</strong> Assembler Bay, but it is not a fully playable demo level. Although all gameplay elements<br />

for Assembler Bay have been independently implemented in the prototype, they<br />

are not connected to one playable game experience. The user can freely move around<br />

the level, jump on platforms <strong>and</strong> search for tiles, but he can not collect this parts <strong>and</strong><br />

start puzzling right away. The puzzle mode is activated by an additional key, which<br />

switches to an arbitrary camera. In this view puzzles can be assembled like in the final<br />

game, although optional features like a time limit for puzzling <strong>and</strong> a fixes boundary for<br />

no-gravity movements still have to be implemented. The character however is fully animated<br />

<strong>and</strong> jump&run sections in the level can be mastered with challenging difficulty.


Achievement <strong>and</strong> Conclusion ::: Achievements <strong>and</strong> Tasks – Comparing Idea <strong>and</strong> Reality 61<br />

The complete prototype level is partially animated, fully textured <strong>and</strong> illuminated<br />

with a range <strong>of</strong> dynamic lights. Included in the level is a complete puzzle, which<br />

can be used in the final game without further changes. The tasks for Assembler Bay also<br />

included two additional levels, which can provide an overview <strong>of</strong> the variety the final<br />

game will <strong>of</strong>fer. These two levels are designed as <strong>3D</strong> sceneries, which are not currently<br />

included in the prototype, because the level architecture is not adapted to the game<br />

mechanics. Each level includes a puzzle designed for the architecture <strong>and</strong> look <strong>of</strong> the individual<br />

level (see Figure 5.1). But like the levels these puzzles are not adapted to the<br />

gameplay mechanisms <strong>and</strong> <strong>of</strong>fer only a preview to the possibilities <strong>of</strong> future development.<br />

The task <strong>of</strong> implementing two additional levels <strong>and</strong> puzzles has be partially completed,<br />

as both levels are accessible in the game, but are not complete yet.<br />

Figure 5.1: Previews <strong>of</strong> additional Level <strong>Design</strong>s for future development<br />

In addition to these <strong>3D</strong> modeled level designs, various concepts for levels, puzzles <strong>and</strong><br />

challenges for the final game are available in the design h<strong>and</strong>book. These level design<br />

drafts include scribbles for tropical, desert <strong>and</strong> organic settings, which provide a guide<br />

for future level designs. The designated tasks for the amount <strong>of</strong> content in this project<br />

have been mostly accomplished. Although the available content is still far from a pr<strong>of</strong>essional<br />

game demo, the base for a variety <strong>of</strong> levels has been set.<br />

5.1.1 Primary Visual Features – Does it Look Good ?<br />

The goal to create the prototype for a game, which could compare to pr<strong>of</strong>essional games<br />

includes state <strong>of</strong> the art visuals. In section 3.2.1 the author provides a list with desired<br />

graphic features for Assembler Bay. This section will review which <strong>of</strong> these features<br />

have been implemented, <strong>and</strong> what quality could be achieved in this points. The most<br />

fundamental graphics feature in Assembler Bay is High Quality Dynamic Lighting,<br />

which is implemented using Deferred Shading. The visual quality <strong>of</strong> the used lighting<br />

model is equal to per-pixel Phong Lighting, but it surpasses the capabilities <strong>of</strong> normal


Achievement <strong>and</strong> Conclusion ::: Achievements <strong>and</strong> Tasks – Comparing Idea <strong>and</strong> Reality 62<br />

lighting models. The use <strong>of</strong> Deferred Shading allows Assembler Bay to use a huge number<br />

<strong>of</strong> dynamic lights, which far exceed the expectations in both quality <strong>and</strong> performance.<br />

The implementation <strong>of</strong> these tasks exceeded expectations.<br />

The second desired graphics feature is the rendering <strong>of</strong> dynamic s<strong>of</strong>t shadows,<br />

which are implemented using a combination <strong>of</strong> Variance Shadow Mapping, Adaptive<br />

Shadow Mapping <strong>and</strong> parts <strong>of</strong> Trapezoidal Shadow Mapping. The final shadow quality<br />

in Assembler Bay is better than expected. While normal shadow algorithms suffer from<br />

aliasing <strong>and</strong> many artifacts, the shadow mapping, implemented in Assembler Bay has<br />

only a single noticeable downside. The cast shadow <strong>of</strong> the character does not connect to<br />

his feat if the shadow map resolution is too low. This is a problem <strong>of</strong> depth buffer imprecision,<br />

which could be addressed by implementing special processing for the character's<br />

cast shadows, but this would reduce the consistency <strong>and</strong> reusability <strong>of</strong> the shadow<br />

model. The performance is good enough to use high resolution shadow maps up to<br />

2048x2048 pixels. However Variance Shadow Mapping provides astonishing quality,<br />

even for shadow map resolutions as low as 256x256 pixels, which would otherwise result<br />

in an unbearable quality (see Figure 5.2). The task <strong>of</strong> dynamic s<strong>of</strong>t shadows is a full<br />

success.<br />

Figure 5.2: Comparison <strong>of</strong> Shadow Mapping Filter Methods<br />

The third desired visual feature is Ambient Occlusion, which is implemented by baking<br />

lightmaps into the level textures. Although real time dynamic Ambient Occlusion would<br />

have been an option for Assembler Bay, a static approach is preferable. Dynamic Ambient<br />

Occlusion can be simulated by various techniques, which deliver quite good results,<br />

but still can not deliver the quality <strong>of</strong> pre-rendered lightmaps. The small improve in<br />

visual quality which can be achieved by the use <strong>of</strong> dynamic Ambient Occlusion techniques<br />

is negligible in contrast to the vast amount <strong>of</strong> processing power it consumes. The


Achievement <strong>and</strong> Conclusion ::: Achievements <strong>and</strong> Tasks – Comparing Idea <strong>and</strong> Reality 63<br />

static Ambient Occlusion, which is integrated in diffuse textures produces a good sense<br />

<strong>of</strong> depth for normal lighting models. However the specialized overexposure lighting<br />

model used in Assembler Bay enhances this effect to produce the unique look as a combination<br />

<strong>of</strong> vivid colors <strong>and</strong> a great sense <strong>of</strong> depth.<br />

Overexposure is the fourth desired visual effect for Assembler Bay. It is not an<br />

established graphics effect but a technique developed in the scope <strong>of</strong> this project. Although<br />

the final effect was only implemented in the last stage <strong>of</strong> visual design in Assembler<br />

Bay, the desired look, it should provide was already a steady idea inside the<br />

team. The effect overexposure is achieved by using <strong>and</strong> Ambient Light <strong>of</strong> maximum<br />

brightness, darkened only through Ambient Occlusion <strong>and</strong> cast shadows. This combination<br />

<strong>of</strong> sterile, clean brightness in every part <strong>of</strong> the level <strong>and</strong> dynamic cast shadows produces<br />

a surreal look, which is unique to Assembler Bay. Overexposure is the main effect,<br />

which generates an original look for Assembler Bay, the other parts being the abstract<br />

level design <strong>and</strong> particular textures style.<br />

5.1.2 Optional Graphics Effect – Does it Look Better ?<br />

MSAA 76 was the first optional effect for Assembler Bay, since it greatly improves image<br />

quality, but is still only an optional feature for some modern games. Because Deferred<br />

Shading is natively not compatible with MSAA, the implementation required certain<br />

changes <strong>and</strong> adjustments to the process <strong>of</strong> Deferred Shading. The task was a partial<br />

success in supporting a combination <strong>of</strong> MSAA <strong>and</strong> Deferred Shading on NVIDIA<br />

graphics adapters. The optional task <strong>of</strong> MSAA can be seen as a full success, depending<br />

on the final XBOX-360 compatibility with this feature.<br />

Figure 5.3: Screenshot <strong>of</strong> Assembler Bay with active MSAA<br />

76 Multi Sample Anti Aliasing


Achievement <strong>and</strong> Conclusion ::: Achievements <strong>and</strong> Tasks – Comparing Idea <strong>and</strong> Reality 64<br />

The remaining optional effects were not implemented in this project. However the base<br />

for these effects has been set by the foundation for post processing effects <strong>and</strong> the extensibility<br />

<strong>of</strong> the Deferred Shading component. An additional Geometry-Buffer Render<br />

Target is still available for a highly specialized bloom effect, whereas Depth <strong>of</strong> Field<br />

can use the Depth Surface <strong>of</strong> the G-Buffer, which is already parsed for certain depth<br />

values in the process <strong>of</strong> Shadow Mapping.<br />

5.1.3 Open Source <strong>Game</strong> Engine – Is it Really Quick <strong>and</strong> Easy?<br />

As depicted in section 1.2,the second main objective <strong>of</strong> this project is the development<br />

<strong>of</strong> an Open Source XNA-Engine, which can be used by the community to develop state<br />

<strong>of</strong> the art titles for the PC <strong>and</strong> the XBOX 360. Although the current QuicknEasy Engine<br />

is still incomplete, it already <strong>of</strong>fers a combination <strong>of</strong> features which can not be found in<br />

any other available Open Source XNA Engine. This section will provide an overview<br />

over various features <strong>of</strong> QEE <strong>and</strong> analyze their reusability <strong>and</strong> functionality for a redistributable<br />

game engine.<br />

The game engine structure is intended to provide all commonly required features<br />

<strong>of</strong> a game engine in the simplest manner possible. The class structure provides a shallow<br />

hierarchy, so it is easy for developers to underst<strong>and</strong> the dependencies <strong>and</strong> functions<br />

<strong>of</strong> each component in the engine. Most relevant public methods are declared virtual,<br />

which provides the possibility to deduct new classes using this methods as an interface.<br />

This method is preferred by the author, because a huge number <strong>of</strong> interfaces will degrade<br />

performance <strong>and</strong> only confuse developers for any classes, which are used unmodified.<br />

Since all parts <strong>of</strong> QEE are implemented by the author, using only public available<br />

sources as inspiration, the whole game engine can be used in any product, without licensing<br />

obligations.<br />

The physics engine, included in QEE, provides an easy interface for the implementation<br />

<strong>of</strong> new Physics Updaters, which can control the way an object reacts to collisions<br />

<strong>and</strong> gravity. The st<strong>and</strong>ard classes provide an easy object management for the simulation<br />

<strong>of</strong> physics, which will suffice for most <strong>3D</strong> games. Although the physics engine<br />

may be immoderate for its use in Assembler Bay, it <strong>of</strong>fers the flexibility <strong>of</strong> implementing<br />

physically based challenges. Any further game developed using QEE can use the<br />

physics engine without any changes to simulate a believable reacting environment.<br />

The performance <strong>of</strong> the physics engine is also better than expected. The physics<br />

engine was tested with 100 instanced <strong>of</strong> an object, each using polygon exact collision<br />

detection <strong>and</strong> consisting <strong>of</strong> 2.000 polygons (see Figure 5.4). This setting still produced<br />

acceptable results with an average frame rate <strong>of</strong> 60 frames per second on modern hardware.<br />

The real time collision h<strong>and</strong>ling for such an amount <strong>of</strong> shapes <strong>and</strong> polygons is<br />

more than a physics engine normally has to deal with, which makes the performance acceptable.


Achievement <strong>and</strong> Conclusion ::: Achievements <strong>and</strong> Tasks – Comparing Idea <strong>and</strong> Reality 65<br />

Figure 5.4: Screenshot <strong>of</strong> a Physics Simulation in Assembler Bay<br />

QuicknEasy Engine is a complete game engine developed in this project. Although still<br />

many improvements <strong>and</strong> documentation are required, before the project can be released<br />

in a developer community, all the fundamentals are implemented on a level fulfilling the<br />

expectations.<br />

5.2 Teamwork <strong>and</strong> Timetables – The Long Way <strong>of</strong> <strong>Game</strong> <strong>Design</strong><br />

Assembler Bay is an interdisciplinary collaboration, to make the idea <strong>of</strong> a real <strong>3D</strong> game<br />

become reality. To master a project like this not only requires a strict timetable <strong>and</strong> thorough<br />

planning, but foremost a perfect cooperation between all team members. The team<br />

for Assembler Bay consisted <strong>of</strong> three members: Two members <strong>of</strong> communication<br />

design, being responsible for audiovisual design <strong>and</strong> the author, being the only computer<br />

scientist. The development <strong>of</strong> a game can not be achieved without close collaboration,<br />

including regular team sessions, because all team members have to adapt to the<br />

specifications resulting from other parts <strong>of</strong> development. The implementation <strong>of</strong> a game<br />

engine requires regular testing <strong>and</strong> verification <strong>of</strong> all components, which requires game<br />

assets to be reliable. Although many tests can also be run with dummy objects or test<br />

objects by other sources than the original design team <strong>of</strong> the project, <strong>3D</strong> game design introduces<br />

various particular problems.<br />

A high hurdle on the track <strong>of</strong> game development is import <strong>and</strong> export <strong>of</strong> game<br />

assets. Although many st<strong>and</strong>ards have been established in public every day media, like<br />

music, documents <strong>and</strong> pictures, other areas still lack comprehensive st<strong>and</strong>ards. These<br />

areas includes <strong>3D</strong> geometry, <strong>3D</strong> animation, sound interchange, compressed textures <strong>and</strong><br />

lighting information, which are the most fundamental assets for <strong>3D</strong> game design. Be-


Achievement <strong>and</strong> Conclusion ::: Teamwork <strong>and</strong> Timetables – The Long Way <strong>of</strong> <strong>Game</strong> <strong>Design</strong> 66<br />

cause all assets from these areas are designed in arbitrary formats, custom exporters <strong>and</strong><br />

importers have to be utilized to make a transfer <strong>of</strong> these assets into the game possible.<br />

Pr<strong>of</strong>essional engines usually provide their own specialized exporters to convert assets<br />

into a format suitable for their custom content pipelines. But this is not suitable for a reusable<br />

game engine, unless the exporters are compatible to the most widely used modeling<br />

programs <strong>and</strong> receives regular updates. This project uses an intermediate approach<br />

combining an Open Source model exporter with a self developed exporter for meta information<br />

like lights <strong>and</strong> animation meta data. The whole meta information is stored in<br />

XML-format, which is parsed at runtime to provide a maximum <strong>of</strong> flexibility <strong>and</strong> transparency.<br />

The meta information files are designed in a way, which is easily readable. A<br />

level designer can underst<strong>and</strong> <strong>and</strong> change the values, watching the direct influence in<br />

the game, without the need to rebuild anything.<br />

The overall cooperation in this project went perfectly, as all team members met<br />

on a regular basis. The transfer <strong>of</strong> game assets into the game engine is now running<br />

smoothly, without the need <strong>of</strong> any code changes or particular adaption. The whole level<br />

geometry, as well as puzzle objects are imported <strong>and</strong> processed by the game engine, resulting<br />

in a fully functional puzzle generated only from meta-information provided in the<br />

form <strong>of</strong> naming conventions for the puzzle-parts. This modularity provides the possibility<br />

to design puzzles as well as levels completely independent from the game engine <strong>and</strong><br />

transfer them using the provided tools.<br />

5.3 Comparison <strong>and</strong> Conclusion – Is it Really State <strong>of</strong> the Art?<br />

The high set aim <strong>of</strong> this project is the design <strong>of</strong> a <strong>3D</strong> game prototype, which can be<br />

called state <strong>of</strong> the art, meaning it is comparable to current pr<strong>of</strong>essional gaming titles.<br />

This section will analyze <strong>and</strong> compare the visual quality, performance <strong>and</strong> features <strong>of</strong><br />

Assembler Bay <strong>and</strong> compare it to pr<strong>of</strong>essional games released in the last months 77 . Subsequently<br />

a review <strong>and</strong> the conclusion <strong>of</strong> the project will be provided in the last subsection.<br />

5.3.1 Dynamic S<strong>of</strong>t Shadows – Who is John Carmack?<br />

Dynamic S<strong>of</strong>t Shadows are a desired feature for every top title, which even modern<br />

games can not provide in optimal quality (see Figure 5.5 78 ). The goal <strong>of</strong> Assembler Bay<br />

is to reach the shadow quality <strong>of</strong> modern state <strong>of</strong> the art titles like Far Cry 2. Because<br />

Assembler Bay uses Variance Shadow Mapping it features much smoother shadows, but<br />

at the cost <strong>of</strong> shadow precision, as small structures will not be visible when blurred (see<br />

Figure 5.5). On the other h<strong>and</strong> Assembler Bay can be compared in terms <strong>of</strong> performance<br />

<strong>and</strong> visual quality, because the final look <strong>of</strong> a game is the deciding factor.<br />

77 Referring to the timespan <strong>of</strong> September 2008 – January 2009<br />

78 Cutout from a screenshot <strong>of</strong> Far Cry 2 with Shadow Quality Setting on high


Achievement <strong>and</strong> Conclusion ::: Comparison <strong>and</strong> Conclusion – Is it Really State <strong>of</strong> the Art? 67<br />

Figure 5.5: Close up Shadow Artifacts in Far Cry 2<br />

Figure 5.6: Magnified Shadow Details in Assembler Bay<br />

In a direct comparison <strong>of</strong> shadow quality, Assembler Bay hardly shows any noticeable<br />

artifacts, while Far Cry 2 has several scenes, where jagged shadow edges are noticeable<br />

<strong>and</strong> deteriorate image quality. Variance Shadow Mapping provides this smooth look at<br />

the cost <strong>of</strong> lost shadow details, but the overall impression is more appealing to the eye.


Achievement <strong>and</strong> Conclusion ::: Comparison <strong>and</strong> Conclusion – Is it Really State <strong>of</strong> the Art? 68<br />

5.3.2 Colors <strong>and</strong> Atmosphere – It is Vivid, but is it Unique?<br />

Assembler Bay wants to impress with an unique look, which is different to the atmosphere<br />

<strong>of</strong> most games. To achieve this, the common lighting model was modified to create<br />

a bright <strong>and</strong> clean look in Assembler Bay. This comes at the cost <strong>of</strong> realism <strong>and</strong><br />

lighting details, which may be interpreted as the absence <strong>of</strong> a sophisticated lighting<br />

model. But the game takes place in a virtual environment, which should look like a perfectly<br />

clean science fiction environment. Everything is completely lighted <strong>and</strong> all colors<br />

shine with maximum intensity. This design idea is similar to the visuals <strong>of</strong> Mirror's<br />

Edge. But while Mirror's Edge emphasizes the contrast between the strong colors in the<br />

sunlight <strong>and</strong> the dirty look <strong>of</strong> the indoor stages, Assembler Bay features a completely<br />

over brightened world.<br />

The look <strong>of</strong> Assembler Bay is already unique by its bright colors <strong>and</strong> s<strong>of</strong>t cast<br />

shadows, but can be further improved with additional effects like depth <strong>of</strong> field <strong>and</strong><br />

bloom. However even without these optional effects, the task <strong>of</strong> creating an original atmosphere<br />

for this project was successful. Assembler Bay appears very different to any<br />

commercial game, but provides pictures which can compare to most <strong>of</strong> them in quality<br />

<strong>and</strong> lighting accents. Although the level details in this project are not as sophisticated as<br />

the assets in commercial games, the game design <strong>of</strong> Assembler Bay allows an environment<br />

without much decals. Since the absence <strong>of</strong> these decals <strong>and</strong> certain details fits to<br />

the world <strong>of</strong> Assembler Bay, it will not be noticeable as a negative fact.<br />

5.3.3 Conclusion – Not Perfect but Worth the Effort<br />

It took a long way to create the result <strong>of</strong> this project, a playable prototype for a state <strong>of</strong><br />

the art <strong>3D</strong> game based on a self developed sophisticated game engine. Although the<br />

aims were set high at the beginning <strong>of</strong> this project, all <strong>of</strong> the primary goals were<br />

achieved <strong>and</strong> even some optional features were implemented in the engine. Throughout<br />

the whole project, more than once the team faced doubts, if the aims were set too high.<br />

But the implementation process proved time to be the foremost limitation to our project.<br />

Many optional features, effects <strong>and</strong> improvements in performance are possible in the<br />

current state <strong>of</strong> the game engine. These tasks will be h<strong>and</strong>led in the further development<br />

<strong>of</strong> Assembler Bay <strong>and</strong> QuicknEasy Engine, because an even longer way awaits Assembler<br />

Bay from this prototype onwards. The team is confident to find more members to<br />

advance this project <strong>and</strong> evolve it to a final game, which realizes all parts <strong>of</strong> the original<br />

project for Assembler Bay.<br />

Although the prototype developed in this project is not comparable with a pr<strong>of</strong>essional<br />

game demo, the underlying technologies can compete with commercial games.<br />

Because pr<strong>of</strong>essional design teams usually consist <strong>of</strong> a great number <strong>of</strong> team members<br />

<strong>and</strong> take years <strong>of</strong> development for a game including game engine design, the development<br />

<strong>of</strong> a <strong>3D</strong> game with the means <strong>of</strong> only three team members <strong>and</strong> six months <strong>of</strong> time<br />

from concept to prototype seemed hardly possible at the beginning. Because the imple-


Achievement <strong>and</strong> Conclusion ::: Comparison <strong>and</strong> Conclusion – Is it Really State <strong>of</strong> the Art? 69<br />

mentation <strong>of</strong> this prototype was a success, the further development <strong>of</strong> Assembler Bay<br />

seems definite. The team is highly motivated to finalize Assembler Bay <strong>and</strong> is supported<br />

by the University <strong>of</strong> Applied Science Trier in this effort.<br />

Reviewing the whole timespan <strong>of</strong> development, the original timetables for this<br />

project were totally <strong>of</strong>f, regarding some features. Although an additional buffer time <strong>of</strong><br />

6 weeks was present in the original timetables, particular problems <strong>and</strong> new requirements<br />

shortened these time to zero. Regarding this project, a timetable for a game<br />

should calculate at least one third <strong>of</strong> the available time as buffer time for unexpected<br />

problems <strong>and</strong> delays. Although some tasks were underestimated in the timetable design,<br />

many problems resulted from hardware failures, driver bugs or missing documentation<br />

for highly specialized features. Facing such problems can not be avoided <strong>and</strong> require a<br />

reasonable amount <strong>of</strong> extra time for any project using newest technologies.<br />

Eventually this project can be seen as a huge success, because it shows that the<br />

development <strong>of</strong> a moderate <strong>3D</strong> engine using newest technologies is possible, even for<br />

small private developer teams. The cooperation <strong>of</strong> developer communities <strong>and</strong> the ever<br />

lasting motivation to make game concepts become true, make it possible to design<br />

games which can compare to modern commercial games.<br />

Figure 5.7: Assembler Bay Logo


List <strong>of</strong> literature<br />

BET03: Erik Bethke, <strong>Game</strong> Development <strong>and</strong> Production, Wordware Publishing, Inc., 2003<br />

MIC06: Michael Dickheiser, <strong>Game</strong> programming gems 6, Charles River Media, 2006<br />

EBE04: David H. Eberly, <strong>Game</strong> Physics, Morgan Kaufmann, 2004<br />

SUP07: Angela Suppan, Interactive Story telling, GRIN Verlag, 2007<br />

BOW06: Doug A. Bowman, <strong>3D</strong> User Interfaces, Addison Wesley, 2006<br />

EBE01: David H. Eberly, <strong>3D</strong> <strong>Game</strong> Engine <strong>Design</strong>, Morgan Kaufmann, 2001<br />

DIE04: D. Sim Dietrich Jr., Nvidia, Shader Model 3.0, 2004<br />

HAR04: Shawn Hargreaves, Deferred Shading, 2004<br />

BUN05: Michael Bunnell, Dynamic Ambient Occlusion <strong>and</strong> Indirect Lighting, 2005<br />

VAL07: Michal Valient, Deferred Rendering in Killzone 2, 2007<br />

MAR04: Tobias Martin <strong>and</strong> Tiow-Seng Tan, Anti-aliasing <strong>and</strong> Continuity with Trapezoidal<br />

Shadow Maps, 2004<br />

NEA05: Andrew V. Nealen. Shadow Mapping <strong>and</strong> Shadow Volumes, 2005<br />

DON05: William Donnelly, Andrew Lauritzen, Variance Shadow Maps, 2005<br />

BUN04: Michael Bunnell, GPU Gems, Addison-Wesley Pr<strong>of</strong>essional, 2004<br />

SEN03: Pradeep Sen, Mike Cammarano, Pat Hanrahan, Shadow Silhouette Maps, 2003<br />

CHA03: Eric Chan <strong>and</strong> Frédo Dur<strong>and</strong>, Rendering Fake S<strong>of</strong>t Shadows with Smoothies, 2003<br />

WIM05: Michael Wimmer, Daniel Scherzer, Werner Purgath<strong>of</strong>er, Light Space Perspective<br />

Shadow Maps, 2005<br />

LAU08: Andrew Lauritzen, Michael McCool, Layered Variance Shadow Maps, 2008<br />

Hay08: Kyle Hayward. Dual-Paraboloid Shadow Maps, 2008<br />

70

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

Saved successfully!

Ooh no, something went wrong!