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.

Slides:



Advertisements
Similar presentations
COMPUTER GRAPHICS SOFTWARE.
Advertisements

Perspective aperture ygyg yryr n zgzg y s = y g (n/z g ) ysys y s = y r (n/z r ) zrzr.
Lecture 38: Chapter 7: Multiprocessors Today’s topic –Vector processors –GPUs –An example 1.
Understanding the graphics pipeline Lecture 2 Original Slides by: Suresh Venkatasubramanian Updates by Joseph Kider.
Graphics Pipeline.
Patrick Cozzi University of Pennsylvania CIS Fall 2013
Dr A Sahu Dept of Comp Sc & Engg. IIT Guwahati 1.
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.
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.
Introduction to Geometry Shaders Patrick Cozzi Analytical Graphics, Inc.
CS5500 Computer Graphics © Chun-Fa Chang, Spring 2007 CS5500 Computer Graphics April 19, 2007.
Control Flow Virtualization for General-Purpose Computation on Graphics Hardware Ghulam Lashari Ondrej Lhotak University of Waterloo.
A Crash Course on Programmable Graphics Hardware Li-Yi Wei 2005 at Tsinghua University, Beijing.
Status – Week 277 Victor Moya.
GPU Simulator Victor Moya. Summary Rendering pipeline for 3D graphics. Rendering pipeline for 3D graphics. Graphic Processors. Graphic Processors. GPU.
Evolution of the Programmable Graphics Pipeline Patrick Cozzi University of Pennsylvania CIS Spring 2011.
Status – Week 283 Victor Moya. 3D Graphics Pipeline Akeley & Hanrahan course. Akeley & Hanrahan course. Fixed vs Programmable. Fixed vs Programmable.
The Graphics Pipeline CS2150 Anthony Jones. Introduction What is this lecture about? – The graphics pipeline as a whole – With examples from the video.
Vertex & Pixel Shaders CPS124 – Computer Graphics Ferdinand Schober.
Status – Week 260 Victor Moya. Summary shSim. shSim. GPU design. GPU design. Future Work. Future Work. Rumors and News. Rumors and News. Imagine. Imagine.
GPU Graphics Processing Unit. Graphics Pipeline Scene Transformations Lighting & Shading ViewingTransformations Rasterization GPUs evolved as hardware.
Under the Hood: 3D Pipeline. Motherboard & Chipset PCI Express x16.
GAM532 DPS932 – Week 1 Rendering Pipeline and Shaders.
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)
Computer Graphics Graphics Hardware
Geometric Objects and Transformations. Coordinate systems rial.html.
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.
Week 3 - Monday.  What did we talk about last time?  Graphics rendering pipeline  Rasterizer Stage.
The Graphics Rendering Pipeline 3D SCENE Collection of 3D primitives IMAGE Array of pixels Primitives: Basic geometric structures (points, lines, triangles,
Computer graphics & visualization The programmable (D3D 10) Pipeline.
Computer Graphics The Rendering Pipeline - Review CO2409 Computer Graphics Week 15.
Shading Languages & HW Giovanni Civati Dept. of Information Tecnology University of Milan, Italy Milan, 26 th May 2004.
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.
Fateme Hajikarami Spring  What is GPGPU ? ◦ General-Purpose computing on a Graphics Processing Unit ◦ Using graphic hardware for non-graphic computations.
© David Kirk/NVIDIA and Wen-mei W. Hwu, ECE408, University of Illinois, Urbana-Champaign 1 Programming Massively Parallel Processors Lecture.
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.
The Internet (Gaming) Windows XP or later 1.7 GHz Intel or AMD Processor 512 MB of RAM DirectX 8.1 graphics card Sound card (These requirements are based.
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.
Computer Graphics Graphics Hardware
GPU Architecture and Its Application
Programmable Shaders Dr. Scott Schaefer.
Programmable Pipelines
A Crash Course on Programmable Graphics Hardware
CS427 Multicore Architecture and Parallel Computing
Graphics Processing Unit
Chapter 6 GPU, Shaders, and Shading Languages
The Graphics Rendering Pipeline
GRAPHICS PROCESSING UNIT
CSC 2231: Parallel Computer Architecture and Programming GPUs
Introduction to Programmable Hardware
Graphics Processing Unit
Computer Graphics Graphics Hardware
CS5500 Computer Graphics April 17, 2006 CS5500 Computer Graphics
Ray Tracing on Programmable Graphics Hardware
Computer Graphics Introduction to Shaders
© 2012 Elsevier, Inc. All rights reserved.
CIS 6930: Chip Multiprocessor: GPU Architecture and Programming
Presentation transcript:

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 2  15.6 billion pixels/sec Xbox  16 billion pixels/sec (4X AA) Nvidia Geforce 8800 GTX 4  36.8 billion pixels/sec Nvidia Geforce GTX  92.2 billion pixels/sec 1: 2: 3: 4: 5:

3/30 Parallel Processing Power Nvidia Geforce GTX 780 Ti  2880 programmable processors  875 MHz each  336 GB/s memory bandwidth  3 GB memory

Parallel Processing Power IBM’s ASCI White, 4.9 TFLOPS Fastest Computer in the World 2000 AMD’s Radeon HD processors, 8.2 TFLOPS 4/30

5/30 Graphics Pipeline Vertices

6/30 Graphics Pipeline Vertices Vertex Transformation/Lighting

7/30 Graphics Pipeline Vertices Vertex Transformation/Lighting Transformed Vertices

8/30 Graphics Pipeline Vertices Vertex Transformation/Lighting Viewport Transformation Transformed Vertices

9/30 Graphics Pipeline Vertices Vertex Transformation/Lighting Viewport Transformation Triangle Setup Transformed Vertices Vertex Index Stream

10/30 Graphics Pipeline Vertices Vertex Transformation/Lighting Backface Culling Viewport Transformation Triangle Setup Transformed Vertices Vertex Index Stream

11/30 Graphics Pipeline Vertices Vertex Transformation/Lighting Backface Culling Clipping Viewport Transformation Triangle Setup Transformed Vertices Vertex Index Stream

12/30 Graphics Pipeline Vertices Vertex Transformation/Lighting Backface Culling Clipping Viewport Transformation Triangle Setup Interpolation/Rasterization Transformed Vertices Vertex Index Stream

13/30 Graphics Pipeline Vertices Vertex Transformation/Lighting Backface Culling Clipping Viewport Transformation Triangle Setup Interpolation/Rasterization Transformed Vertices Pixel Location/Color/Depth Vertex Index Stream

14/30 Graphics Pipeline Vertices Vertex Transformation/Lighting Backface Culling Clipping Viewport Transformation Triangle Setup Interpolation/Rasterization Visibility Determination Transformed Vertices Pixel Location/Color/Depth Vertex Index Stream

15/30 Graphics Pipeline Vertices Vertex Transformation/Lighting Backface Culling Clipping Viewport Transformation Triangle Setup Interpolation/Rasterization Visibility Determination Frame Buffer Transformed Vertices Pixel Location/Color/Depth Vertex Index Stream

16/30 Programmable Graphics Pipeline Vertices Vertex Shader Backface Culling Clipping Viewport Transformation Triangle Setup Interpolation/Rasterization Visibility Determination Frame Buffer Transformed Vertices/ Normals/Texture coords/… Pixel Location Vertex Index Stream Pixel Shader Color/Depth Interpolated Vertex Data

17/30 Shader Programming Many different languages  Assembly  OpenGL Shading Language  Nvidia’s CG  Microsoft’s HLSL Different capabilities based on shader model  Register count  Instructions  Maximum number of instructions

18/30 Vertex Shaders Input: anything associated with vertices  Position, normal, texture coordinates, etc… Output: transformed vertices  MUST output position  Can produce color, normal, texture coordinates, etc…

19/30 Vertex Shaders // vertex shader output structure struct VS_OUTPUT { float4 Pos : POSITION; };

20/30 Vertex Shaders VS_OUTPUT VS( float3 InPos : POSITION // Vertex position in model space ) { VS_OUTPUT Out = (VS_OUTPUT)0; // transform the position float3 transformedPos = mul(float4(InPos, 1), (float4x3)World); Out.Pos = mul(float4(transformedPos,1), ViewProjection); return Out; }

21/30 Pixel Shaders Input: Vertex data produced from vertex shader Output:  MUST output color  Can output depth as well  Cannot change location of pixel on screen

22/30 Pixel Shaders float4 PS ( VS_OUTPUT In ) : COLOR { // may perform texture lookup, depth effects, fog, etc… return float4 ( 1, 1, 1, 1 ); }

23/30 Gouraud Shading Example // vertex shader output structure struct VS_OUTPUT { float4 Pos : POSITION; float4 Color : COLOR; };

24/30 Gouraud Shading Example VS_OUTPUT VS( float3 InPos : POSITION, // Vertex position in model space float3 InNormal : NORMAL // Vertex normal in model space ) { VS_OUTPUT Out = (VS_OUTPUT)0; // transform the position and normal float3 transformedPos = mul(float4(InPos, 1), (float4x3)World); Out.Pos = mul(float4(transformedPos,1), ViewProjection); float3 transNormal = mul(InNormal, (float3x3)World); // normal (view space) Out.Color = float4 ( calcColor ( normalize ( lightPos – transformedPos ), transNormal, normalize ( eyePos – transformedPos ) ), 1 ); return Out; }

25/30 Gouraud Shading Example float3 calcColor ( float3 lightVec, float3 normal, float3 eyeToVertex ) { float3 color = 0; color += lightColor * MaterialAmbient; color += lightColor * MaterialDiffuse * max ( 0, dot ( normal, lightVec ) ); float3 R = normalize ( reflect ( lightVec, normal ) ); color += lightColor * MaterialSpecular * pow ( max ( 0, dot ( R, eyeToVertex ) ), MaterialSpecularPower ); return color; }

26/30 Gouraud Shading Example float4 PS ( VS_OUTPUT In ) : COLOR { return In.Color; }

27/30 Phong Shading Example // vertex shader output structure struct VS_OUTPUT { float4 Pos : POSITION; float3 Normal : TEXCOORD0; float3 TransformedPos : TEXCOORD1; };

28/30 Phong Shading Example VS_OUTPUT VS( float3 InPos : POSITION, // Vertex position in model space float3 InNormal : NORMAL // Vertex normal in model space ) { VS_OUTPUT Out = (VS_OUTPUT)0; // transform the position and normal Out.TransformedPos = mul(float4(InPos, 1), (float4x3)World); Out.Pos = mul(float4(Out.TransformedPos,1), ViewProjection); Out.Normal = mul(InNormal, (float3x3)World); // normal (view space) return Out; }

29/30 Phong Shading Example float4 PS ( VS_OUTPUT In ) : COLOR { // vector from vertex towards eye float3 EyeToVertex = normalize ( In.TransformedPos - EyePos ); float3 normal = normalize ( In.Normal ); float4 color = calcColor ( normalize ( lightPos – In.TransformedPos ), normal, EyeToVertex ); return color; }

30/30 General Purpose GPU Programming Originally success was limited because problems had to be crammed into graphics pipeline General purpose computation now available  Nvidia’s CUDA  DirectX Compute  OpenCL