CS-378: Game Technology Lecture #9: More Mapping Prof. Okan Arikan University of Texas, Austin Thanks to James O’Brien, Steve Chenney, Zoran Popovic, Jessica.

Slides:



Advertisements
Similar presentations
CS-378: Game Technology Lecture #1: Scan Conversion Prof. Okan Arikan University of Texas, Austin Thanks to James O’Brien, Steve Chenney, Zoran Popovic,
Advertisements

Understanding the graphics pipeline Lecture 2 Original Slides by: Suresh Venkatasubramanian Updates by Joseph Kider.
Graphics Pipeline.
9/25/2001CS 638, Fall 2001 Today Shadow Volume Algorithms Vertex and Pixel Shaders.
The Programmable Graphics Hardware Pipeline Doug James Asst. Professor CS & Robotics.
CS5500 Computer Graphics © Chun-Fa Chang, Spring 2007 CS5500 Computer Graphics April 19, 2007.
A Crash Course on Programmable Graphics Hardware Li-Yi Wei 2005 at Tsinghua University, Beijing.
The Graphics Pipeline CS2150 Anthony Jones. Introduction What is this lecture about? – The graphics pipeline as a whole – With examples from the video.
Game Engine Design ITCS 4010/5010 Spring 2006 Kalpathi Subramanian Department of Computer Science UNC Charlotte.
The programmable pipeline Lecture 10 Slide Courtesy to Dr. Suresh Venkatasubramanian.
Vertex & Pixel Shaders CPS124 – Computer Graphics Ferdinand Schober.
3D computer graphic Basis for real-time rendering and GPU architecture 劉哲宇,Liou Jhe-Yu.
GPU Graphics Processing Unit. Graphics Pipeline Scene Transformations Lighting & Shading ViewingTransformations Rasterization GPUs evolved as hardware.
Computer Graphics: Programming, Problem Solving, and Visual Communication Steve Cunningham California State University Stanislaus and Grinnell College.
Under the Hood: 3D Pipeline. Motherboard & Chipset PCI Express x16.
REAL-TIME VOLUME GRAPHICS Christof Rezk Salama Computer Graphics and Multimedia Group, University of Siegen, Germany Eurographics 2006 Real-Time Volume.
Under the Hood: 3D Pipeline. Motherboard & Chipset PCI Express x16.
GPU Programming Robert Hero Quick Overview (The Old Way) Graphics cards process Triangles Graphics cards process Triangles Quads.
Programmable Pipelines. Objectives Introduce programmable pipelines ­Vertex shaders ­Fragment shaders Introduce shading languages ­Needed to describe.
Real-time Graphical Shader Programming with Cg (HLSL)
Geometric Objects and Transformations. Coordinate systems rial.html.
Graphics Graphics Korea University cgvr.korea.ac.kr 1 Using Vertex Shader in DirectX 8.1 강 신 진
Programmable Pipelines. 2 Objectives Introduce programmable pipelines ­Vertex shaders ­Fragment shaders Introduce shading languages ­Needed to describe.
Chris Kerkhoff Matthew Sullivan 10/16/2009.  Shaders are simple programs that describe the traits of either a vertex or a pixel.  Shaders replace a.
A Crash Course in HLSL Matt Christian.
09/09/03CS679 - Fall Copyright Univ. of Wisconsin Last Time Event management Lag Group assignment has happened, like it or not.
Cg Programming Mapping Computational Concepts to GPUs.
09/11/03CS679 - Fall Copyright Univ. of Wisconsin Last Time Graphics Pipeline Texturing Overview Cubic Environment Mapping.
CS 450: COMPUTER GRAPHICS REVIEW: INTRODUCTION TO COMPUTER GRAPHICS – PART 2 SPRING 2015 DR. MICHAEL J. REALE.
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2007 Tamara Munzner Blending, Modern Hardware.
The Graphics Rendering Pipeline 3D SCENE Collection of 3D primitives IMAGE Array of pixels Primitives: Basic geometric structures (points, lines, triangles,
1 Dr. Scott Schaefer Programmable Shaders. 2/30 Graphics Cards Performance Nvidia Geforce 6800 GTX 1  6.4 billion pixels/sec Nvidia Geforce 7900 GTX.
Computer Graphics The Rendering Pipeline - Review CO2409 Computer Graphics Week 15.
CS-378: Game Technology Lecture #4: Texture and Other Maps Prof. Okan Arikan University of Texas, Austin V Lecture #4: Texture and Other Maps.
CS-378: Game Technology Lecture #7: More Mapping Prof. Okan Arikan University of Texas, Austin Thanks to James O’Brien, Steve Chenney, Zoran Popovic, Jessica.
GRAPHICS PIPELINE & SHADERS SET09115 Intro to Graphics Programming.
CS662 Computer Graphics Game Technologies Jim X. Chen, Ph.D. Computer Science Department George Mason University.
Programmable Pipelines Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts Director, Arts Technology Center University.
Review of OpenGL Basics
09/16/03CS679 - Fall Copyright Univ. of Wisconsin Last Time Environment mapping Light mapping Project Goals for Stage 1.
Advanced Computer Graphics Spring 2014 K. H. Ko School of Mechatronics Gwangju Institute of Science and Technology.
A User-Programmable Vertex Engine Erik Lindholm Mark Kilgard Henry Moreton NVIDIA Corporation Presented by Han-Wei Shen.
Review on Graphics Basics. Outline Polygon rendering pipeline Affine transformations Projective transformations Lighting and shading From vertices to.
Lab: Vertex Shading Chris Wynn Ken Hurley. Objective Hands-On vertex shader programming Start with simple programs … Part 1: Textured-Lit Teapot.
David Luebke 1 1/25/2016 Programmable Graphics Hardware.
From Turing Machine to Global Illumination Chun-Fa Chang National Taiwan Normal University.
COMPUTER GRAPHICS CS 482 – FALL 2015 SEPTEMBER 29, 2015 RENDERING RASTERIZATION RAY CASTING PROGRAMMABLE SHADERS.
09/25/03CS679 - Fall Copyright Univ. of Wisconsin Last Time Shadows Stage 2 outline.
Ray Tracing using Programmable Graphics Hardware
What are shaders? In the field of computer graphics, a shader is a computer program that runs on the graphics processing unit(GPU) and is used to do shading.
09/23/03CS679 - Fall Copyright Univ. of Wisconsin Last Time Reflections Shadows Part 1 Stage 1 is in.
An Introduction to the Cg Shading Language Marco Leon Brandeis University Computer Science Department.
GLSL Review Monday, Nov OpenGL pipeline Command Stream Vertex Processing Geometry processing Rasterization Fragment processing Fragment Ops/Blending.
Graphics Pipeline Bringing it all together. Implementation The goal of computer graphics is to take the data out of computer memory and put it up on the.
GPU Architecture and Its Application
CS-378: Game Technology Lecture #7: More Mapping Prof. Okan Arikan
Programmable Pipelines
A Crash Course on Programmable Graphics Hardware
Graphics Processing Unit
Chapter 6 GPU, Shaders, and Shading Languages
The Graphics Rendering Pipeline
CS451Real-time Rendering Pipeline
Introduction to Programmable Hardware
Graphics Processing Unit
Where does the Vertex Engine fit?
CS5500 Computer Graphics April 17, 2006 CS5500 Computer Graphics
CS-378: Game Technology Lecture #4: Texture and Other Maps
Computer Graphics Introduction to Shaders
CIS 441/541: Introduction to Computer Graphics Lecture 15: shaders
Frame Buffer Applications
Presentation transcript:

CS-378: Game Technology Lecture #9: More Mapping Prof. Okan Arikan University of Texas, Austin Thanks to James O’Brien, Steve Chenney, Zoran Popovic, Jessica Hodgins V

Today Shaders Nvidia Quadro FX 4500

Shadow Buffer Algorithms Compute z-buffer from light viewpoint Put it into the shadow buffer Render normal view, compare world locations of points in the z- buffer and shadow buffer Have to transform pts into same coordinate system Problems: Resolution is a big issue – both depth and spatial Only some hardware supports the required computations But, the Cg Tutorial book gives a fragment shader to do it

Programmable Hardware Earliest hardware was fixed-function – no control over processing Then came configurable hardware – fixed function units, but you had some control over how information flowed Stencil buffer and tests are an example Multi-texturing is another example Most recent hardware is programmable Just like a CPU is programmable, but not quite Nvidia GeForce FX, ATI 9700

Modified Pipeline Replace transform and lighting with vertex shader Vertex shader must now do transform and lighting But can also do more Replace texture stages with fragment (pixel) shader Previously, texture stages were only per-pixel operations Fragment shader must do texturing

Vertex Shader Motivation Old graphics hardware did all the work on the CPU – the “graphics card” was a color buffer and DA converter Then came hardware rasterizers Knew how to draw polygons on the screen, and maybe interpolate Later came texture access in hardware (we’re in the mid-90s) Important: Per-vertex transformations and lighting (t&l) were on the CPU Then hardware t&l came to the commodity market Had been present in $20,000+ machines for a few years, now cost $300 But the functionality (the types of transforms and lighting equations) was fixed in the hardware

Vertex Shaders To shift more processing to the hardware, general programmability was required The tasks that come before transformation vary widely Putting every possible lighting equation in hardware is impractical A vertex program runs on a vertex shader Vertex programs can modify the vertex between submission to the pipeline and primitive assembly Why bother? Why not leave it all on the CPU?

Vertex Program Properties Run for every vertex, independently Access to all per-vertex properties Some registers - NOT retained from one vertex to the next Some constant memory Programmer specifies what’s in that memory Compute on the available data Output to fixed registers – the next stage of the pipeline

Figure 2: The inputs and outputs of vertex shaders. Arrows indicate read-only, write-only, or read- write. IO for Vertex Shaders (Circa 2001)

Vertex Programs All operations work on vectors Scalars are stored as vectors with the same value in each coordinate Instruction set varies: Numerical operations: add, multiply, reciprocal square root, dot product, … LIT which implements the Phong lighting model in one instruction Can re-arrange (swizzle) and negate vectors before doing op Matrices can be automatically mapped into registers No branches in some hardware, but can be done with other instructions Set a value to 0/1 based on a comparison, then multiply and add

Vertex Program Example # blend normal and position v=v 1 +(1-  )v 2 MOV R3, v[3] ; MOV R5, v[2] ; ADD R8, v[1], -R3 ; ADD R6, v[0], -R5 ; MAD R8, v[15].x, R8, R3 MAD R6, v[15].x, R6, R5 ; # transform normal to eye space DP3 R9.x, R8, c[12] ; DP3 R9.y, R8, c[13] ; DP3 R9.z, R8, c[14] ; # transform position and output DP4 [HPOS].x, R6, c[4] ; DP4 [HPOS].y, R6, c[5] ; DP4 [HPOS].z, R6, c[6] ; DP4 [HPOS].w, R6, c[7] ; # normalize normal DP3 R9.w, R9, R9 ; RSQ R9.w, R9.w ; MUL R9, R9.w, R9 ; # apply lighting and output color DP3 R0.x, R9, c[20] ; DP3 R0.y, R9, c[22] ; MOV R0.zw, c[21] ; LIT R1, R0 ; DP3 o[COL0], c[21], R1 ;

Fragment Shader Motivation The idea of per-fragment shaders have been around for a long time Renderman is the best example, but not at all real time In a traditional pipeline, the only major per-pixel operation is texture mapping All lighting, etc. is done in the vertex processing, before primitive assembly and rasterization In fact, a fragment is only screen position, color, and tex- coords

Fragment Shader Generic Structure

Fragment Shaders Fragment shaders operate on fragments in place of the texturing hardware After rasterization, before any fragment tests or blending Input: The fragment, with screen position, depth, color, and a set of texture coordinates Access to textures and some constant data and registers Compute RGBA values for the fragment, and depth Can also kill a fragment Two types of fragment shaders: register combiners (GeForce4) and fully programmable (GeForceFX, Radeon 9700)

Functionality At a minimum, we want to be able to do Phong interpolation How do you get normal vector info? How do you get the light? How do you get the specular color? How do you get the world position? Is a fragment shader much good without a vertex shader? Can you simulate a pixel shader in the CPU? Fragment programs, like vertex programs, are hard to write in assembler

Shading Languages Programming shading hardware is still a difficult process Akin to writing assembly language programs Shading languages and accompanying compilers allow users to write shaders in high level languages Two examples: Microsoft’s HLSL (part of DirectX 9) and Nvidia’s Cg (compatible with HLSL) Renderman is the ultimate example, but it’s not real time

Cg I’m not going to tell you much about it – pick up the tutorial book and learn about it yourselves It looks like C or C++ Actually a language and a runtime environment Can compile ahead of time, or compile on the fly Why compile on the fly? What it can do is tightly tied to the hardware How does it know which hardware, and how to use it?

Vertex Program Example

Pixel Program Example

Cg Runtime There is a sequence of commands to get your Cg program onto the hardware See the Cg Tutorial for more details (Appendix B)

Other Things to Try Many ways of doing bump mapping Shadow volume construction with vertex shaders Key observation: degenerate primitives are not rendered Animation skinning in hardware (deformations) General purpose computations on matrices, such as fluid dynamics The Nvidia web site has lots of examples of different effects, as does the Cg tutorial book

At the end of the day !!!

What do we do now Guest Lecture March 21 st. Bill Mark Q & A You MUST have questions