GAM532 DPS932 – Week 1 Rendering Pipeline and Shaders.

Slides:



Advertisements
Similar presentations
Understanding the graphics pipeline Lecture 2 Original Slides by: Suresh Venkatasubramanian Updates by Joseph Kider.
Advertisements

Graphics Pipeline.
GAM531 DPS931 – Week 11 Render State. The Render State Render State BuffersShadersSamplers Rasterizer State Blend State.
GAM532 DPS932 – Week 7 Introduction to shadows. Shadow Effects Light Surface No Shadows Shadows.
Introduction to Shader Programming
GLSL I May 28, 2007 (Adapted from Ed Angel’s lecture slides)
A Crash Course on Programmable Graphics Hardware Li-Yi Wei 2005 at Tsinghua University, Beijing.
GLSL I Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts Director, Arts Technology Center University of New Mexico.
The programmable pipeline Lecture 10 Slide Courtesy to Dr. Suresh Venkatasubramanian.
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.
GEOMETRY SHADER. Breakdown  Basics  Review – graphics pipeline and shaders  What can the geometry shader do?  Working with the geometry shader  GLSL.
Computer Graphics: Programming, Problem Solving, and Visual Communication Steve Cunningham California State University Stanislaus and Grinnell College.
REAL-TIME VOLUME GRAPHICS Christof Rezk Salama Computer Graphics and Multimedia Group, University of Siegen, Germany Eurographics 2006 Real-Time Volume.
Geometry Shaders. Visualizing Normal Vectors  textbook calls this a “hedgehog plot” but (I think) that this is a misuse of the term  a hedgehog plot.
GPU Programming Robert Hero Quick Overview (The Old Way) Graphics cards process Triangles Graphics cards process Triangles Quads.
CHAPTER 4 Window Creation and Control © 2008 Cengage Learning EMEA.
Programmable Pipelines. Objectives Introduce programmable pipelines ­Vertex shaders ­Fragment shaders Introduce shading languages ­Needed to describe.
Geometric Objects and Transformations. Coordinate systems rial.html.
OpenGL Shading Language (Advanced Computer Graphics) Ernest Tatum.
Programmable Pipelines. 2 Objectives Introduce programmable pipelines ­Vertex shaders ­Fragment shaders Introduce shading languages ­Needed to describe.
A Crash Course in HLSL Matt Christian.
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.
GAM532 DPS932 – Week 8 Texture Shadow Implementation.
OpenGL Conclusions OpenGL Programming and Reference Guides, other sources CSCI 6360/4360.
CSE 690: GPGPU Lecture 6: Cg Tutorial Klaus Mueller Computer Science, Stony Brook University.
CSE Real Time Rendering Week 2. Graphics Processing 2.
Computer Graphics The Rendering Pipeline - Review CO2409 Computer Graphics Week 15.
GAM532 DPS932 – Week 2 Vertex Shaders. The Shader Pipeline Vertex Processing Primitive Assembly / Processing Rasterization Fragment Process Pixel Output.
GRAPHICS PIPELINE & SHADERS SET09115 Intro to Graphics Programming.
Programmable Pipelines Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts Director, Arts Technology Center University.
OpenGL Shader Language Vertex and Fragment Shading Programs.
Shaders in OpenGL Marshall Hahn. Introduction to Shaders in OpenGL In this talk, the basics of OpenGL Shading Language will be covered. This includes.
OpenGL Shading Language (GLSL)
OpenGL-ES 3.0 And Beyond Boston Photo credit :Johnson Cameraface OpenGL Basics.
OpenGL Shading Language (GLSL)
Geometry Shader (GLSL)
2009 GRAPHICS : PROJECT 1 BASED ON DX9 BASICS. Documented by Dongjoon Kim SNU CS Ph.D Course Student Contact : NOTE.
Week 3 Lecture 4: Part 2: GLSL I Based on Interactive Computer Graphics (Angel) - Chapter 9.
COMPUTER GRAPHICS CS 482 – FALL 2015 SEPTEMBER 29, 2015 RENDERING RASTERIZATION RAY CASTING PROGRAMMABLE SHADERS.
 Learn some important functions and process in OpenGL ES  Draw some triangles on the screen  Do some transformation on each triangle in each frame.
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
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.
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.
Shader.
Programmable Shaders Dr. Scott Schaefer.
Programmable Pipelines
A Crash Course on Programmable Graphics Hardware
Chapter 6 GPU, Shaders, and Shading Languages
The Graphics Rendering Pipeline
Understanding Theory and application of 3D
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
Day 05 Shader Basics.
UMBC Graphics for Games
Chapter VI OpenGL ES and Shader
Introduction to Shaders
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
03 | Creating, Texturing and Moving Objects
CS 480/680 Computer Graphics GLSL Overview.
CS 480/680 Part 1: Model Loading.
OpenGL-Rendering Pipeline
CS 480/680 Fall 2011 Dr. Frederick C Harris, Jr. Computer Graphics
Presentation transcript:

GAM532 DPS932 – Week 1 Rendering Pipeline and Shaders

The Shader Pipeline Vertex Processing Primitive Assembly / Processing Rasterization Fragment Process Pixel Output Vertex DataPixel Color

Vertex Processing Local Vertices (in Mesh) World Space Vertices (relative to the center of the scene) View Space Vertices (relative to the absolute position of the camera) Clip Space Vertices (Flattened into 2D screen space)

Geometry Assembly / Processing Clip Space Vertices (Flattened into 2D screen space) Connect Associated Vertices (Winding order preserved) Construct Geometry

Rasterization Clip Space Geometry Clipping and Backface Culling (Removes pieces that will not be seen) Rasterize (Split the geometry into fragments, interpolating vertex values)

Fragment Processing Fragment (Containing interpolated vertex information) -UV Coord - Normal - World Pos -Light Dir Texture Sampled With UVS (Color stored locally) Lighting and Other Transformations Applied (Applied to stored color value) [142,107,6,255] Final Color Exits Pipeline

The Shader Pipeline Vertex Processing Primitive Assembly / Processing Rasterization Fragment Process Pixel Output Programmable ClosedProgrammableClosed

What is a Shader Program? #version 430 layout(triangles) in; layout(triangle_strip) out; layout(max_vertices=3) out; struct BasicGSInput { vec4 position; vec3 normal; vec2 uv; vec4 fragPos; vec3 toLight; }; struct BasicGSOutput { vec4 position; vec3 normal; vec2 uv; vec4 fragPos; vec3 toLight; }; layout (location = 0) in BasicGSInput gin[]; layout (location = 0) out BasicGSOutput gout; void main() { int i; for(i=0; i<gl_in.length(); i++) { gl_Position = gin[i].position; gout.position = gin[i].position; gout.normal = gin[i].normal; gout.uv = gin[i].uv; gout.fragPos = gin[i].fragPos; gout.toLight = gin[i].toLight; EmitVertex(); } EndPrimitive(); } Grapics Card Running Shaders in Shader Cores

How Do You Make Shader Programs? Shader Languages GLSL HLSL OpenGL Shader Language High Level Shader Language (Direct X) GLSL HLSL ~ C++ GLSL != C++

Shader Data Types GLSLHLSL Booleanbool Signed 32 bit Integerint Unsigned 32 bit Integeruintuint / dword Signed 32 bit Floating Pointfloat Signed 64 bit Floating Pointdouble n Element Boolean Vectorbvecnbooln n Element Signed Integer Vectorivecnintn n Element Unsigned Integer Vectoruvecnuintn n Element Float (32bit) Vectorvecnfloatn n Element Double (64bit) Vectordvecndoublen n By n Element Float Matrixmatnfloatnxn n By m Element Float Matrixmatnxmfloatnxn

Shader Languages Cont #version 430 //Line above indicates what shader version struct Input { vec4 position; vec3 normal; vec2 uv; }; //structs work just like C++ … void main() { //void main is the entry point for //all glsl shader programs } struct Input { float4 position; float3 normal; float2 uv; }//structs work just like C++ … float4 ShaderFunctionName(Input shadIn) : BINDINGS { //entry points are functions which will have their //names defined as entry points in C++ }

Shader Input and Output Vertex Shader Geometry Shader Rasterization Fragment Shader Vertex Data Clip Space Vertex Data Clip Space Geometry Rasterized Fragment Pixel Color Uniform Buffers

Programming Shader I/O #version 430 struct FragInput { vec4 position; vec3 normal; vec2 uv; };//Define the structure of the shader’s input struct Light { vec4 diffuse; vec4 specular; };//Define the structure of uniform buffer element //Identifies a uniform buffer, aligns to first register layout(binding = 1) uniform Light light; //Identifies shader’s IO with bound global variables layout(location = 0) in FragInput fin; layout(location = 0) out vec4 color; void main() { color = vec4(1,0,0,1); } //setting global will change shader’s output struct FragInput { float4 position : SV_POSITION; float3 normal : NORMAL; float2 uv : TEXCOORD0;//binds var to shader output };//Define the structure of the shader’s input //cbuffer identifies a uniform buffer, aligns it to //uniform buffer’s first register cbuffer light : register(b1) { float4 diffuse; float4 specular; } //Identifies shader’s IO as parameter and return type float4 fragShader(FragInput fin) : SV_Target { float4 color = float4(1,0,0,1); … return color; }

Extra Shader Code vec4 a; a.x = 10; a.y = 31; a.zw = a.xy; vec3 b = a.xyz; vec4 c = vec4(a.x, a.y, a.z, 1.0); float4x4 d = float4x4(a,c,a,c); float r = dot(c, d * a); d[0][1] = 22; float4 a; a.x = 10; a.y = 31; a.zw = a.xy; float3 b = a.xyz; float4 c = float4(a, 1.0); float4x4 d = float4x4(a,c,a,c); float r = dot(c, mul(d, a)); d[0][1] = 22;

Loading Shader File (C++) String shaderString; File vShader(fileName, in); String ts; while(vShader) { getLine(vShader, ts); shaderString += ts + "\n"; } vShader.close(); vs = glCreateShader(GL_VERTEX_SHADER); glShaderSource(vs, 1, &(shaderData.c_str()), 0); glCompileShader(vs); ID3D10Blob* sh = 0; ID3D10Blob* em = 0; D3DX11CompileFromFile(fileName, 0, 0, function, "vs_5_0", 1 << 15, 0, 0, &sh, &em, 0); dev->CreateVertexShader(sh->GetBufferPointer(), sh- >GetBufferSize(), 0, &vs); D3D11_INPUT_ELEMENT_DESC* desc; auto& ia = v.getVertexDescription(); _dxTranVertex(ia, &desc); dev->CreateInputLayout(desc, ia.size(), sh- >GetBufferPointer(), sh->GetBufferSize(), &layout);

Binding Shaders //Vertex, (geometry) and fragment shader must be //bound to an program first, check engine for //details glUseProgram(prg); con->VSSetShader(vs, 0, 0);

To Do Clone old repo to a new GAM532 repo on bitbucket Add name to student list Form groups Read over Lab 1 Read Week 1 Notes (Review 531 material heavily if new to this course stream)