Presentation is loading. Please wait.

Presentation is loading. Please wait.

CGDD 4003 THE MASSIVE FIELD OF COMPUTER GRAPHICS.

Similar presentations


Presentation on theme: "CGDD 4003 THE MASSIVE FIELD OF COMPUTER GRAPHICS."— Presentation transcript:

1 CGDD 4003 THE MASSIVE FIELD OF COMPUTER GRAPHICS

2 TERMINOLOGY Rendering: the entire process of drawing an image to the screen Vertex: a single 3D vector (x, y, z) Edge: a line between two vertices Face: Most often 3 vertices and their edges Triangle: why a triangle? Simple Can linearly interpolate on them (later) Can construct other objects with them

3 THE GRAPHICS PIPELINE OVERVIEW Objects are made of primitives, and primitives are made of vertices (i.e. geometry) Vertex Processing (no triangles yet) Coordinate transformations into clip space [-1, 1] Compute color for each vertex (not pixel) Clipping and Primitive Assembly Clipping volume culls out geometry outside the frustum, and clips geo that straddles Assemble sets of vertices into lines and polygons Rasterization Determine which pixels are inside each polygon (primitive) The output is a set of fragments for each primitive Fragment Processing Fills in the pixels in the frame buffer (what you’re seeing right now!)

4 COORDINATE SYSTEMS We have a bunch of them Object space (or “local” space) – the space when the object is modeled World space – the “game” space where everything happens Camera space – the view of the world from the camera Screen space – the actual screen We transform the object from one space to the next Cameras have frustum defined by Near plane – objects closer than this cannot be seen Far plane – objects further can’t be seen Aspect ratio Clip space is the area inside of the frustum

5 BASIC PROBLEM We need to convert our 3D models and display them on a 2D screen To do this, we use projections by defining a viewing volume These “flatten” the 3D world There are two kinds: Orthographic (aka “parallel”) All objects that have the same dimension are the same size, regardless of distance Viewing volume is rectangular Perspective Objects shrink with distance Viewing volume is shaped like a pyramid

6 EXAMPLE (UPPER-RIGHT IS A PERSPECTIVE VIEW)

7 ORTHOGRAPHIC VIEW VOLUME (YOU CAN SEE THE PARALLEL NOW…) Near clipping plane Far clipping plane

8 PERSPECTIVE VIEW VOLUME Near clipping plane Far clipping plane

9 IT ALL STARTS WITH BUFFERS Frame buffer The memory where the visible screen is stored There’s only one Drawing directly to this memory can be detected by the user Back buffer A secondary buffer that you draw to Once everything is drawn, swap the buffer (pointer) or copy it!

10 IT ALL STARTS WITH BUFFERS Depth buffer (aka z-buffer ) Objects in the scene have a depth, and sorting is slow (aka “The Painter’s Algorithm”) When drawing each object, only update the pixel if the object is closer Stencil buffer A buffer that can reject on a per-pixel basis Irregular shapes on the screen

11 ALIASING http://i18.photobucket.com/albums/b106/mspeir/Grid.jpg

12 TRANSFORMATIONS Translate Rotate Scale

13 TERMINOLOGY Wireframe – rendering only the edges of the model (old games)

14 TERMINOLOGY Hidden Surface Removal (HSR) – occluded objects can’t be seen Backface culling - drawing only the triangles that are facing the camera

15 BACKFACE CULLING

16 TERMINOLOGY Solid shading (this isn’t a definition)

17 TERMINOLOGY Flat Shading – simulate lighting

18 TERMINOLOGY A texture is an image (e.g.a jpg or procedurally generated) Texture mapping – using an image during the rasterization process

19 TERMINOLOGY – THE BLOCK PROGRAM Blending – mixing colors by rendering more than one thing in one spot The floor is rendered semi-transparent (yes, there are two cubes)

20 SHADERS AND MATERIALS No more fixed-function pipeline When you render a triangle, you run a vertex and pixel shader Shaders are small programs used to process: A vertex – translate, rotate, scale, etc… A pixel (or fragment)– determines the final color of a pixel using textures, light colors, normal of the plane, etc… Common languages: GLSL (OpenGL), Cg, HLSL (Microsoft) A material is the combination of shaders, textures, normals, colors, reflectivity that will determine the final color

21 GRAPHIC ORGANIZATION Rendering should be separate from game logic Hardware differs on each machine A render object is something that is renderable (duh) There is only one description of it (saving geometry) A flock of birds is still just one bird Render object instances Use a render object Save a state for each instance on the screen (e.g. location, animation state) We typically cull objects (i.e. prevent them from drawing) if: They are behind the camera Outside the frustum

22 CHARACTERS A mesh is a collection of triangles Can be one mesh Can be hierarchical (i.e. one object can have multiple meshes) A skeleton describes how a mesh will be deformed for animation

23 LIMITING WHAT WE RENDER View frustum Near and far planes and clipping outside the frustum Cull when possible (render volume partitioning) Portals (how many portals are visible? Think of windows and doors) Binary Space Partitions (BSPs) – a tree structure representing all of the game space Each node does not intersect with any other node If a node isn’t visible, neither is its child! Quad/Oct Trees – extensions of BSPs Potentially Visible Sets (PVSs) – each node has a list of other nodes

24 BSPS Wikipedia

25 QUADTREE PARTITIONING Collision detection Outdoor visibility checking Algorithm (2D): X/Y : consider bits Left shift at each level in tree When at leaf, stop

26 QUADTREE VISUALIZED

27 GRAPHIC PRIMITIVES Note: there are also point sprites for particle systems

28 MESH AS TRIANGLE STRIP

29 VERTEX AND INDEX BUFFERS How many vertices in a cube? How many faces in a cube? How many triangles in a cube? Usually twice as many triangles as vertices Typically, vertices are stored in a buffer and are numbered (0…n-1) There is a separate list for faces This list still has a type (triangle list, strip, etc…) E.g. - a triangle could be made from vertices 0, 4, 5 Called “indices” in an “index buffer”

30 INDEXED STRIPS First strip is 5, 0, 6, 1, 7, 2, 8, 3, 9, 4. Second is 10, 5, 11, 6, 12, 7, 13, 8, 14, 9 Also, once a vertex has been processed, it may be cached (speedup)

31 TEXTURE MAPPING Applying an image to geometry 2D images (rectangular) 3D images (volumetric – such as a CAT scan) Cube mapping Adds realism to the scene Vertices have additional information: A 3D position Normals (for lighting) UV coordinates (for textures)

32 UV COORDINATES (AKA TEXTURE COORDINATES) (0, 0)(1, 0) (1, 1)(0, 1) (1, 1)(0, 1) (0, 0)(1, 0) Polygon to be textured

33 UV COORDINATES (AKA TEXTURE COORDINATES) (0, 0)(1, 0) (1, 1)(0, 1) (1, 1)(0, 1) (0, 0)(1, 0) Note: there is a linear interpolation of all the in-between UV coordinates!

34 UV COORDINATES (AKA TEXTURE COORDINATES) (0, 0)(1, 0) (1, 1)(0, 1) (1, 1)(0, 1) (0, 0)(1, 0)

35 UV COORDINATES (AKA TEXTURE COORDINATES) (0, 0)(1, 0) (1, 1)(0, 1) (1, 1)(0, 1) (0, 0)(1, 0)

36 WHAT HAPPENS NOW? (0, 0)(1, 0) (1, 1)(0, 1) (2, 2)(0, 2) (0, 0)(2, 0) Polygon to be textured

37 WHAT HAPPENS NOW? (0, 0)(1, 0) (1, 1)(0, 1) (2, 2)(0, 2) (0, 0)(2, 0) Polygon to be textured

38 WHAT ABOUT NOW? (0, 0)(1, 0) (1, 1)(0, 1)

39 APPLYING TEXTURES

40 ADDITIONAL TEXTURING Point sampling Bilinear filtering (when magnifying) Averages 4 pixels based on distance Mipmapping Halving the size of the texture Can cause pops when switching Trilinear filtering Uses bilinear filtering Interpolates between mipmaps

41 LIGHTING http://machinesdontcare.wordpress.com/2008/06/ http://www.directxtutorial.com/Tutorial9/B-Direct3DBasics/dx9B3.aspx

42 MODELING

43 MODELING (CONT)

44 USING NORMAL MAPS AND TEXTURES

45 NORMAL MAPS AND LOD http://www.inition.co.uk/inition/product.php?SubCatID_=38&URL_=product_ffhaptic_sensable_claytools

46 HTTP://UPLOAD.WIKIMEDIA.ORG/WIKIPEDIA/COMMONS/3/36/NORMAL_MAP_EXA MPLE.PNG

47 LEVEL OF DETAIL Hardware limits number of polys rendered Use high-level models when possible Drop to low poly models (LOD) when needed

48 LEVEL EDITING Target fixed poly count (thought allow for flexibility and customization)

49 LOW-POLY COUNT MODELING

50 FINAL THOUGHTS Major difference in modeling and using models Art & programming & level/character design Take graphics in Spring!


Download ppt "CGDD 4003 THE MASSIVE FIELD OF COMPUTER GRAPHICS."

Similar presentations


Ads by Google