02.01.2014 Views

Slides - Computer Graphics and Multimedia - RWTH Aachen ...

Slides - Computer Graphics and Multimedia - RWTH Aachen ...

Slides - Computer Graphics and Multimedia - RWTH Aachen ...

SHOW MORE
SHOW LESS

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

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

Developing a Jump’n’Run puzzle game<br />

Samiro Discher Alex<strong>and</strong>er Kugler Christopher Kugler<br />

Christof Mroz<br />

<strong>RWTH</strong> <strong>Aachen</strong> University<br />

11. April 2012<br />

1 S.Discher,C.Mroz,C.Kugler,A.Kugler


Rendering<br />

2 S.Discher,C.Mroz,C.Kugler,A.Kugler


Normal Mapping<br />

Difficulties<br />

Texture to Object space:<br />

matrix of binormal, tangent<br />

<strong>and</strong> normal<br />

tangents computed from<br />

neighbouring vertices<br />

3 S.Discher,C.Mroz,C.Kugler,A.Kugler


Reflection<br />

Metallic<br />

Environment Mapping<br />

Fresnel Effect<br />

depending on viewing angle the amount of reflectance changes<br />

the reflected color may be mixed with either a base color or<br />

even a refracted color<br />

4 S.Discher,C.Mroz,C.Kugler,A.Kugler


Refraction<br />

Without Normalmapping<br />

With Normalmapping<br />

Dynamic vs. Static<br />

static: uses a cube map<br />

dynamic: draw object as late as possible <strong>and</strong> use current<br />

screen buffer as lookup, solve lookup outside of screen buffer<br />

by clamping<br />

5 S.Discher,C.Mroz,C.Kugler,A.Kugler


Chromatic Dispersion<br />

Characteristics<br />

different refraction for red, blue <strong>and</strong> green depending on<br />

refraction ratio (material dependent)<br />

can be combined with reflection (Fresnel Equation)<br />

6 S.Discher,C.Mroz,C.Kugler,A.Kugler


Skybox<br />

Characteristics<br />

Cube Map with camera as center<br />

7 S.Discher,C.Mroz,C.Kugler,A.Kugler


Transparency<br />

Characteristics<br />

draw transparent objects in a second pass, use alpha blending<br />

8 S.Discher,C.Mroz,C.Kugler,A.Kugler


Post Processing<br />

Effects<br />

Deferred Lighting<br />

Motion Blur<br />

FXAA<br />

SSAO<br />

Greyscale<br />

Glow<br />

9 S.Discher,C.Mroz,C.Kugler,A.Kugler


Deferred Lighting<br />

Characteristics<br />

use depth buffer to calculate light direction in eye space<br />

use normal buffer <strong>and</strong> light direction to calculate the diffuse<br />

<strong>and</strong> specular amount<br />

combine diffuse, specular, ssao <strong>and</strong> the material’s<br />

characteristics (fresnel exponent <strong>and</strong> intensity) adequately<br />

10 S.Discher,C.Mroz,C.Kugler,A.Kugler


Pointlights<br />

11 S.Discher,C.Mroz,C.Kugler,A.Kugler


Spotlights<br />

Characteristics<br />

distance <strong>and</strong> angle attenuation<br />

12 S.Discher,C.Mroz,C.Kugler,A.Kugler


Spotlights With Shadows<br />

Projected Geometry Pass<br />

Lighting Pass<br />

Pipeline characteristics<br />

Geometry Pass: draw geometry only from light position <strong>and</strong><br />

save into buffer<br />

Lighting Pass: use generated buffer to determine whether pixel<br />

is in shadow or not<br />

13 S.Discher,C.Mroz,C.Kugler,A.Kugler


Motion Blur<br />

Velocity Buffer<br />

Result<br />

Pipeline characteristics<br />

compute velocity with current MVP <strong>and</strong> MVP of the last<br />

frame<br />

14 S.Discher,C.Mroz,C.Kugler,A.Kugler


Anti-Aliasing<br />

Without Anti-Aliasing<br />

With FXAA<br />

Pipeline characteristics<br />

high quality anti-aliasing with a single-pass post-process<br />

15 S.Discher,C.Mroz,C.Kugler,A.Kugler


Glow<br />

16 S.Discher,C.Mroz,C.Kugler,A.Kugler


Greyscale<br />

17 S.Discher,C.Mroz,C.Kugler,A.Kugler


Assets<br />

18 S.Discher,C.Mroz,C.Kugler,A.Kugler


Assets<br />

Modeling<br />

14 assets with 12 different functionalities<br />

planned puzzle logic system<br />

19 S.Discher,C.Mroz,C.Kugler,A.Kugler


Tools<br />

used Blender 2.59<br />

importer for 3D-objects, materials, textures (alpha, normal)<br />

1st Level (in Blender)<br />

20 S.Discher,C.Mroz,C.Kugler,A.Kugler


Animation<br />

animation applied with scene graph<br />

movable objects splitting into several sub-objects<br />

Robots MG<br />

21 S.Discher,C.Mroz,C.Kugler,A.Kugler


Normal Maps<br />

Low Poly<br />

High Poly<br />

Normal Map<br />

creation of normalmaps with<br />

baking high on low poly<br />

objects<br />

22 S.Discher,C.Mroz,C.Kugler,A.Kugler


Modifiers<br />

clever use of modifiers<br />

Eye Geometry<br />

Robot Ammunition<br />

23 S.Discher,C.Mroz,C.Kugler,A.Kugler


Game Engine<br />

Post Mortem<br />

The result was a desaster<br />

Refactoring costs → New feature development almost stalled<br />

How could this happen?<br />

Presentation logic: unexpected complexity<br />

Object-oriented entity hierarchy<br />

Engine was rewritten<br />

but not in time, unfortunately<br />

24 S.Discher,C.Mroz,C.Kugler,A.Kugler


Game Engine<br />

Post Mortem<br />

The result was a desaster<br />

Refactoring costs → New feature development almost stalled<br />

How could this happen?<br />

Presentation logic: unexpected complexity<br />

Object-oriented entity hierarchy<br />

Engine was rewritten<br />

but not in time, unfortunately<br />

25 S.Discher,C.Mroz,C.Kugler,A.Kugler


Game Engine<br />

Post Mortem<br />

The result was a desaster<br />

Refactoring costs → New feature development almost stalled<br />

How could this happen?<br />

Presentation logic: unexpected complexity<br />

Object-oriented entity hierarchy<br />

Engine was rewritten<br />

but not in time, unfortunately<br />

26 S.Discher,C.Mroz,C.Kugler,A.Kugler


Game Engine<br />

Post Mortem<br />

The result was a desaster<br />

Refactoring costs → New feature development almost stalled<br />

How could this happen?<br />

Presentation logic: unexpected complexity<br />

Object-oriented entity hierarchy<br />

Engine was rewritten<br />

but not in time, unfortunately<br />

27 S.Discher,C.Mroz,C.Kugler,A.Kugler


Game Engine<br />

Post Mortem<br />

The result was a desaster<br />

Refactoring costs → New feature development almost stalled<br />

How could this happen?<br />

Presentation logic: unexpected complexity<br />

Object-oriented entity hierarchy<br />

Engine was rewritten<br />

but not in time, unfortunately<br />

28 S.Discher,C.Mroz,C.Kugler,A.Kugler


Game Engine<br />

Post Mortem<br />

The result was a desaster<br />

Refactoring costs → New feature development almost stalled<br />

How could this happen?<br />

Presentation logic: unexpected complexity<br />

Object-oriented entity hierarchy<br />

Engine was rewritten<br />

but not in time, unfortunately<br />

29 S.Discher,C.Mroz,C.Kugler,A.Kugler


Game Engine<br />

Post Mortem<br />

The result was a desaster<br />

Refactoring costs → New feature development almost stalled<br />

How could this happen?<br />

Presentation logic: unexpected complexity<br />

Object-oriented entity hierarchy<br />

Engine was rewritten<br />

but not in time, unfortunately<br />

30 S.Discher,C.Mroz,C.Kugler,A.Kugler


Game Engine<br />

Post Mortem<br />

The result was a desaster<br />

Refactoring costs → New feature development almost stalled<br />

How could this happen?<br />

Presentation logic: unexpected complexity<br />

Object-oriented entity hierarchy<br />

Engine was rewritten<br />

but not in time, unfortunately<br />

31 S.Discher,C.Mroz,C.Kugler,A.Kugler


Game Engine<br />

Post Mortem<br />

The result was a desaster<br />

Refactoring costs → New feature development almost stalled<br />

How could this happen?<br />

Presentation logic: unexpected complexity<br />

Object-oriented entity hierarchy<br />

Engine was rewritten<br />

but not in time, unfortunately<br />

32 S.Discher,C.Mroz,C.Kugler,A.Kugler


Architecture<br />

Model<br />

addEntity()<br />

Controller<br />

update()<br />

Presenter<br />

createMeshNode()<br />

createLightNode()<br />

createCameraNode()<br />

Renderer<br />

paint()<br />

*<br />

Room<br />

*<br />

Node<br />

*<br />

Entity<br />

33 S.Discher,C.Mroz,C.Kugler,A.Kugler


Scene Node Hierarchy<br />

parent<br />

1<br />

Node<br />

setTransform()<br />

getGlobalTransform()<br />

*<br />

MeshNode<br />

Camera<br />

Light<br />

setDiffuse()<br />

setGlow()<br />

PointLight<br />

SpotLight<br />

MetallicNode<br />

DeferredPointLight<br />

ShadowSpotLight<br />

34 S.Discher,C.Mroz,C.Kugler,A.Kugler


Entity Controllers<br />

Observer<br />

*<br />

Observable<br />

Controller<br />

PlayerController<br />

update()<br />

update()<br />

Entity<br />

node<br />

entity<br />

AssetNode Player Dynamic<br />

35 S.Discher,C.Mroz,C.Kugler,A.Kugler


Asset Definition<br />

EmptyAsset<br />

GeoAsset<br />

* children<br />

Asset<br />

1<br />

LightAsset<br />

Animation<br />

name<br />

*<br />

*<br />

Channel<br />

name<br />

keyframes<br />

36 S.Discher,C.Mroz,C.Kugler,A.Kugler


Asset Instantiation<br />

Asset<br />

AssetController<br />

blueprint<br />

play(name : string) root node<br />

MeshNode<br />

*<br />

Animation<br />

name<br />

apply(t, n : MeshNode)<br />

Timer<br />

37 S.Discher,C.Mroz,C.Kugler,A.Kugler


Approach: Entity Hierarchy<br />

Entity<br />

sendMessage()<br />

Can leave<br />

room<br />

?<br />

pos<br />

Static<br />

Dynamic<br />

orientation<br />

PhysicsObject<br />

mass<br />

velocity<br />

force<br />

Door<br />

Player<br />

38 S.Discher,C.Mroz,C.Kugler,A.Kugler


Idea: Refine Taxonomy<br />

Entity<br />

Static<br />

Dynamic<br />

sendMessage()<br />

pos<br />

orientation<br />

RigidBody<br />

mass<br />

volume<br />

Kinematic<br />

velocity<br />

DynamicKinematic<br />

Door<br />

Trap<br />

Player<br />

39 S.Discher,C.Mroz,C.Kugler,A.Kugler


Our Solution: Blob Anti-Pattern<br />

Player<br />

Default<br />

Implementations<br />

pos<br />

orientation<br />

velocity<br />

mass<br />

Entity<br />

PhysicsEntity<br />

getPos()<br />

getMass()<br />

getvelocity()<br />

getOrientation()<br />

Door<br />

sendMessage()<br />

getPos()<br />

getOrientation()<br />

getVelocity()<br />

getMass()<br />

pos<br />

mass<br />

getPos()<br />

getMass()<br />

40 S.Discher,C.Mroz,C.Kugler,A.Kugler


Discussion of the OO approach<br />

Summary<br />

Placing new classes into the hierarchy: distracting<br />

Changes may propagate from root to subclass<br />

Changed requirements =⇒ (maybe) splitting of taxonomy<br />

Cost of refactoring inhibits creativity<br />

Maybe we just need to think harder?<br />

Alternative Solution<br />

Don’t base entity management/processing on OOP to begin with<br />

41 S.Discher,C.Mroz,C.Kugler,A.Kugler


Discussion of the OO approach<br />

Summary<br />

Placing new classes into the hierarchy: distracting<br />

Changes may propagate from root to subclass<br />

Changed requirements =⇒ (maybe) splitting of taxonomy<br />

Cost of refactoring inhibits creativity<br />

Maybe we just need to think harder?<br />

Alternative Solution<br />

Don’t base entity management/processing on OOP to begin with<br />

42 S.Discher,C.Mroz,C.Kugler,A.Kugler


Discussion of the OO approach<br />

Summary<br />

Placing new classes into the hierarchy: distracting<br />

Changes may propagate from root to subclass<br />

Changed requirements =⇒ (maybe) splitting of taxonomy<br />

Cost of refactoring inhibits creativity<br />

Maybe we just need to think harder?<br />

Alternative Solution<br />

Don’t base entity management/processing on OOP to begin with<br />

43 S.Discher,C.Mroz,C.Kugler,A.Kugler


Discussion of the OO approach<br />

Summary<br />

Placing new classes into the hierarchy: distracting<br />

Changes may propagate from root to subclass<br />

Changed requirements =⇒ (maybe) splitting of taxonomy<br />

Cost of refactoring inhibits creativity<br />

Maybe we just need to think harder?<br />

Alternative Solution<br />

Don’t base entity management/processing on OOP to begin with<br />

44 S.Discher,C.Mroz,C.Kugler,A.Kugler


Discussion of the OO approach<br />

Summary<br />

Placing new classes into the hierarchy: distracting<br />

Changes may propagate from root to subclass<br />

Changed requirements =⇒ (maybe) splitting of taxonomy<br />

Cost of refactoring inhibits creativity<br />

Maybe we just need to think harder?<br />

Alternative Solution<br />

Don’t base entity management/processing on OOP to begin with<br />

45 S.Discher,C.Mroz,C.Kugler,A.Kugler


Discussion of the OO approach<br />

Summary<br />

Placing new classes into the hierarchy: distracting<br />

Changes may propagate from root to subclass<br />

Changed requirements =⇒ (maybe) splitting of taxonomy<br />

Cost of refactoring inhibits creativity<br />

Maybe we just need to think harder?<br />

Alternative Solution<br />

Don’t base entity management/processing on OOP to begin with<br />

46 S.Discher,C.Mroz,C.Kugler,A.Kugler


Discussion of the OO approach<br />

Summary<br />

Placing new classes into the hierarchy: distracting<br />

Changes may propagate from root to subclass<br />

Changed requirements =⇒ (maybe) splitting of taxonomy<br />

Cost of refactoring inhibits creativity<br />

Maybe we just need to think harder?<br />

Alternative Solution<br />

Don’t base entity management/processing on OOP to begin with<br />

47 S.Discher,C.Mroz,C.Kugler,A.Kugler


New engine: Entity System<br />

Controller<br />

*<br />

System<br />

update()<br />

run()<br />

GameState<br />

keys<br />

deltaTime<br />

addEntity()<br />

addComponent()<br />

queryEntities()<br />

Presenter<br />

Renderer<br />

*<br />

Entity<br />

*<br />

Component<br />

48 S.Discher,C.Mroz,C.Kugler,A.Kugler


Entity System Example<br />

: DoorLogic<br />

: RigidBody<br />

: Transform2D<br />

: PlayerLogic<br />

door : Entity<br />

player : Entity<br />

DoorController<br />

Physics<br />

System<br />

: Kinematics<br />

PlayerController<br />

49 S.Discher,C.Mroz,C.Kugler,A.Kugler


Image Sources<br />

http://de.wikipedia.org/w/index.php?title=Datei:7fin.png<br />

http://en.wikipedia.org/wiki/File:4overmap.png<br />

http://wiki.delphigl.com/index.php/Datei:Skybox.jpg<br />

50 S.Discher,C.Mroz,C.Kugler,A.Kugler

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

Saved successfully!

Ooh no, something went wrong!