UMBC Graphics for Games

Slides:



Advertisements
Similar presentations
COMPUTER GRAPHICS CS 482 – FALL 2014 NOVEMBER 10, 2014 GRAPHICS HARDWARE GRAPHICS PROCESSING UNITS PARALLELISM.
Advertisements

GLSL Basics Discussion Lecture for CS 418 Spring 2015 TA: Zhicheng Yan, Sushma S Kini, Mary Pietrowicz.
Graphics Pipeline.
Shading CMSC 435/634. RenderMan Light Displacement Surface Volume Imager.
Informationsteknologi Wednesday, December 12, 2007Computer Graphics - Class 171 Today’s class OpenGL Shading Language.
The Programmable Graphics Hardware Pipeline Doug James Asst. Professor CS & Robotics.
Introduction to Shader Programming
GLSL I May 28, 2007 (Adapted from Ed Angel’s lecture slides)
GLSL I Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts Director, Arts Technology Center University of New Mexico.
Pixel Shader Vertex Shader The Real-time Graphics Pipeline Input Assembler Rasterizer Output Merger.
Mohan Sridharan Based on slides created by Edward Angel GLSL I 1 CS4395: Computer Graphics.
Computer Science – Game DesignUC Santa Cruz Adapted from Jim Whitehead’s slides Shaders Feb 18, 2011 Creative Commons Attribution 3.0 (Except copyrighted.
GPU Graphics Processing Unit. Graphics Pipeline Scene Transformations Lighting & Shading ViewingTransformations Rasterization GPUs evolved as hardware.
GAM532 DPS932 – Week 1 Rendering Pipeline and Shaders.
Cg – C for Graphics Eric Vidal CS 280. History General graphics processing languages – Renderman shading language (1988) Assembly languages for graphics.
REAL-TIME VOLUME GRAPHICS Christof Rezk Salama Computer Graphics and Multimedia Group, University of Siegen, Germany Eurographics 2006 Real-Time Volume.
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.
GPU Shading and Rendering Shading Technology 8:30 Introduction (:30–Olano) 9:00 Direct3D 10 (:45–Blythe) Languages, Systems and Demos 10:30 RapidMind.
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.
The Graphics Rendering Pipeline 3D SCENE Collection of 3D primitives IMAGE Array of pixels Primitives: Basic geometric structures (points, lines, triangles,
Shading CMSC 435/634. RenderMan Light Displacement Surface Volume Imager.
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.
Shading CMSC 435/634.
Computer Graphics The Rendering Pipeline - Review CO2409 Computer Graphics Week 15.
GRAPHICS PIPELINE & SHADERS SET09115 Intro to Graphics Programming.
CS662 Computer Graphics Game Technologies Jim X. Chen, Ph.D. Computer Science Department George Mason University.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
Computer Graphics 3 Lecture 6: Other Hardware-Based Extensions Benjamin Mora 1 University of Wales Swansea Dr. Benjamin Mora.
Week 3 Lecture 4: Part 2: GLSL I Based on Interactive Computer Graphics (Angel) - Chapter 9.
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.
OpenGL Shading Language
UW EXTENSION CERTIFICATE PROGRAM IN GAME DEVELOPMENT 2 ND QUARTER: ADVANCED GRAPHICS The GPU.
Advanced D3D10 Shader Authoring Presentation/Presenter Title Slide.
Programming with OpenGL Part 3: Shaders Ed Angel Professor of Emeritus of Computer Science University of New Mexico 1 E. Angel and D. Shreiner: Interactive.
GLSL I.  Fixed vs. Programmable  HW fixed function pipeline ▪ Faster ▪ Limited  New programmable hardware ▪ Many effects become possible. ▪ Global.
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.
Computer Science – Game DesignUC Santa Cruz Tile Engine.
COMP 175 | COMPUTER GRAPHICS Remco Chang1/XX13 – GLSL Lecture 13: OpenGL Shading Language (GLSL) COMP 175: Computer Graphics April 12, 2016.
How to use a Pixel Shader CMT3317. Pixel shaders There is NO requirement to use a pixel shader for the coursework though you can if you want to You should.
COMPUTER GRAPHICS CHAPTER 38 CS 482 – Fall 2017 GRAPHICS HARDWARE
- Introduction - Graphics Pipeline
Week 3 - Monday CS361.
Programmable Shaders Dr. Scott Schaefer.
Programmable Pipelines
Graphics Processing Unit
Chapter 6 GPU, Shaders, and Shading Languages
The Graphics Rendering Pipeline
CS451Real-time Rendering Pipeline
Understanding Theory and application of 3D
Shading CMSC 435/634.
GLSL I Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts Director, Arts Technology Center University of New Mexico.
Introduction to Computer Graphics with WebGL
UMBC Graphics for Games
Chapter VI OpenGL ES and Shader
Graphics Processing Unit
Computer Graphics Practical Lesson 10
Programming with OpenGL Part 3: Shaders
Computer Graphics Introduction to Shaders
CIS 441/541: Introduction to Computer Graphics Lecture 15: shaders
CS 480/680 Computer Graphics GLSL Overview.
Language Definitions Chap. 3 of Orange Book.
OpenGL-Rendering Pipeline
CS 480/680 Fall 2011 Dr. Frederick C Harris, Jr. Computer Graphics
CIS 6930: Chip Multiprocessor: GPU Architecture and Programming
Presentation transcript:

UMBC Graphics for Games Shading UMBC Graphics for Games

Shader? Small program, domain-specific language Named for appearance “Shader” is now used for any GPU computation

History Shade Trees [Cook 1984] Image Synthesizer [Perlin 1985] Expressions for displacement, surface, light, atmosphere Image Synthesizer [Perlin 1985] Add control flow, also introduces Perlin noise RenderMan [Hanrahan and Lawson 1990] Decades of Pixar movies PixelFlow [Olano and Lastra 1998] First high-level shading language on graphics hardware Vertex Programs [Lindholm et al. 2001] Assembly-like, first GPU shading RTSL [Proudfoot et al. 2001] High level shading on GPUs, introduces GPU shading stages

Common Shading stages Compute Vertex Pixel Vertex Mem (Rasterize) Run each vertex Where does vertex land on screen (Rasterize) Not programmable Collect verts to triangles, turn into pixels Pixel Compute color per pixel Compute General-purpose Rasterize Pixel

Less Common Stages Vertex Compute Hull Domain Geom Pixel Hull Mem Run each triangle/quad Determine tessellation factors (Tessellation) Not programmable Turn one primitive to many Domain Where do the new vertices go? Geometry Run per triangle Make more triangles Tessellate Domain Geom Rasterize Pixel

Language DirectX: HLSL = High Level Shading Language Windows, Xbox, UE4, Unity, … OpenGL: GLSL = GL Shading Language Linux, Mobile, WebGL Both C-like Statement syntax, if / for / switch, struct, function call/declaration, #define / #if, … Some C++ featurse Comments, function overloading Extensions for shading HLSL/GLSL use different names, but otherwise almost identical

Vector Types float2, float3, float4 (only to 4) GLSL calls these vec2, vec3, vec4 Also int2-4, bool2-4, etc. Constructor with any combination of enough components float2 f2 = float2(1, 2); float3 f3 = float3(f2, 0); float4 f4 = float4(3, f2, 4); Swizzle f4.xyz, f4.wxzy, f4.xxxx Operations per component (e.g. a+b = vector addition) Vector functions dot(a,b); cross(a,b); length(a); distance(a,b); normalize(a); bool vectors: all(a), any(a)

Matrix types float2x2, float3x4, float4x2, … GLSL float2x2 = mat2, float3x4 = mat3x4, etc. Construct from components or vectors Component-wise operations Matrix functions mul(mat,mat), mul(vec,mat), mul(mat,vec) determinant(m)

Built-in Shading Functions Find on HLSL reference pages! Blending saturate, clamp, step, smoothstep, lerp Repeating floor, frac, fmod Crazy-special purpose reflect, refract Derivatives (Pixel shaders only!) ddx, ddy, fwidth

Data Constant buffers Vertex buffers Index buffers Fast, same for everybody Defined in shader or CPU code Limited number and size (D3D11 = 15 x 4096-value buffers) Regular constants in your shader get stuffed into one. Vertex buffers Array for CPU, one element per vertex shader Index buffers Array for CPU, GPU uses to tell which vertices go together

Data Memory buffers: multiple views Shader Resource View (SRV): read only Texture2D, etc. Render Target View: write only SV_Target0 or Color output semantics Unordered Access View (UAV): read/write Buffer<uint> Access as array from shader Atomic access functions if there might be overlap GPU needs to do a transition or resolve to change access type

Shader Stage I/O Each shader stage = function Input Output “in” parameters or struct Label with special hardware semantics e.g. in float4 Position : SV_Position Output “out” parameters, struct, or function return value Label with semantics Output from one stage should match input to next

Hardware semantics Vertex input Vertex output Vertex to Pixel Position, Texcoord, Color, … Convention, but no meaning to GPU SV_VertexID (SV = system value) Vertex output SV_Position (used by rasterizer) Vertex to Pixel Limited number of interpolators. Pixel output Color (one output) or SV_Target* for many

UE4 Shaders Engine Materials .ush = Unreal Shader Header .usf = Unreal Shader Function Materials Compiled into boilerplate code Ends up in Vertex Shader: Anything attached to WorldPositionOffset or WorldDisplacement Anything attached to the input of a Vertex Interpolator Ends up in Pixel Shader: Everything else