Introduction to Shaders

Slides:



Advertisements
Similar presentations
GLSL Basics Discussion Lecture for CS 418 Spring 2015 TA: Zhicheng Yan, Sushma S Kini, Mary Pietrowicz.
Advertisements

CS 4363/6353 BASIC RENDERING. THE GRAPHICS PIPELINE OVERVIEW Vertex Processing Coordinate transformations Compute color for each vertex Clipping and Primitive.
TEXTURE MAPPING JEFF CHASTINE 1. TEXTURE MAPPING Applying an image (or a texture ) to geometry 2D images (rectangular) 3D images (volumetric – such as.
As well as colors, normals, and other vertex data PUSHIN’ GEO TO THE GPU JEFF CHASTINE 1.
Informationsteknologi Wednesday, December 12, 2007Computer Graphics - Class 171 Today’s class OpenGL Shading Language.
MAT 594CM S10Fundamentals of Spatial ComputingAngus Forbes Week 4 : GLSL Shaders Topics: Shader programs, vertex & fragment shaders, passing data into.
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.
Programmable Graphics Hardware Languages A Survey of Cg, GLSL and HLSL Oliver Wang.
Mohan Sridharan Based on slides created by Edward Angel GLSL I 1 CS4395: Computer Graphics.
Open Graphics Library (OpenGL)
2D graphics 3D graphics Segoe UI Fonts, text analysis, layout Image & video decoding GPGPU Too.
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.
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.
And an introduction to matrices COORDINATE SYSTEMS JEFF CHASTINE 1.
Geometric Objects and Transformations. Coordinate systems rial.html.
CS 418: Interactive Computer Graphics Introduction to WebGL: HelloTriangle.html Eric Shaffer.
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.
Image Synthesis Rabie A. Ramadan, PhD D Images.
Real-Time High Quality Rendering CSE 291 [Winter 2015], Lecture 4 Brief Intro to Programmable Shaders
GRAPHICS PIPELINE & SHADERS SET09115 Intro to Graphics Programming.
CS662 Computer Graphics Game Technologies Jim X. Chen, Ph.D. Computer Science Department George Mason University.
Introduction to OpenGL  OpenGL is a graphics API  Software library  Layer between programmer and graphics hardware (and software)  OpenGL can fit in.
OpenGL Shader Language Vertex and Fragment Shading Programs.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
Shaders in OpenGL Marshall Hahn. Introduction to Shaders in OpenGL In this talk, the basics of OpenGL Shading Language will be covered. This includes.
CS418 Computer Graphics John C. Hart
OpenGL Shading Language (GLSL)
CSE 381 – Advanced Game Programming GLSL. Rendering Revisited.
OpenGL Shading Language (GLSL)
Vertex Buffer Objects and Shader Attributes. For Further Reading Angel 7 th Ed: –Most parts of Chapter 2. Beginning WebGL: –Chapter 1: vertex Buffer Objects,
Week 3 Lecture 4: Part 2: GLSL I Based on Interactive Computer Graphics (Angel) - Chapter 9.
Programming with OpenGL Part 5: More GLSL Isaac Gang University of Mary Hardin-Baylor E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley.
The OpenGL API Patrick Cozzi University of Pennsylvania CIS Fall 2012.
 Learn how you can use the shader through OpenGL ES  Add texture on object and make the object have a different look!!
 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
OpenGL Shading Language (GLSL)
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.
OpenGl Shaders Lighthouse3d.com.
GLSL I.  Fixed vs. Programmable  HW fixed function pipeline ▪ Faster ▪ Limited  New programmable hardware ▪ Many effects become possible. ▪ Global.
COMP 175 | COMPUTER GRAPHICS Remco Chang1/XX13 – GLSL Lecture 13: OpenGL Shading Language (GLSL) COMP 175: Computer Graphics April 12, 2016.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
GLSL Basics Slides by : Wei-Wen Feng.
Pushin’ Geo to the GPU As well as colors, normals, and other vertex data Made by Jeff Chastine, Modified by Chao Mei Jeff Chastine.
Shader.
Programmable Pipelines
and an introduction to matrices
OpenGL and Related Libraries
Chapter 6 GPU, Shaders, and Shading Languages
Objectives Simple Shaders Programming shaders with GLSL
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 Computer Graphics with WebGL
Introduction to Computer Graphics with WebGL
Computer Graphics Practical Lesson 10
Programming with OpenGL Part 3: Shaders
Mickaël Sereno Shaders Mickaël Sereno 25/04/2019 Mickaël Sereno -
Computer Graphics Introduction to Shaders
CIS 441/541: Introduction to Computer Graphics Lecture 15: shaders
CS 480/680 Computer Graphics GLSL Overview.
CS 480/680 Fall 2011 Dr. Frederick C Harris, Jr. Computer Graphics
Presentation transcript:

Introduction to Shaders Jeff Chastine

Quick Background A vertex is a 3D point (x, y, z) A triangle is made from 3 vertices has a normal Note: vertices can have normals too! Jeff Chastine

Quick Background Models/Meshes are made from triangles OpenGL doesn’t support Quads (4 vertices) Jeff Chastine

Quick Background Hardware has changed! Was “fixed” More of the graphics pipeline is programmable OpenGL has changed! Is now shader-based Jeff Chastine

Intro to Shaders A shader is a program Has source code (text file) Cg, HLSL and GLSL GLSL is very “C-like” Is compiled into a program We get back IDs, which are just ints! Jeff Chastine

Intro to Shaders Two primary types of shaders: Vertex shader Changes the position of a vertex (trans/rot/skew) May determine color of the vertex Fragment shader Determines the color of a pixel Uses lighting, materials, normals, etc… Jeff Chastine

Making a Shader Program Compile a vertex shader (get an ID) Compile a fragment shader (get an ID) Check for compilation errors Link those two shaders together (get an ID) Keep that ID! Use that ID before you render triangles Can have separate shaders for each model Jeff Chastine

Examples in vec4 s_vPosition; void main () { // Look, Ma! I avoided any matrix multiplication! // The value of s_vPosition should be between -1.0 and +1.0 gl_Position = s_vPosition; } --------------------------------------------------------------------- out vec4 s_vColor; // No matter what, color the pixel red! fColor = vec4 (1.0, 0.0, 0.0, 1.0); Jeff Chastine

Compiling Vertex and Fragment Shaders <GLuint> glCreateShader (<type>) Creates an ID (a GLuint) of a shader Example: GLuint ID = glCreateShader(GL_VERTEX_SHADER); glShaderSource (<id>, <count>, <src code>, <lengths>) Binds the source code to the shader Happens before compilation glCompileShader (<id>) Used to make part the shader program Jeff Chastine

Creating/Linking/Using the Shader <GLuint> glCreateProgram() Returns an ID – keep this for the life of the program glAttachShader (<prog ID>, <shader ID>) Do this for both the vertex and fragment shaders glLinkProgram(<prog ID>) Actually makes the shader program glUseProgram(<prog ID>) Use this shader when you’re about to draw triangles Jeff Chastine

END WITH A DRAGON! Jeff Chastine