Game Graphics Programmers

Similar documents
Game Graphics Programmers

Game Graphics Programmers

GUERRILLA DEVELOP CONFERENCE JULY 07 BRIGHTON

The Application Stage. The Game Loop, Resource Management and Renderer Design

Applications of Explicit Early-Z Z Culling. Jason Mitchell ATI Research

Deferred Rendering Due: Wednesday November 15 at 10pm

Graphics Processing Unit Architecture (GPU Arch)

Sign up for crits! Announcments

CS 354R: Computer Game Technology

Rasterization Overview

Bringing AAA graphics to mobile platforms. Niklas Smedberg Senior Engine Programmer, Epic Games

Building scalable 3D applications. Ville Miettinen Hybrid Graphics

Real-Time Universal Capture Facial Animation with GPU Skin Rendering

CMSC427 Advanced shading getting global illumination by local methods. Credit: slides Prof. Zwicker

Optimizing and Profiling Unity Games for Mobile Platforms. Angelo Theodorou Senior Software Engineer, MPG Gamelab 2014, 25 th -27 th June

Computer Graphics (CS 543) Lecture 10: Soft Shadows (Maps and Volumes), Normal and Bump Mapping

Real-Time Rendering (Echtzeitgraphik) Michael Wimmer

Computer Graphics (CS 543) Lecture 10: Normal Maps, Parametrization, Tone Mapping

Models and Architectures

Computer Graphics. Shadows

A Trip Down The (2011) Rasterization Pipeline

Computer Graphics 10 - Shadows

Render-To-Texture Caching. D. Sim Dietrich Jr.

Enhancing Traditional Rasterization Graphics with Ray Tracing. March 2015

Computergrafik. Matthias Zwicker. Herbst 2010

Last Time. Why are Shadows Important? Today. Graphics Pipeline. Clipping. Rasterization. Why are Shadows Important?

Shaders. Slide credit to Prof. Zwicker

Bringing Hollywood to Real Time. Abe Wiley 3D Artist 3-D Application Research Group

Lets assume each object has a defined colour. Hence our illumination model is looks unrealistic.

Shadow Rendering EDA101 Advanced Shading and Rendering

Tutorial on GPU Programming #2. Joong-Youn Lee Supercomputing Center, KISTI

Could you make the XNA functions yourself?

For Intuition about Scene Lighting. Today. Limitations of Planar Shadows. Cast Shadows on Planar Surfaces. Shadow/View Duality.

Rendering Algorithms: Real-time indirect illumination. Spring 2010 Matthias Zwicker

Game Technology. Lecture Physically Based Rendering. Dipl-Inform. Robert Konrad Polona Caserman, M.Sc.

Shadow Techniques. Sim Dietrich NVIDIA Corporation

X. GPU Programming. Jacobs University Visualization and Computer Graphics Lab : Advanced Graphics - Chapter X 1

Attention to Detail! Creating Next Generation Content For Radeon X1800 and beyond

Recall: Indexing into Cube Map

graphics pipeline computer graphics graphics pipeline 2009 fabio pellacini 1

Module 13C: Using The 3D Graphics APIs OpenGL ES

The Vegetation of Horizon Zero Dawn. Gilbert Sanders Principal Artist, Guerrilla Games

Spring 2009 Prof. Hyesoon Kim

graphics pipeline computer graphics graphics pipeline 2009 fabio pellacini 1

Programming shaders & GPUs Christian Miller CS Fall 2011

Introduction to Computer Graphics with WebGL

DEFERRED RENDERING STEFAN MÜLLER ARISONA, ETH ZURICH SMA/

TDA362/DIT223 Computer Graphics EXAM (Same exam for both CTH- and GU students)

CSE 167: Introduction to Computer Graphics Lecture #13: GLSL. Jürgen P. Schulze, Ph.D. University of California, San Diego Fall Quarter 2015

Real-Time Shadows. Computer Graphics. MIT EECS Durand 1

TSBK03 Screen-Space Ambient Occlusion

Computer Graphics Shadow Algorithms

3D Rendering Pipeline

Graphics Hardware, Graphics APIs, and Computation on GPUs. Mark Segal

Enabling immersive gaming experiences Intro to Ray Tracing

Graphics Performance Optimisation. John Spitzer Director of European Developer Technology

PowerVR Hardware. Architecture Overview for Developers

Programmable Graphics Hardware

OpenGl Pipeline. triangles, lines, points, images. Per-vertex ops. Primitive assembly. Texturing. Rasterization. Per-fragment ops.

Rendering Objects. Need to transform all geometry then

Introduction to Shaders.

Graphics Hardware. Instructor Stephen J. Guy

Introduction to Visualization and Computer Graphics

Introduction to the OpenGL Shading Language

Graphics Hardware. Graphics Processing Unit (GPU) is a Subsidiary hardware. With massively multi-threaded many-core. Dedicated to 2D and 3D graphics

Rendering. Converting a 3D scene to a 2D image. Camera. Light. Rendering. View Plane

The Rasterization Pipeline

Pipeline Operations. CS 4620 Lecture Steve Marschner. Cornell CS4620 Spring 2018 Lecture 11

Last Time. Reading for Today: Graphics Pipeline. Clipping. Rasterization

Z-Buffer hold pixel's distance from camera. Z buffer

1.2.3 The Graphics Hardware Pipeline

C P S C 314 S H A D E R S, O P E N G L, & J S RENDERING PIPELINE. Mikhail Bessmeltsev

Real-Time Shadows. MIT EECS 6.837, Durand and Cutler

Spring 2011 Prof. Hyesoon Kim

Optimizing Games for ATI s IMAGEON Aaftab Munshi. 3D Architect ATI Research

Dominic Filion, Senior Engineer Blizzard Entertainment. Rob McNaughton, Lead Technical Artist Blizzard Entertainment

RSX Best Practices. Mark Cerny, Cerny Games David Simpson, Naughty Dog Jon Olick, Naughty Dog

Rasterization and Graphics Hardware. Not just about fancy 3D! Rendering/Rasterization. The simplest case: Points. When do we care?

Programming Graphics Hardware

Real-Time Shadows. Last Time? Today. Why are Shadows Important? Shadows as a Depth Cue. For Intuition about Scene Lighting

Designing the look and feel for Smoke and Neon powers The creation of a new toolset and pipeline for I:SS Pros and cons from our new workflow and

Illumination and Geometry Techniques. Karljohan Lundin Palmerius

Enhancing Traditional Rasterization Graphics with Ray Tracing. October 2015

Introduction to OpenGL

Next-Generation Graphics on Larrabee. Tim Foley Intel Corp

Wed, October 12, 2011

Pipeline Operations. CS 4620 Lecture 14

Scanline Rendering 2 1/42

Shaders in Eve Online Páll Ragnar Pálsson

Point based global illumination is now a standard tool for film quality renderers. Since it started out as a real time technique it is only natural

Shadows in the graphics pipeline

2.11 Particle Systems

Squeezing Performance out of your Game with ATI Developer Performance Tools and Optimization Techniques

Real-Time Shadows. Last Time? Schedule. Questions? Today. Why are Shadows Important?

Broken Age's Approach to Scalability. Oliver Franzke Lead Programmer, Double Fine Productions

Real-Time Shadows. Last Time? Textures can Alias. Schedule. Questions? Quiz 1: Tuesday October 26 th, in class (1 week from today!

CSE 167: Lecture #8: GLSL. Jürgen P. Schulze, Ph.D. University of California, San Diego Fall Quarter 2012

CS GPU and GPGPU Programming Lecture 2: Introduction; GPU Architecture 1. Markus Hadwiger, KAUST

Optimizing DirectX Graphics. Richard Huddy European Developer Relations Manager

Programmable GPUs. Real Time Graphics 11/13/2013. Nalu 2004 (NVIDIA Corporation) GeForce 6. Virtua Fighter 1995 (SEGA Corporation) NV1

Transcription:

Graphics 1

Introduction A Glimpse into what Game Graphics Programmers do System level view of Graphics Architectures & Pipeline Intro to Commonly used Rendering Techniques in Games 2

Game Graphics Programmers Create infrastructure to realize artistic vision of product Works closely with Art Director Works closely with Artist to define art production requirements Utilize the hardware and APIs of the target platforms Integrate renderer with other game components Art pipeline, AI, front-end etc. Achieve interactive performance Work with memory constraints

What do you see? Info Here

How would you render this? Lot s going on here: Objects (Car, Road, Ground, Bushes, Driver) Sky Lighting (direct and indirect) Material properties transparency, specular Reflections Shadows Motion Blur Color correction

Deconstruct the Art Direction: What do you see? Info Here (To switch between regular layout page 1 and 2 right click on the slide goto> Layout and pick the other version from the graphic representation of the different pages)

What do you see? Overall Style: Photorealistic Realistic materials High contrast lighting bright lights & deep shadows Light sources at ground level and shadows deepen upwards Saturated bright signs Many small & coloured light sources Atmospheric High-detail, dilapidated buildings & streets Reflective, wet looking streets Night-sky Several characters in foreground

Rendering Requirements Direct lighting Spot lights, Point lights, Light cards Indirect lighting Bounced light at ground level Static vs Dynamic light sources HDR? Ambient occlusion Billboard for Light Volumes Skybox alpha Emissive shader on Signs Support animated textures? Reflection maps buildings & sky reflection Level of detail, Fog

Art Production Requirements Efficiently generate buildings & varied store fronts Generating reusable materials shader + textures Decide Geo vs Texture detail Create signage props Prop variety for street Workflow for placing lights & signs Solution for creating light volumes e.g. camera-aligned billboards Pipeline for Static lights Scalable texturing solution for applying Grime textures Build art for multiple level of details how many, budget constraints?

Rendering Pipeline Objectives: Quick Overview of Depth-Buffered Triangle Rasterization Programmable Pipeline 10

Elements of a Renderer Offline Tools Content Tools Asset Conditioning Scene Management Submit Rendering Geometry Processing Rasterization Art Pipeline CPU GPU

Art Creation & Pipeline Artists create resources Models Textures Shaders? Assets generally need some offline processing to be ready for in game use Export of geometry Optimization of geometry Texture compression Shader compilation Etc. PC may not be able to do some stuff in art pipeline

Scene Management Visibility Determination Frustum Culling quickly reject objects that lie outside the frustum Occlusion Culling quickly reject objects that are in the frustrum but cover Linear sort probably good enough, but there are some more exotic data structures (Octree, KD-tree, etc.) Level of Detail Management Replace an object with simpler form when object is small on the screen May involve simplifying shaders, animation, mesh Translucency sorting z-buffer will handle out of order draws of opaque stuff Translucent stuff needs to be manually sorted

Submit geometry to GPU for rendering Iterate through list of visible objects Iterate over each submesh-material pair Set render state based on material s specification Set vertex and pixel shaders Set uniforms (parameters to shaders) Set a few other state elements (clipping, alpha blending) Set vertex and index buffers Call DrawIndexPrimitive() or gldrawarray()

Performance Graphics hardware is deeply pipelined & highly parallelized Submit large vertex buffers Avoid state switching Reading from render targets causes stalls Rendering Engine Design considerations: Don t chop the world up too finely Reduce draw calls Even at expense of drawing more off-screen Batching by state: Sort primitives by material type Minimize data access by CPU: Geometry, Textures, Display lists, Positions are uploaded to VRAM once per frame

Vertic es GPU Pipeline Vertex Shader Transformation from Model Space to View Space Vertices Primitive Assembly Assemble polygons from vertex and index buffer Polygons Clipping Clip polygons to the edges of the view volume Polygons Triangle Setup & Rasterization Triangles are Rasterized into Fragments Interpolated fragment values Pixel Shader Compute fragment s color Final fragment color Merge/ROP Write Alpha/Blend Color to Framebuffer Framebuffer

Programmable vs. Fixed Function DX7/OpenGL 1.4/OpenGL ES 1.x and earlier hardware used fixed function vertex processing Select from a limited set of states to configure processing of components PS2, Xbox Modern hardware is programmable at the Vertex & Fragment level PS3, Xbox 360 (but not Wii) Specialized instructions can be executed for each vertex (Vertex Shaders) or fragment (Pixel Shaders) Why do we care? Need to be aware of what portions API are legacy, particularly with OpenGL.

Vertex Components Position, colour, texture, normals, etc. For programmable processing, components of a vertex are defined by the Engine // simple vertex format struct Vertex { } float3 pos; float3 normalws; float3 tangentws; float3 color;// vertex color float2 uv0 // texcoords for diffuse, specular & normal map float2 uv1 // secondary texcoords e.g. for grime map lookup

Geometry Primitives: Triangle Lists Simply lists the vertices in groups of 3 Lots of duplicate vertices MSDN Direct3D Reference

Geometry Primitives: Strips & Fans Triangle Strips & Fans Generated by offline tools Reduce vertex duplication Predefined vertex orders MSDN Direct3D Reference

Geometry Primitives: Index Triangle Lists Commonly used particularly with Programmable pipelines Required to take advantage of GPU vertex caching MSDN Direct3D Reference

Break 22

Programmable Shaders Shader program accesses data by 2 methods: Registers Input & Constant Input come from vertex stream, constants (uniforms) are set from calling code Texture Maps Input registers can be passed between vertex and pixel shaders ( varying ) Supports vector and matrix types intrinsically e.g. float3, float4 Float x[4] is not same as float4 x ALU performs math operations on 3 or 4 components in a single instruction Registers are 128 bit wide Avoid use of Conditional Logic

Example vertex shader varying vec3 normal; varying vec3 vertex_to_light_vector; void main() { // Transforming The Vertex gl_position = gl_modelviewprojectionmatrix * gl_vertex; // Transforming The Normal To ModelView-Space normal = gl_normalmatrix * gl_normal; // Transforming The Vertex Position To ModelView-Space vec4 vertex_in_modelview_space = gl_modelviewmatrx * gl_vertex; } // Calculating The Vector From The Vertex Position To The Light Position vertex_to_light_vector = vec3(gl_lightsource[0].position ñ vertex_in_modelview_space);

Example fragment shader varying vec3 normal; varying vec3 vertex_to_light_vector; void main() { // Defining The Material Colors const vec4 AmbientColor = vec4(0.1, 0.0, 0.0, 1.0); const vec4 DiffuseColor = vec4(1.0, 0.0, 0.0, 1.0); // Scaling The Input Vector To Length 1 vec3 normalized_normal = normalize(normal); vec3 normalized_vertex_to_light_vector = normalize(vertex_to_light_vector); // Calculating The Diffuse Term And Clamping It To [0;1] float DiffuseTerm = clamp(dot(normal, vertex_to_light_vector), 0.0, 1.0); } // Calculating The Final Color gl_fragcolor = AmbientColor + DiffuseColor * DiffuseTerm;

Xbox360 GPU Architecture Cross, Jason (2005-05-20). "Xbox 360 GPU Details". ExtremeTech..

Graphics Hardware Performance Vertex Processing Rate Depends on GPU clock rate & number of vertex ALUs available No of vertex shader instructions Fragment processing rate Depends on GPU clock rate + number of ALUs available No. of pixel shader instructions Pixel processing, texture fetch rate Depends on GPU/VRAM bandwidth Note: Xbox360 and Playstation 3 have 40+ ALUs on chip both are massively parallel architectures

Lighting Defines the look of the Environment Many techniques As much Art as Science 28

Uses of Lighting Can t see anything without lights Directs the viewer s eye Creates depth Conveys time-of-day and season Conveys mood, atmosphere and drama Express character s inner state

Basic Lighting Calculation Lighting algorithms are concerned with: Properties of the lights : Color, Intensity, Shape, Fall-off Properties of the Surface: Shininess, Roughness, Color, Transparency, Refraction Index Blinn/Phong lighting model Intensity = Ambient + Diffuse + Specular Implemented in Pixel Shader Allows lighting interaction to be specified per Material Can model more advanced interactions by having a depth map e.g. to model subsurface scattering

Light Sources Dynamic Lights Direct lighting is Computed per frame at runtime Dynamic game objects will receive light Points, Directional, Spot Static Lights Used to light Environment Captures Direct and/or Indirect lighting Compute Offline & Store e.g. Vertex colors, light maps, Spherical Harmonics Coefficients, Use a Combination of Techniques E.g. Emissive objects May have special lights for characters and worlds, and small subset that affect both

Image Based Lighting Approaches Modern games make use of image data for Lighting Specular Maps Normal Maps Environment Cube Maps Ambient occlusion maps

Normal Maps Normal vectors are encoded in RGB color channels Transformed from Tangent to World Space for lighting computation More Surface detail with less Geo Without Normal Map With Normal Map created by David Maas

Environment Maps A cube map generated from 6 directions Map on to the 6 inner surfaces of a box at infinity Use to render reflections on reflective surfaces e.g. window panes Can be used for: Specular Color: Approximate roughness by sampling in lower mips Luminance : If cube map is HDR

Ambient Occlusion Maps Describes how much light each point of a surface receives when uniformly lit Computed with offline tools Construct a hemisphere with large radius centered Determine what percentage of the hemisphere s area is visible from the point

Lots of dynamic lights Gamer: Oh, Crap! Look at all those bad guys! Rendering Programmer: Oh, crap! Look at all those dynamic lights!

Lots of dynamic lights Real world has lots of lights in it Light maps let you have as many Static lights as you want But what we really want is lots of Dynamic lights Hard to get lots of dynamic lighting with conventional techniques You tend to end up paying for it even when not benefiting But, when there are lots of lights they tend to be small If we only render pixels touched by given light, cost is manageable

Deferred Rendering The way to do this is to separate surface property calculation and lighting Components needed in the lighting calculation are stored in intermediate buffers (per pixel) e.g. Diffuse color Specular power, intensity Normals Depth Lighting computation is done in Screen-space once per pixel

Geometry Pass: Render scene geometry, write lighting components to G-Buffers

Light Accumulation Pass: Initialize light accumulation buffer with baked lighting components Determine lit pixels Render pixels affected by each light, and accumulate

Shadows Commonly used techniques 41

Where did this guy jump from and how far is he off the ground?

GDC 2010: Shadow mapping

Shadows Grounds objects in the scene Generally it is better to have an inaccurate shadow than none at all Gives hint of how high the object is from the ground Most commonly used techniques: Projected blob Projected texture Shadow volumes Shadow maps

Technique #1: Blobs Raycast to ground Draw textured quad Scale quad based on object s height Multiple blobs for articulated objects E.g. One per leg Stretch and squash shadow based on object speed

Regular layout 2 (no arcade box) Info Here (To switch between regular layout page 46

Technique #2: Projected Texture Render shadow caster from perspective of light sources into a temporary buffer Often use lower-complexity model Project result onto shadow-receiving surfaces in the world Similar to blob but requires an extra rendering pass Watch for aliasing

48

Technique #3: Stencil Volumes Compute silhouette edges of geometry with respect to light Extrude edges in the direction of the light rays Draw scene to framebuffer updating z-buffer Clear stencil buffer (zero out)

Stencil Volume (cont d) Turn of z-writes Draw front-facing polys of shadow volume (from Camera view point) front face of volume : Increment Stencil buffer Draw back-facing polys of shadow volume (from Camera view point) back face of volume : Decrement Stencil buffer If the backface of the shadow volume is not drawn ( fragment fails z-test), then Stencil buffer value = +1 Darken fragments where stencil is not zero.

Stencil Volume: Pros & Cons Pros Works for arbitrary surfaces Handles self-shadowing nicely Cons Hard edges Silhouette edge calculation is expensive GPU intensive (vertex processing, rendertarget writes & reads)

Technique #4: Shadow Maps Render scene from point of view of the light Save the depth buffer as a texture Shadow map texture contains z-depth objects closest to it

Shadow Map (cont d) Render the scene from point of view of Camera. For each Vertex: Transform Vertex Position to Light Space. Interpolate Light Space coordinates between Vertices Fragment Position in Light Space Convert Light Space x,y coordinates to u,v Compare Light Space z depth with depth stored in corresponding texel of the shadow map

Shadow Maps: Challenges Can suffer from severe aliasing problems Need large shadow maps Pre or post filter shadow to reduce aliasing (also gives fot shadows) Expensive: Multiple passes required

Frame buffer effects 56

FrameBuffer Effects Utilize rendered data as a texture for subsequent operations Render-to-texture, frame-buffer-as-texture Examples: Motion blur Depth-of-field Copy rendered frame to off-screen buffer, and blur Using z-buffer as a mask, copy blurred frame to rendered frame Refraction / reflection (Predator effect, heat shimmer, water surface) Render or copy to offscreen buffer Composite with perturbed texture co-ordinates Colour correction

Guerrilla Games Killzone 2 Presentation

Color correction Leading Game Engines now do this Valve, Killzone2 Technique commonly used in Film but gaining popularity in games Primary goal same as in film: Creative control over look to manipulate the mood of the viewer Call attention to important visual elements Easy to art direct & allows for changes late in production In games: can't tweak color with same precision since scene content changes in unpredictable ways from frame to frame Can be used to implement dynamic game state (such as player's health)

Color LUTs Color look up table Represent the RGB color space as a 3D texture 32 x 32 x 32 pixels (8 bit color) Use input RGB (from framebuffer ), look new color in LUT Can be authored: Offline Using in-game Photoshop-like GUI e.g. Valve's Source Engine

Color Enhancement for Video Games Siggraph 09 (Used with permission fr author) 61

Authoring LUTs Out-of-Engine Create an identity LUT Flatten (e.g.) 32 x 32 x 32 cube into 1024 x 32 strip Grab (uncorrected) screenshot from the game and paste identity LUT strip on it Give screenshot + LUT strip to artist to perform color manipulations in external app Convert strip back to 3D LUT, import into engine

Color Enhancement for Video Games Siggraph 09 (Used with permission from author)

Other stuff to be aware of Billboards and particles Quads that are aligned to the camera Maybe only along one axis Particle system implies a group of them that are simulated Velocity, gravity Can do a lot in hardware with vertex shader and point sprites Skinning Continuous mesh with vertices weighted to a skeleton Complicated vertex transform that combines matrices Can be done on GPU, but often done on CPU for performance reasons Display latency

Wrap up Graphics programming is a synthesis of many disciplines Know the hardware Know the techniques Many and varied Follow the research Look at other games Check out the demos on Nvidia, and ATI's sites Read Real-Time Rendering (Akenine-Moller, Haines, Hoffman)