• Nem Talált Eredményt

Create an automatic UV layout

In document Game Development (Pldal 76-0)

Game Development

4.21. Adjust the uv coordinates in the UV Editor...

We can use:

Game Development

4.23. The "completed" head model

Game Development

4.24. The End

5. 5 Character Modelling II. Modelling the body

5.1. Start

• http://cg.iit.bme.hu/gamedev/KIC/02_DevToolsAssets/04/

• Load head.blend into Blender

Game Development

5.2. New Cylinder

5.3. Set background image in front view

Set background image in front view: torso_front.jpg Rotate cylinder to look like this:

Game Development

5.4. Move vertices to their place

Game Development

5.5. Refinement (loop subdivide), vertex position adjustment:

Game Development

5.6. Delete cap faces

Game Development

5.7. Set background image for side view (torso_side.jpg)

Game Development

5.8. Move vertices to their place in side view

Game Development

5.9. Extrude the shoulders, adjust vertex positions

Game Development

5.10. Extrude the collar (torso.blend)

Game Development

Game Development

5.11. Extrude the arm, adjust vertices

Game Development

5.12. Help

Help: Front view image (arms_front.jpg) extrude, scale...

Game Development

Game Development

5.14. Creating legs

Creating legs is similar.

Details are up to you!

We can use: extrude, scale, rotate faces

(cut faces (knife cut), vertex merge, create new faces etc...)

5.15. legs.blend

Game Development

5.16. We also need:

• Hands (glove)

• Foot (shoes)

• Accessories (back sack, belt, sunglasses etc..)

• TEXTURING

• Refinement of the whole model

6. 6 Character animation in Blender - Rigging

6.1. Start

Game Development

6.2. Create one bone of a skeleton

Game Development

6.3. Create new bones

Game Development

Game Development

Game Development

Game Development

6.5. Name the bones (_l postfix)

Game Development

Game Development

Game Development

6.6. Renaming the bones

Game Development

6.7. Bind geometry to the skeleton

Game Development

6.8. Test (skeleton can be posed in Pose mode)

6.9. Undo transformation of a bone

6.10. Vertex groups

Game Development

6.11. Bone weight painting

Red: high influence (1.0) Blue: low influence (0.0)

6.12. Just paint weights until we are satisfied...

Game Development

7. 7 Game engine modules

7.1. What is a game engine?

• An extremely complex software package

• A class library

• Additional tools

• level editors

• modeling software plugins

7.2. Tasks of a game engine I

• Multi-threading

Game Development

• Rendering

• resource (tesh, texture, shader) management

• material/shader system

• GPU state change management

• geometry instancing

• visibility culling

7.3. Tasks of a game engine II

• Animation

• Physics simulation

• Character animation

• Particle systems

• Camera animation

• Audio

• GUI

7.4. Tasks of a game engine III

• Artificial intelligence

• state management

• pathing

• Scripting

• Procedural content generation

• global illumination

• vegetation generation

• Networking

Game Development

7.6. Multi-threading library?

• There are some, e.g.

• Intel Thread Building Blocks

• Microsoft Parallel Patterns Library

• but the challenge is to design engine modularization, parallelism, communication, task granularity

• for garage projects giving their own thread to physics and audio suffices

7.7. Rendering - resource management

• Mesh models, textures, shaders must be loaded from files

• Streamed/removed from CPU/GPU memory

• Game objects can reference these resources

• Intermediate buffers, render targets

7.8. Rendering - material/shader system

• New materials should be editable, changeable without touching the code: a kind of scripting is needed

• e.g. Ogre's material scripts

• e.g. the Effects system of D3D

• Assignment of materials to game objects

• Application of material for rendering

7.9. Rendering - GPU state change management

• GPUs are fast - CPU-GPU communication is the bottleneck

• to minimize this, minimize state changes

• render objects with the same materials, textures contiguously

• render queues

• geometry instancing

7.10. Rendering - Visibility culling

• Do not render hidden geometry

• View frustum culling

• PVS - possibly visible set

• a conservative guess on what is visible

Game Development

• if a proxy object inside A fully occludes a proxy object around B, then B is surely not visible

• hierarchies

• GPU support - visibility queries

• when rasterizing proxy of B, did we draw anything?

7.11. Rendering Engine

• Ogre3D

• Crystal Space

• Genesis3D

• Irrlicht

• Truevision3D

7.12. Animation - Physics simulation

• The virtual world should not only look real - it should act real!

• Rigid body mechanics

• Collision detection and response

• Contact forces and joints

• Cloth simulation

• Fluid simulation

7.13. Physics Engine

• Bullet

• open source

• ODE - Open Dynamics Engine

• NVidia PhysX

Game Development

• input: bone orientations at keyframes

• skinning

8. 8 Rendering pipeline - Ogre3D

8.1. Pipeline stages I.

• Prepare vertex data

• Vertex Shader

• World and View transformation

• Shading

• Projection Transformation

• Make up primitives

• Geometry Shader [sm4, DX10]

• Additional geometry creation

8.2. Pipeline stages II.

• Rasterization

• Backface culling

• Clipping

• Homogeneous division

Game Development

• Viewport transformation

• Pixel shader

• Defining pixel color

• z-test

• blending

8.3. Preparing vertex data

• Vertex buffer

• Array of vertex records

8.4. Vertex shader

• Input data

• varying: [position, normal, color, texture coordinates, ...]

• uniform: model, view, projection matrices, light data, ...

• Output data

• Position in homogenous screen coordinates

• Shaded color

• Other data [normal, texture coordinates]

8.5. Primitive assembler

• non-indexed / indexed

• Adjacent vertices define a triangle

Game Development

8.6. Backface culling

• Based on vertex order (clockwise, counter clockwise)

• If the model has a consistent vertex ordering (preferable)

• The model should be a closed shell

8.7. Clipping

• Offscreen triangle parts are cut

• normalized screen coordinates[-1, -1, 0] [1, 1, 1] [Cartesian]

• Wrap-around problem

• Clipping in homogeneous coordinates

8.8. Rasterization

• Homogeneous division

• Viewport transformation: pixel coordinates

• Linear interpolation

• Interpolation of vertex output data for each covered pixels

• Execute pixel shader for each covered pixel

8.9. Pixel shader

• Input data

• vertex shader output data, linearly interpolated

• pixel coordinates

• Output data

Game Development

• pixel color [RGBA]

• Pixel depth

• Optional, interpolated values can be overriden

• If not overriden: early test

8.10. Output merger

• buffers

• target: frame buffer or texture

• depth-stencil buffer

• operations

• Depth test

• Stencil test

• Alfa blending

8.11. Z-test

• Solution for visibility problems

8.12. Blending

Game Development

8.13. "Standard" vertex shader (Cg)

Game Development

8.14. "Standard" pixel shader

Game Development

8.16. Phong shading

8.17. Ogre3D

8.18. Object-Oriented Graphics Rendering Engine

• www.ogre3d.org

• Manual

• API reference

• SDK

• Demos

• Tools (exporter)

• Wiki

• Forum

8.19. Object Oriented

Game Development

• Main interfaces are independent from:

• 3D API

• Scene type

• Platform

• Extendable

• plugins

• Clear design

8.20. Features

• Multi platform

• Various scene graph management

• Resource management

• Dedicated model format

• Level of detail

• Skinning

• Morphing

• Material scripting system (XML)

• Render state

• Textures(2D,3D,CUBE,animated)

• Shaders

• Particle system (scripts)

• Common shadow computation methods

• Render to texture

• Post processing framework (scripts)

• Overlay framework (scripts)

Game Development

8.21. Basic Ogre usage

OgreRoot root = new Root(...);

root.loadPlugin("RenderSystem_Direct3D9");

RenderSystemList list = root.getAvailableRenderers();

root.setRenderSystem(list.at(0));

root.initialise(...);

RenderWindow renderWindow = root.createRenderWindow(...);

SceneManager sceneManager = root.createSceneManager(...);

ResourceGroupManager.getSingleton().addResourceLocation(...);

ResourceGroupManager.getSingleton().initialiseAllResourceGroups();

setupScene();

setupListeners();

root.startRendering(); //main loop ( )

8.22. setupScene

SceneNode rootSceneNode = sceneManager.getRootSceneNode();

camera = sceneManager.createCamera("Main Camera");

camera.setPosition(0, 10, 20);

Viewport viewport = renderWindow.addViewport(camera, ...);

renderWindow.setActive(true);

Game Development

Entity entity = sceneManager.createEntity("cake", "zuh.mesh");

SceneNode cakeNode = rootSceneNode.createChildSceneNode();

cakeNode.attachObject(entity);

cakeNode.setPosition(-3.5f, 0, 0);

8.23. setupListeners

8.24. Material script (.material)

Game Development

8.26. Shader program definitions (.program)

Game Development

8.27. The End

9. 9 Ogre3D

9.2. Media files

Game Development

Win32 Console Application

9.4. Settings for all configurations

Game Development

Game Development

9.6. Required dlls (files ending with _d are from the debug folder, others are from the release folder)

9.7. OgreLab1.cpp

Game Development

9.8. Test: build and run

9.9. Log file

Game Development

9.10. Camera / viewport

9.11. Test

Game Development

9.12. Exported Ogre meshes

9.13. Test

Game Development

9.14. Several copies of the model

9.15. Test

Game Development

9.16. Lightsource!

9.17. Test

Game Development

9.18. Animated light

9.19. Test

Game Development

9.20. Ground

Game Development

9.21. Test

9.22. Tessellated ground

Game Development

9.23. Test

Don't forget to set segmentation back to 1!!

Game Development

9.25. Test

9.26. Shaders / Phong shading

Game Development

9.27. Shaders / Phong shading

Game Development

9.28. Test

Yes, this is our shader!!!

Game Development

9.29. Test

Game Development

9.30. Test

Game Development

9.31. Test

Game Development

9.32. The End

10. 10 Billboard, Particle System

10.1. Basics

• http://cg.iit.bme.hu/gamedev/KIC/04_GraphicsEngine/

• 04_03_Ogre3D_BillboardsParticles_Base.zip

• Extract

• Run: OgreBillboardParticles.sln

• Set include and library paths (if not correct)

• Set working directory (if not (SolutionDir)/bin)

• Compile

• Run

10.2. Run

Game Development

10.3. New file: Tree.h

Game Development

10.5. OgreBillboardParticles.cpp

10.6. Test

Game Development

10.7. Blending

Game Development

10.9. Several trees

10.10. Test

Game Development

10.11. No depth buffer write

Game Development

10.13. Sorted rendering of transparent objects

• Individual work: Rewrite the code to contain only one billboard set which should contain all billboards

• Take care of:

• Ordering

• Culling

• Pool (maximal size of the billboardset)

10.14. Solution

10.15. Test

Game Development

10.16. A more realistic approach: Billboard Clouds

Game Development

10.17. A more realistic tree

10.18. Tree.material: new material

Game Development

10.19. Test

Game Development

10.20. Tree.material: new material

10.21. Test

Game Development

10.22. Particle systems

10.23. New file: Particles.h

Game Development

10.24. New file in media folder: example.particle

10.25. New material file: Particles.material

10.26. OgreBillboardParticles.cpp

Game Development

10.27. Test

10.28. Individual Work

Explore the scripts, play with them, try several:

• Emitters

Game Development

10.30. The End

In document Game Development (Pldal 76-0)