Chapter 5.1 GraphicsOverviewFundamentalsFrame and Back BufferVisibility and Depth BufferStencil BufferTrianglesVerticesCoordinate SpacesCoordinate Spaces (2)Coordinate Spaces (3)Coordinate Spaces (4)TexturesShadersMaterialsHigh-Level OrganizationGameplay and RenderingRender ObjectsRender InstancesMeshesSkeletonsVolume PartitioningVolume Partitioning - PortalsVolume Partitioning – PortalsSlide 25Slide 26Slide 27Slide 28Slide 29Slide 30Slide 31Slide 32Volume Partitioning – BSPSlide 34Volume Partitioning: QuadtreeSlide 36Volume Partitioning - PVSSlide 38Slide 39Rendering PrimitivesStrips, Lists, FansStrips, Lists, Fans (2)Strips, Lists, Fans (3)Strips, Lists, Fans (4)Indexed PrimitivesThe Vertex CacheThe Vertex Cache (2)Quads and Point SpritesSlide 49Texture FormatsTexture Formats (2)Texture Formats (3)Texture Formats (4)Texture MappingTexture Mapping (2)Texture FilteringTexture Filtering (2)Texture Filtering (3)Rendering to TexturesLightingComponentsLighting EnvironmentLighting Environment (2)Multiple LightsMultiple Lights (2)Multiple Lights (3)Multiple Lights (4)Diffuse Material LightingNormal MapsPre-computed Radiance TransferSlide 71Slide 72Specular Material LightingSpecular Material Lighting (2)Specular Material Lighting (3)Specular Material Lighting (4)Environment MapsEnvironment Maps - 2Environment Maps - 3Hardware Rendering PipeSlide 81Input AssemblyVertex ShadingPrimitive Assembly, Cull, ClipProject, RasterizePixel ShadingZ, Stencil, Framebuffer BlendShader CharacteristicsShader LanguagesConclusionsConclusions (2)Chapter 5.1Graphics2OverviewFundamentalsHigh-Level OrganizationRendering PrimitivesTexturesLightingThe Hardware Rendering PipelineConclusions3FundamentalsFrame and Back BufferVisibility and Depth BufferStencil BufferTrianglesVerticesCoordinate SpacesTexturesShadersMaterials4Frame and Back BufferBoth hold pixel colorsFrame buffer is displayed on screenBack buffer is just a region of memoryImage is rendered to the back bufferHalf-drawn images are very distractingSwapped to the frame bufferMay be a swap, or may be a copyBack buffer is larger if anti-aliasingShrink and filter to frame buffer5Visibility and Depth BufferDepth buffer is same size as back bufferHolds a depth or “Z” valueOften called the “Z buffer”Pixels test their depth against existing valueIf greater, new pixel is further than existing pixelTherefore hidden by existing pixel – rejectedOtherwise, is in front, and therefore visibleOverwrites value in depth buffer and color in back bufferNo useful units for the depth valueBy convention, nearer means lower valueNon-linear mapping from world space6Stencil BufferUtility bufferUsually eight bits in sizeUsually interleaved with 24-bit depth bufferCan write to stencil bufferCan reject pixels based on comparison between existing value and referenceMany uses for masking and culling7TrianglesFundamental primitive of pipelinesEverything else constructed from them(except lines and point sprites)Three points define a planeTriangle plane is mapped with dataTexturesColors“Rasterized” to find pixels to draw8VerticesA vertex is a point in spacePlus other attribute dataColorsSurface normalTexture coordinatesWhatever data shader programs needTriangles use three verticesVertices shared between adjacent triangles9Coordinate SpacesWorld spaceArbitrary global game spaceObject spaceChild of world spaceOrigin at entity’s position and orientationVertex positions and normals stored in thisCamera spaceCamera’s version of “object” space10Coordinate Spaces (2)Clip spaceDistorted version of camera spaceEdges of screen make four side planesNear and far planesNeeded to control precision of depth bufferTotal of six clipping planesDistorted to make a cube in 4D clip spaceMakes clipping hardware simpler11Coordinate Spaces (3)EyeTriangles will be clippedCameraspacevisiblefrustumClipspacefrustum12Coordinate Spaces (4)Screen spaceClip space vertices projected to screen spaceActual pixels, ready for renderingTangent spaceDefined at each point on surface of meshUsually smoothly interpolated over surfaceNormal of surface is one axis“tangent” and “binormal” axes lie along surfaceTangent direction is controlled by artistUseful for lighting calculations13TexturesArray of texelsSame a pixel, but for a textureNominally R,G,B,A but can mean anything1D, 2D, 3D and “cube map” arrays2D is by far the most commonBasically just a 2D image bitmapOften square and power-of-2 in sizeCube map - six 2D arrays makes hollow cubeApproximates a hollow sphere of texels14ShadersA program run at each vertex or pixelGenerates pixel colors or vertex positionsRelatively small programsUsually tens or hundreds of instructionsExplicit parallelismNo direct communication between shaders“Extreme SIMD” programming modelHardware capabilities evolving rapidly15MaterialsDescription of how to render a triangleBig blob of data and stateVertex and pixel shadersTexturesGlobal variablesDescription of data held in verticesOther pipeline stateDoes not include actual vertex data16High-Level OrganizationGameplay and RenderingRender ObjectsRender InstancesMeshesSkeletonsVolume Partitioning17Gameplay and RenderingRendering speed varies according to sceneSome scenes more complex than othersTypically 15-60 frames per secondGameplay is constant speedCamera view should not change gameIn multiplayer, each person has a different view, but there is only one shared game1 update per second (RTS) to thousands (FPS)Keep the two as separate as possible!18Render ObjectsDescription of renderable object typeMesh data (triangles, vertices)Material data (shaders, textures, etc)Skeleton (+rig) for animationShared by multiple instances19Render InstancesA single entity in a worldReferences a render objectDecides what the object looks likePosition and orientationLighting stateAnimation state20MeshesTrianglesVerticesSingle material“Atomic unit of rendering”Not quite atomic, depending on hardwareSingle object may have multiple meshesEach with different shaders, textures, etc21SkeletonsSkeleton is a
View Full Document