Game Engine Design ITCS 40105010 Spring 2006 Kalpathi
- Slides: 34
Game Engine Design ITCS 4010/5010 Spring 2006 Kalpathi Subramanian Department of Computer Science UNC Charlotte
What you need to know… l Linear algebra and trigonometry – – l Short course – see Appendix A & B in book. Definitely read until next lecture, if you’re not confident with that material… C/C++ - programming – Not hard to learn if you have not used it yet. Tomas Akenine-Mőller © 2002
What are the results that are achievable with Computer Graphics? Tomas Akenine-Mőller © 2002
State-of-the-Art Real-Time Rendering 2001 Tomas Akenine-Mőller © 2002
State-of-the-Art Real-Time Rendering 2001 Tomas Akenine-Mőller © 2002
Which one is a real photo, and which one is CG? Tomas Akenine-Mőller © 2002
Complexity: 8 million triangles… Tomas Akenine-Mőller © 2002
Visible Human Project (Mid 90 s) Visible Male Acquisition (256 x 1871) slices from CT, MRI, Anatomical - about 15 Gbytes l Visible Female Acquisition - 40 Gbytes l Tomas Akenine-Mőller © 2002
Photo-realistic Rendering… Tomas Akenine-Mőller © 2002
The Graphics Rendering Pipeline Chapter 2 in the book l The pipeline is the ”engine” that creates images from 3 D scenes l Three conceptual stages of the pipeline: l – – – Application (executed on the CPU) Geometry Rasterizer Application input 3 D scene Geometry Rasterizer Image output Tomas Akenine-Mőller © 2002
Rendering Primitives Use graphics hardware for real time… l These can render points, lines, triangles. l A surface is thus an approximation by a number of such primitives. l Tomas Akenine-Mőller © 2002
You say that you render a ” 3 D scene”, but what is it? l First, of all to take a picture, it takes a camera – a virtual one. – l A 3 D scene is: – – l Decides what should end up in the final image Geometry (triangles, lines, points, and more) Light sources Material properties of geometry Textures (images to glue onto the geometry) A triangle consists of 3 vertices – A vertex is 3 D position, and may include normals and more. Tomas Akenine-Mőller © 2002
Virtual Camera l Defined by position, direction vector, up vector, field of view, near and far plane. point l l dir fov (angle) far near Create image of geometry inside gray region Used by Open. GL, Direct. X, ray tracing, etc. Tomas Akenine-Mőller © 2002
Application Back to the pipeline: The APPLICATION stage l Means that the programmer decides what happens here Examples: – – – l Rasterizer Executed on the CPU – l Geometry Collision detection Speed-up techniques Animation Most important task: send rendering primitives (e. g. triangles) to the graphics hardware Tomas Akenine-Mőller © 2002
Application Geometry Rasterizer The GEOMETRY stage Task: ”geometrical” operations on the input data (e. g. triangles) l Allows: l – – – Move objects (matrix multiplication) Move the camera (matrix multiplication) Compute lighting at vertices of triangle Project onto screen (3 D to 2 D) Clipping (avoid triangles outside screen) Map to window Tomas Akenine-Mőller © 2002
Application Geometry Rasterizer Animate objects and camera Can animate in many different ways with 4 x 4 matrices (topic of next lecture) l Example: l – l Before displaying a torus on screen, a matrix that represents a rotation can be applied. The result is that the torus is rotated. Same thing with camera (this is possible since motion is relative) Tomas Akenine-Mőller © 2002
Application Geometry Rasterizer The RASTERIZER stage l Main task: take output from GEOMETRY and turn into visible pixels on screen l Also, add textures and various other per-pixel operations And visibility is resolved here: sorts the primitives in the z-direction l Tomas Akenine-Mőller © 2002
Application Rewind! Let’s take a closer look Geometry Rasterizer The programmer ”sends” down primtives to be rendered through the pipeline (using API calls) l The geometry stage does per-vertex operations l The rasterizer stage does per-pixel operations l Next, scrutinize geometry and rasterizer l Tomas Akenine-Mőller © 2002
The GEOMETRY stage in more detail l l Geometry Rasterizer The model transform Originally, an object is in ”model space” Move, orient, and transform geometrical objects into ”world space” Example, a sphere is defined with origin at (0, 0, 0) with radius 1 – l Application Translate, rotate, scale to make it appear elsewhere Done per vertex with a 4 x 4 matrix multiplication! The user can apply different matrices over time to animate objects DEMO Tomas Akenine-Mőller © 2002
GEOMETRY The view transform Application Geometry Rasterizer You can move the camera in the same manner l But apply inverse transform to objects, so that camera looks down negative z-axis l DEMO z x Tomas Akenine-Mőller © 2002
Application GEOMETRY Lighting l Geometry Rasterizer Compute ”lighting” at vertices Rasterizer light blue Geometry red l Try to mimic how light in nature behaves – l green Hard to uses empirical models, hacks, and some real theory Much more about this in later lecture Tomas Akenine-Mőller © 2002
GEOMETRY Projection l Application Geometry Rasterizer Two major ways to do it – – Orthogonal (useful in few applications) Perspective (most often used) l Mimics how humans perceive the world, i. e. , objects’ apparent size decreases with distance Tomas Akenine-Mőller © 2002
GEOMETRY Projection Application Geometry Rasterizer Also done with a matrix multiplication! l Pinhole camera (left), analog used in CG (right) l Tomas Akenine-Mőller © 2002
Application Geometry GEOMETRY Clipping and Screen Mapping Rasterizer Square (cube) after projection l Clip primitives to square l l l Screen mapping, scales and translates square so that it ends up in a rendering window These ”screen space coordinates” together with Z (depth) are sent to the rasterizer stage Tomas Akenine-Mőller © 2002
GEOMETRY Summary model space compute lighting world space projection image space Application world space clip Geometry Rasterizer camera space map to screen Tomas Akenine-Mőller © 2002
The RASTERIZER more detail l Geometry Rasterizer in Scan-conversion – l Application Find out which pixels are inside the primitive Texturing – Put images on triangles Interpolation over triangle l Z-buffering l – Make sure that what is visible from the camera really is displayed Double buffering l And more… l Tomas Akenine-Mőller © 2002
The RASTERIZER Scan conversion Application Geometry Rasterizer Triangle vertices from GEOMETRY is input l Find pixels inside the triangle l – l Or on a line, or on a point Do per-pixel operations on these pixels: – – Interpolation Texturing Z-buffering And more… Tomas Akenine-Mőller © 2002
The RASTERIZER Interpolation l Application Geometry Rasterizer Interpolate colors over the triangle – Called Gouraud interpolation blue red green Tomas Akenine-Mőller © 2002
Application The RASTERIZER Texturing l Rasterizer One application of texturing is to ”glue” images onto geometrical object + l Geometry = Uses and other applications – – – More realism Bump mapping Pseudo reflections Store lighting Almost infinitely many uses DEMO Tomas Akenine-Mőller © 2002
Application The RASTERIZER buffering l Geometry Rasterizer Z- The graphics hardware is pretty stupid – It ”just” draws triangles However, a triangle that is covered by a more closely located triangle should not be visible l Assume two equally large tris at different depths l incorrect Triangle 1 Triangle 2 correct Draw 1 then 2 Draw 2 then 1 Tomas Akenine-Mőller © 2002
The RASTERIZER buffering Application Geometry Rasterizer Z- Would be nice to avoid sorting… l The Z-buffer (aka depth buffer) solves this l Idea: l – – – l Store z (depth) at each pixel When scan-converting a triangle, compute z at each pixel on triangle Compare triangle’s z to Z-buffer z-value If triangle’s z is smaller, then replace Z-buffer and color buffer Else do nothing DEMO Can render in any order Tomas Akenine-Mőller © 2002
The RASTERIZER Double buffering Application Geometry Rasterizer The monitor displays one image at a time l So if we render the next image to screen, then rendered primitives pop up l And even worse, we often clear the screen before generating a new image l A better solution is ”double buffering” l Tomas Akenine-Mőller © 2002
The RASTERIZER Double buffering Application Geometry Rasterizer Use two buffers: one front and one back l The front buffer is displayed l The back buffer is rendered to l When new image has been created in back buffer, swap front and back l Tomas Akenine-Mőller © 2002
And, lately… l Programmable shading has become a hot topic – – – Vertex shaders Pixel shaders Adds more control and much more possibilities for the programmer HARDWARE Application Geometry Vertex shader program Rasterizer Pixel shader program Tomas Akenine-Mőller © 2002
- Itcs 6114
- Itcs 6114
- Ecu itcs
- Ic primo levi bollate
- Primo levi the grey zone
- Giduk
- Why seasons
- External and internal combustion engine
- A formal approach to game design and game research
- Malay mancatcher trap diagram
- Sage game engine
- Ogre game engine tutorial
- Game engine for rts
- Acid game engine
- Gii game engine
- Game engine architecture
- Unreal engine game loop
- Core game maker
- Game engine architecture
- Renderware game engine
- Torque game engine
- Flame game engine
- Ist spring design and validation
- Analysisist
- Combustion process
- The pirate game
- The farming game rules
- Game lab game theory
- Liar game game theory
- Liar game game theory
- Mechanics dynamics aesthetics examples
- Systemic game design
- Oyun tasarım dökümanı
- The westing game anticipation guide
- Game development timeline