Save this PDF as:

Size: px
Start display at page:

## Transcription

2 Shaders Like a function call data are passed in, processed, and passed back out -- Shreiner et al, OpenGL Programming Guide GLSL is like a complete C program, but without recursion Pointer Dynamic allocation of memory

3 Vertex Shader Basic task: Sending vertices positions to the rasterizer Advanced tasks: Transformation Projection Moving vertices Morphing Wave motion Fractals Processing color

4 A Simple Vertex Shader: triangles.vert (Shreiner et al) #version 430 core Specify it is an input to the shader in vec4 vposition; void main() Global variable, copied from the application to the shader { gl_position = vposition; } A built-in variable, passing data to the rasterizer

5 A Simple Fragment Shader #version 330 core out vec4 fcolor; void main() { fcolor = vec4( 1.0, 0.0, 0.0, 1.0 ); }

6 Example of Vertex Shader: Color Processing // vertex shader #version 150 in vec4 vposition; out vec4 color; void main() { color = vec4( vposition.x, vposition.y, vposition.z, 1.0 ); gl_position = vposition; } // fragment shader #version 150 in vec4 color; out vec4 fcolor; void main() { fcolor = color; } E. Angel and D. Shreiner: Interactive Computer Graphics 6E Addison-Wesley 2012

7 Declaring Variables Allowed: Letters, numbers, _ Not allowed: Digits and _ cannot appear as the first character Do not allow consecutive _

8 Data Types Basic types: int, float, double, uint, bool Fewer implicit conversion int f = false Shreiner et al, OpenGL Programming Guide, the Official Guide to Learning OpenGL, Version 4.3, the 8th Ed,

9 Data Types Vectors: float vec2, vec3, vec4 Also int (ivec) and boolean (bvec) Matrices: mat2, mat3, mat4, mat3x4 Stored by columns mat2 M=mat2 (1.0, 2.0, 3.0, 4.0); vec2 col1=vec2(1.0,2.0); vec2 col2=vec2(3.0,4.0); mat2 M=mat2(col1,col2); Structures: grouping different types

10 Data Types C++ style constructors Truncate a vector: vec4 color =vec4(1.0, 2.0, 3.0, 1.0); vec3 rgb = vec3(color) Lengthen a vector: vec3 white = vec3(1.0) white = (1.0,1.0,1.0) vec4 translucent = vec4 (white, 0.5) Initialize a matrix M=mat3(4.0)= Samplers: used to represent texture

11 Data Referencing Standard referencing: float green = color[1]; float m12 = mat[row=1][column=2] Component access float green = color.g; float velocity_x = velocity.x Shreiner et al, OpenGL Programming Guide, the Official Guide to Learning OpenGL, Version 4.3, the 8th Ed,

12 Swizzling Can refer to array elements by element using [] or selection (.) operator a[2], a.b, a.z, a.p are the same vec3 green=color.ggg vec4 revcolor=color.abgr vec3 a; a.yz=color.gr vec3 vector1=color.rrg vec3 vector2=color.zrg

13 Operators Shreiner et al, OpenGL Programming Guide, the Official Guide to Learning OpenGL, Version 4.3, the 8th Ed,

14 Operators and Built-in Functions Built-in functions Arithmetic, e.g., pow(), exp(), sqrt(), etc. Trigonometric, e.g., sin(), cos(), etc. Matrix functions, e.g., transpose(), inverse(), etc. Many more: normalize(), reflect(), length(), distance(), etc. Overloading of vector and matrix types mat4 a; vec4 b, c, d; c = b*a; // a column vector stored as a 1d array d = a*b; // a row vector stored as a 1d array

15 Example of Vertex Shader: Geometric Transformation #version 330 core in vec4 vposition; in vec4 vcolor; out vec4 color; uniform mat4 ModelViewProjectionMatrix; void main() { color = vcolor; gl_position = ModelViewProjectionMatrix * vposition; } Shreiner et al, OpenGL Programming Guide, the Official Guide to Learning OpenGL, Version 4.3, the 8th Ed,

16 Type Qualifier Define and modify the behavior of variables Storage qualifiers: where the data come from const: read-only, must be initialized when declared in: vertex attributes or from the previous stage out: output from the shader uniform: a global variable shared between all the shader stages buffer: share buffer with application (r/w) Layout qualifiers: the storage location Invariant/precise qualifiers: enforcing the reproducibility Copy in/out data

17 Uniform Qualifiers A global variable Used to pass information to shader such as the bounding box and the transformation matrix of a primitive shared between all the shader stages Can be changed in the application and sent to shaders Cannot be changed in shader

18 How to set the value for uniform qualifiers? GLSL compiler creates a table for all uniform variable when linking the program. Step1: You need to get the index of the variable by glgetuniformlocation() The index is not changed unless relinking the program Step2: set the value using gluniform*() or gluniformmatrix*()

19 An Example of Uniform Qualifiers (Shreiner et al) In the shader uniform GLint time; In the application

20 Example of Vertex Shader: Wave Motion Vertex Shader in vec4 vposition; uniform float xs, zs, // frequencies uniform float h; // height scale void main() { vec4 t = vposition; t.y = vposition.y + h*sin(time + xs*vposition.x) + h*sin(time + zs*vposition.z); gl_position = t; } E. Angel and D. Shreiner: Interactive Computer Graphics 6E Addison-Wesley 2012

21 Example of Vertex Shader: Particle System in vec3 vposition; uniform mat4 ModelViewProjectionMatrix; uniform vec3 init_vel; uniform float g, m, t; void main() { vec3 object_pos; object_pos.x = vposition.x + vel.x*t; object_pos.y = vposition.y + vel.y*t + g/(2.0*m)*t*t; object_pos.z = vposition.z + vel.z*t; gl_position = ModelViewProjectionMatrix*vec4(object_pos,1); } E. Angel and D. Shreiner: Interactive Computer Graphics 6E Addison-Wesley 2012

22 Double Buffering Updating the value of a uniform variable opens the door to animating an application Execute gluniform in display callback Force a redraw through glutpostredisplay() Need to prevent a partially redrawn frame buffer from being displayed Draw into back buffer Display front buffer Double buffering Swap buffers after updating finished E. Angel and D. Shreiner: Interactive Computer Graphics 6E Addison-Wesley 2012

23 Adding Double Buffering Request a double buffer glutinitdisplaymode(glut_double) Swap buffers void mydisplay() { glclear( ); gldrawarrays(); glutswapbuffers(); } E. Angel and D. Shreiner: Interactive Computer Graphics 6E Addison-Wesley 2012

25 Compiling Shaders Step4: compile a shader object Step5: verify the shader compiled successfully GLint compiled; glgetshaderiv( shader, GL_COMPILE_STATUS, &compiled ); Shreiner et al, OpenGL Programming Guide, the Official Guide to Learning OpenGL, Version 4.3, the 8th Ed,

### Programming with OpenGL Part 5: More GLSL. Ed Angel Professor Emeritus of Computer Science University of New Mexico

Programming with OpenGL Part 5: More GLSL Ed Angel Professor Emeritus of Computer Science University of New Mexico 1 Objectives Coupling shaders to applications - Reading - Compiling - Linking Vertex Attributes

### Comp 410/510 Computer Graphics Spring Programming with OpenGL Part 3: Shaders

Comp 410/510 Computer Graphics Spring 2018 Programming with OpenGL Part 3: Shaders Objectives Basic shaders - Vertex shader - Fragment shader Programming shaders with GLSL Finish first program void init(void)

Objectives Programming with OpenGL Part : More GLSL CS Interactive Computer Graphics Prof. David E. Breen Department of Computer Science Coupling shaders to applications - Reading - Compiling - Linking

### Supplement to Lecture 22

Supplement to Lecture 22 Programmable GPUs Programmable Pipelines Introduce programmable pipelines - Vertex shaders - Fragment shaders Introduce shading languages - Needed to describe shaders - RenderMan

### Lecture 3. Programming with OpenGL GLUT + GLEW. CS 354 Computer Graphics Sunday, January 20, 13

Lecture 3 Programming with OpenGL 3.1 + GLUT + GLEW OpenGL The success of GL lead to OpenGL (1992), a platform-independent API that was - Easy to use - Close enough to the hardware to get excellent performance

### GLSL II. Objectives. Coupling GLSL to Applications Example applications

GLSL II Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts Director, Arts Technology Center University of New Mexico Objectives Coupling GLSL to Applications Example

### Objectives. Coupling GLSL to Applications Example applications

GLSL II Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts Director, Arts Technology Center University of New Mexico Objectives Coupling GLSL to Applications Example

### GLSL 1: Basics. J.Tumblin-Modified SLIDES from:

GLSL 1: Basics J.Tumblin-Modified SLIDES from: Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts Director, Arts Technology Center University of New Mexico and

### 2D graphics with WebGL

2D graphics with WebGL Some material contained here is adapted from the book s slides. September 7, 2015 (Dr. Mihail) 2D graphics September 7, 2015 1 / 22 Graphics Pipeline (Dr. Mihail) 2D graphics September

### 3D Game Programming Programmable Pipelines. Ming-Te Chi Department of Computer Science, National Chengchi University

3D Game Programming Programmable Pipelines Ming-Te Chi Department of Computer Science, National Chengchi University Outline Programmable Pipelines(4ed CH15) (5th CH5) Vertex shaders Fragment shaders Introduce

### Lecture 09: Shaders (Part 1)

Lecture 09: Shaders (Part 1) CSE 40166 Computer Graphics Peter Bui University of Notre Dame, IN, USA November 9, 2010 OpenGL Rendering Pipeline OpenGL Rendering Pipeline (Pseudo-Code) 1 f o r gl_vertex

### The Projection Matrix

The Projection Matrix Lecture 8 Robb T. Koether Hampden-Sydney College Fri, Sep 11, 2015 Robb T. Koether (Hampden-Sydney College) The Projection Matrix Fri, Sep 11, 2015 1 / 43 Outline 1 Coordinate Systems

### The Projection Matrix

The Projection Matrix Lecture 5 Robb T. Koether Hampden-Sydney College Wed, Aug 30, 2017 Robb T. Koether (Hampden-Sydney College) The Projection Matrix Wed, Aug 30, 2017 1 / 21 Outline 1 The World Coordinate

### Building Models. CS 537 Interactive Computer Graphics Prof. David E. Breen Department of Computer Science

Building Models CS 537 Interactive Computer Graphics Prof. David E. Breen Department of Computer Science 1 Objectives Introduce simple data structures for building polygonal models - Vertex lists - Edge

### CSE 167: Introduction to Computer Graphics Lecture #13: GLSL. Jürgen P. Schulze, Ph.D. University of California, San Diego Fall Quarter 2015

CSE 167: Introduction to Computer Graphics Lecture #13: GLSL Jürgen P. Schulze, Ph.D. University of California, San Diego Fall Quarter 2015 Announcements Project 6 due Friday Next Thursday: Midterm #2

### Objectives. OpenGL - Shaders. GLSL A Quick Review

OpenGL - Shaders CITS3003 Graphics & Animatin E. Angel and D. Shreiner: Interactive Cmputer Graphics 6E Addisn-Wesley 2012 1 Objectives The rendering pipeline and the shaders Data types, qualifiers, built-in

### Copyright Khronos Group 2012 Page 1. Teaching GL. Dave Shreiner Director, Graphics and GPU Computing, ARM 1 December 2012

Copyright Khronos Group 2012 Page 1 Teaching GL Dave Shreiner Director, Graphics and GPU Computing, ARM 1 December 2012 Copyright Khronos Group 2012 Page 2 Agenda Overview of OpenGL family of APIs Comparison

### CSE 167: Introduction to Computer Graphics Lecture #7: GLSL. Jürgen P. Schulze, Ph.D. University of California, San Diego Spring Quarter 2016

CSE 167: Introduction to Computer Graphics Lecture #7: GLSL Jürgen P. Schulze, Ph.D. University of California, San Diego Spring Quarter 2016 Announcements Project 2 due Friday 4/22 at 2pm Midterm #1 on

### WebGL A quick introduction. J. Madeira V. 0.2 September 2017

WebGL A quick introduction J. Madeira V. 0.2 September 2017 1 Interactive Computer Graphics Graphics library / package is intermediary between application and display hardware Application program maps

CSCI 420 Computer Graphics Lecture 4 Shaders Jernej Barbic University of Southern California Shading Languages GLSL Vertex Array Objects Vertex Shader Fragment Shader [Angel Ch. 1, 2, A] Introduction The

### Shaders. Slide credit to Prof. Zwicker

Shaders Slide credit to Prof. Zwicker 2 Today Shader programming 3 Complete model Blinn model with several light sources i diffuse specular ambient How is this implemented on the graphics processor (GPU)?

### WebGL: Hands On. DevCon5 NYC Kenneth Russell Software Engineer, Google, Inc. Chair, WebGL Working Group

WebGL: Hands On DevCon5 NYC 2011 Kenneth Russell Software Engineer, Google, Inc. Chair, WebGL Working Group Today's Agenda Introduce WebGL and its programming model. Show code for a complete example. Demonstrate

### Tutorial 04. Harshavardhan Kode. September 14, 2015

Tutorial 04 Harshavardhan Kode September 14, 2015 1 About This tutorial an extension of the Tutorial 03. So you might see quite a lot similarities. The following things are new. A Plane is added underneath

### The Graphics Pipeline and OpenGL III: OpenGL Shading Language (GLSL 1.10)!

! The Graphics Pipeline and OpenGL III: OpenGL Shading Language (GLSL 1.10)! Gordon Wetzstein! Stanford University! EE 267 Virtual Reality! Lecture 4! stanford.edu/class/ee267/! Updates! for 24h lab access:

### Programming with OpenGL Complete Programs Objectives Build a complete first program

Programming with OpenGL Complete Programs Objectives Build a complete first program Introduce shaders Introduce a standard program structure Simple viewing Two-dimensional viewing as a special case of

### CS4621/5621 Fall Basics of OpenGL/GLSL Textures Basics

CS4621/5621 Fall 2015 Basics of OpenGL/GLSL Textures Basics Professor: Kavita Bala Instructor: Nicolas Savva with slides from Balazs Kovacs, Eston Schweickart, Daniel Schroeder, Jiang Huang and Pramook

### CS452/552; EE465/505. Review & Examples

CS452/552; EE465/505 Review & Examples 2-05 15 Outline Review and Examples:! Shaders, Buffers & Binding! Example: Draw 3 Triangles Vertex lists; gl.drawarrays( ) Edge lists: gl.drawelements( )! Example:

### CS380: Computer Graphics Screen Space & World Space. Sung-Eui Yoon ( 윤성의 ) Course URL:

CS380: Computer Graphics Screen Space & World Space Sung-Eui Yoon ( 윤성의 ) Course URL: http://sglab.kaist.ac.kr/~sungeui/cg Class Objectives Understand different spaces and basic OpenGL commands Understand

### Computer Graphics (CS 4731) OpenGL/GLUT (Part 2)

Computer Graphics (CS 4731) Lecture 3: Introduction to OpenGL/GLUT (Part 2) Prof Emmanuel Agu Computer Science Dept. Worcester Polytechnic Institute (WPI) Triangulation Generally OpenGL breaks polygonsdownintotriangles

### Shading Languages. Ari Silvennoinen Apri 12, 2004

Shading Languages Ari Silvennoinen Apri 12, 2004 Introduction The recent trend in graphics hardware has been to replace fixed functionality in vertex and fragment processing with programmability [1], [2],

### Mali & OpenGL ES 3.0. Dave Shreiner Jon Kirkham ARM. Game Developers Conference 27 March 2013

Mali & OpenGL ES 3.0 Dave Shreiner Jon Kirkham ARM Game Developers Conference 27 March 2013 1 Agenda Some foundational work Instanced geometry rendering Transform feedback Occlusion Queries 2 What s New

### Mobile Application Programing: Android. OpenGL Operation

Mobile Application Programing: Android OpenGL Operation Activities Apps are composed of activities Activities are self-contained tasks made up of one screen-full of information Activities start one another

### Three Main Themes of Computer Graphics

Three Main Themes of Computer Graphics Modeling How do we represent (or model) 3-D objects? How do we construct models for specific objects? Animation How do we represent the motion of objects? How do

### Computer Graphics. Bing-Yu Chen National Taiwan University

Computer Graphics Bing-Yu Chen National Taiwan University Introduction to OpenGL General OpenGL Introduction An Example OpenGL Program Drawing with OpenGL Transformations Animation and Depth Buffering

### OPEN GL BACKGROUND. Objectives. Early History of APIs. SGI and GL. PHIGS and X. Modified from Angel 6e book slides

OPEN GL Modified from Angel 6e book slides BACKGROUND Objectives Early History of APIs Development of the OpenGL API OpenGL Architecture OpenGL as a state machine OpenGL as a data flow machine Functions

### OUTLINE. Implementing Texturing What Can Go Wrong and How to Fix It Mipmapping Filtering Perspective Correction

TEXTURE MAPPING 1 OUTLINE Implementing Texturing What Can Go Wrong and How to Fix It Mipmapping Filtering Perspective Correction 2 BASIC STRAGEGY Three steps to applying a texture 1. specify the texture

### GLSL Introduction. Fu-Chung Huang. Thanks for materials from many other people

GLSL Introduction Fu-Chung Huang Thanks for materials from many other people Shader Languages Currently 3 major shader languages Cg (Nvidia) HLSL (Microsoft) Derived from Cg GLSL (OpenGL) Main influences

### GLSL Introduction. Fu-Chung Huang. Thanks for materials from many other people

GLSL Introduction Fu-Chung Huang Thanks for materials from many other people Programmable Shaders //per vertex inputs from main attribute aposition; attribute anormal; //outputs to frag. program varying

### CS770/870 Spring 2017 Open GL Shader Language GLSL

Preview CS770/870 Spring 2017 Open GL Shader Language GLSL Review traditional graphics pipeline CPU/GPU mixed pipeline issues Shaders GLSL graphics pipeline Based on material from Angel and Shreiner, Interactive

### OPENGL RENDERING PIPELINE

CPSC 314 03 SHADERS, OPENGL, & JS UGRAD.CS.UBC.CA/~CS314 Textbook: Appendix A* (helpful, but different version of OpenGL) Alla Sheffer Sep 2016 OPENGL RENDERING PIPELINE 1 OPENGL RENDERING PIPELINE Javascript

### EECS 487: Interactive Computer Graphics

Integrating GLSL with OpenGL EECS 487: Interactive Computer Graphics Lecture 19: Integrating shaders with OpenGL program Vertex-array objects with shaders Miscellaneous shader related stuﬀ Integrating

### Lecture 11 Shaders and WebGL. October 8, 2015

Lecture 11 Shaders and WebGL October 8, 2015 Review Graphics Pipeline (all the machinery) Program Vertex and Fragment Shaders WebGL to set things up Key Shader Concepts Fragment Processing and Vertex

Objectives Shading in OpenGL Introduce the OpenGL shading methods - per vertex shading vs per fragment shading - Where to carry out Discuss polygonal shading - Flat - Smooth - Gouraud CITS3003 Graphics

### CS452/552; EE465/505. Image Processing Frame Buffer Objects

CS452/552; EE465/505 Image Processing Frame Buffer Objects 3-12 15 Outline! Image Processing: Examples! Render to Texture Read: Angel, Chapter 7, 7.10-7.13 Lab3 new due date: Friday, Mar. 13 th Project#1

### Mobile Application Programing: Android. OpenGL Operation

Mobile Application Programing: Android OpenGL Operation Activities Apps are composed of activities Activities are self-contained tasks made up of one screen-full of information Activities start one another

### Converts geometric primitives into images Is split into several independent stages Those are usually executed concurrently

Rendering Pipeline Rendering Pipeline Converts geometric primitives into images Is split into several independent stages Those are usually executed concurrently Pipeline 18.10.2013 Steiner- Wallner- Podaras

### Comp 410/510 Computer Graphics Spring Programming with OpenGL Part 2: First Program

Comp 410/510 Computer Graphics Spring 2017 Programming with OpenGL Part 2: First Program Objectives Refine the first program Introduce a standard program structure - Initialization Program Structure Most

### Tutorial 1: Your First Triangle!

Tutorial 1: Your First Triangle! Summary For your first dabble in OpenGL, you are going to create the graphics programming equivalent of Hello World - outputting a single coloured triangle. It doesn t

### Mobile Application Programming: Android. OpenGL Operation

Mobile Application Programming: Android OpenGL Operation OpenGL ES C-Based Performance-Oriented Graphics Library Wrapper libraries provided for Java, C#, etc. Produces 2D images from 2D or 3D geometric

### Lecture 12: Mid-term test solution & project. CITS 3003 Graphics & Animation

Lecture 12: Mid-term test solution & project CITS 3003 Graphics & Animation Slides: E. Angel and D. Shreiner: Interactive Computer Graphics 6E Addison-Wesley 2012 Objectives Explain solution to the mid-term

### CS4621/5621 Fall Computer Graphics Practicum Intro to OpenGL/GLSL

CS4621/5621 Fall 2015 Computer Graphics Practicum Intro to OpenGL/GLSL Professor: Kavita Bala Instructor: Nicolas Savva with slides from Balazs Kovacs, Eston Schweickart, Daniel Schroeder, Jiang Huang

### 3d Programming I. Dr Anton Gerdelan

3d Programming I Dr Anton Gerdelan gerdela@scss.tcd.ie 3d Programming 3d programming is very difficult 3d programming is very time consuming 3d Programming Practical knowledge of the latest, low-level

### GLSL Programming. Nicolas Holzschuch

GLSL Programming Nicolas Holzschuch GLSL programming C-like language structure: int i, j; i = 2; j = 0; j += i; Functions, loops, branches... Reading your first GSL shader is easy Differences with C New

### The Graphics Pipeline

The Graphics Pipeline Lecture 2 Robb T. Koether Hampden-Sydney College Fri, Aug 28, 2015 Robb T. Koether (Hampden-Sydney College) The Graphics Pipeline Fri, Aug 28, 2015 1 / 19 Outline 1 Vertices 2 The

### The GLSL API. Mike Bailey. Oregon State University. Geometry Shader. Program. The GLSL Shader-creation Process. create. compile. Vertex.

The GLSL API Mike Bailey Oregon State University Program The GLSL -creation Process create compile Source read Source read Program link Use create compile Source read create compile 1 Initializing the

### Models and Architectures. Angel and Shreiner: Interactive Computer Graphics 7E Addison-Wesley 2015

Models and Architectures 1 Objectives Learn the basic design of a graphics system Introduce pipeline architecture Examine software components for an interactive graphics system 2 Image Formation Revisited

### C P S C 314 S H A D E R S, O P E N G L, & J S RENDERING PIPELINE. Mikhail Bessmeltsev

C P S C 314 S H A D E R S, O P E N G L, & J S RENDERING PIPELINE UGRAD.CS.UBC.C A/~CS314 Mikhail Bessmeltsev 1 WHAT IS RENDERING? Generating image from a 3D scene 2 WHAT IS RENDERING? Generating image

Vertex & Fragment shaders The next big step in graphics hardware Adds programmability to the previously fixed rendering pipeline The OpenGL Shading Language (a.k.a. GLSL, glslang) Vertex shaders: programs

### CS 380 Introduction to Computer Graphics. LAB (1) : OpenGL Tutorial Reference : Foundations of 3D Computer Graphics, Steven J.

CS 380 Introduction to Computer Graphics LAB (1) : OpenGL Tutorial 2018. 03. 05 Reference : Foundations of 3D Computer Graphics, Steven J. Gortler Goals Understand OpenGL pipeline Practice basic OpenGL

### SHADER PROGRAMMING. Based on Jian Huang s lecture on Shader Programming

SHADER PROGRAMMING Based on Jian Huang s lecture on Shader Programming What OpenGL 15 years ago could do http://www.neilturner.me.uk/shots/opengl-big.jpg What OpenGL can do now What s Changed? 15 years

### GLSL Overview: Creating a Program

1. Create the OpenGL application GLSL Overview: Creating a Program Primarily concerned with drawing Preferred approach uses buffer objects All drawing done in terms of vertex arrays Programming style differs

### 3D Modeling. 3D Modeling 1

3D Modeling 3D Modeling 1 Virtual enviroments can be populated with "models" as well as regular geometries (glut shapes, glu quadrics, gl primitives). Models are: collections of primitives often in a display

### OpenGL: What s Coming Down the Graphics Pipeline. Dave Shreiner ARM

OpenGL: What s Coming Down the Graphics Pipeline Dave Shreiner ARM shreiner@siggraph.org 1 Syllabus Introduction Rendering Fundamentals Shader Overview Fundamental Techniques Applications [Shreiner] [Shreiner]

### Exercise 1 Introduction to OpenGL

Exercise 1 Introduction to OpenGL What we are going to do OpenGL Glut Small Example using OpenGl and Glut Alexandra Junghans 2 What is OpenGL? OpenGL Two Parts most widely used and supported graphics API

### Yazhuo Liu Homework 3

Yazhuo Liu Homework 3 Write a shader program that renders a colored tetrahedron, which gradually shrinks to a point and expands back to its original shape. While it is shrinking and expanding, the color

### CMSC427 OpenGL and JOGL

CMSC427 OpenGL and JOGL Step 1: Configuring and compiling In Eclipse following previous instructions Get from web page CMSC427OpenGLCode.zip Add graphics3dlib.jar to JOGL project From command line Add

### CS452/552; EE465/505. Image Formation

CS452/552; EE465/505 Image Formation 1-15-15 Outline! Image Formation! Introduction to WebGL, continued Draw a colored triangle using WebGL Read: Angel, Chapters 2 & 3 Homework #1 will be available on

### 1)Write a shader program that renders a regular pentagon with textured image like the one shown below.

Andrew Yenalavitch CSE520 Winter 2015 Quiz 2 Report 1)Write a shader program that renders a regular pentagon with textured image like the one shown below. Use the following provided image for the texture:

### Computergraphics Exercise 15/ Shading & Texturing

Computergraphics Exercise 15/16 3. Shading & Texturing Jakob Wagner for internal use only Shaders Vertex Specification define vertex format & data in model space Vertex Processing transform to clip space

### 1 Preview. Dr. Scott Gordon Computer Science Dept. CSUS. Virtual Cameras, Viewing Transformations: CSc-155 Advanced Computer Graphics

CSc-155 Advanced Computer Graphics 1 Preview Dr. Scott Gordon Computer Science Dept. CSUS Course Description Modeling, viewing, and rendering techniques in 3D computer graphics systems. Topics include:

### Tutorial 12: Real-Time Lighting B

Tutorial 12: Real-Time Lighting B Summary The last tutorial taught you the basics of real time lighting, including using the normal of a surface to calculate the diffusion and specularity. Surfaces are

### Lecture 2 CISC440/640 Spring Department of Computer and Information Science

Lecture 2 CISC440/640 Spring 2015 Department of Computer and Information Science Today s Topic The secrets of Glut-tony 2 So let s do some graphics! For the next week or so this is your world: -1 1-1 1

### CMSC427 Fall 2017 OpenGL Notes A: Starting with JOGL and OpenGL Objectives of notes Readings Computer Graphics Programming in OpenGL with Java

CMSC427 Fall 2017 OpenGL Notes A: Starting with JOGL and OpenGL Objectives of notes Show how to program full OpenGL in JOGL Start on shader programing Readings Computer Graphics Programming in OpenGL with

### CSE 167: Lecture #8: GLSL. Jürgen P. Schulze, Ph.D. University of California, San Diego Fall Quarter 2012

CSE 167: Introduction to Computer Graphics Lecture #8: GLSL Jürgen P. Schulze, Ph.D. University of California, San Diego Fall Quarter 2012 Announcements Homework project #4 due Friday, November 2 nd Introduction:

### This Lecture. Why OpenGL? Introduction to OpenGL. Programmer s View

Foundations of Computer Graphics Overview and Motivation This Lecture Introduction to OpenGL and simple demo code mytest1.cpp ; you compiled mytest3.cpp for HW 0 I am going to show (and write) actual code

### Particle Systems with Compute & Geometry Shader. Institute of Computer Graphics and Algorithms Vienna University of Technology

Particle Systems with Compute & Geometry Shader Institute of Computer Graphics and Algorithms Vienna University of Technology Motivation https://www.youtube.com/watch?v=spwbwtu9xyk 24.11.2016 RTR 2016

### Interaction. CSCI 420 Computer Graphics Lecture 3

CSCI 420 Computer Graphics Lecture 3 Interaction Jernej Barbic University of Southern California Client/Server Model Callbacks Double Buffering Hidden Surface Removal Simple Transformations [Angel Ch.

### VR-programming tools (procedural) More VRML later in this course! (declarative)

Realtime 3D Computer Graphics & Virtual Reality OpenGL Introduction VR-programming Input and display devices are the main hardware interface to users Immersion embeds users through the generation of live-like

### COURSE 17: STATE-OF-THE-ART IN SHADING HARDWARE1 CHAPTER 6: THE OPENGL SHADING LANGUAGE 2. Randi J. Rost 3Dlabs, Inc.

COURSE 17: STATE-OF-THE-ART IN SHADING HARDWARE1 CHAPTER 6: THE OPENGL SHADING LANGUAGE 2 Randi J. Rost 3Dlabs, Inc. SIGGRAPH 2002 Course Notes 05-August-2002 SIGGRAPH 2002 6-1 State of the Art in Shading

### Advanced Graphics. The Shader knows. Alex Benton, University of Cambridge Supported in part by Google UK, Ltd

Advanced Graphics The Shader knows Alex Benton, University of Cambridge A.Benton@damtp.cam.ac.uk Supported in part by Google UK, Ltd What is the shader? Local space World space Viewing space Local space

### Computer Graphics (4731) Lecture 4: 2D Graphics Systems (Drawing Polylines, tiling, & Aspect Ratio)

Computer Graphics (4731) Lecture 4: 2D Graphics Systems (Drawing Polylines, tiling, & Aspect Ratio) Prof Emmanuel Agu Computer Science Dept. Worcester Polytechnic Institute (WPI) Screen Coordinate System

Lessons Learned from HW Shading CS Interactive Computer Graphics Prof. David E. Breen Department of Computer Science Only have an idle() function if something is animated Set idle function to NULL, when

### Ulf Assarsson Department of Computer Engineering Chalmers University of Technology

Ulf Assarsson Department of Computer Engineering Chalmers University of Technology Tracing Photons One way to form an image is to follow rays of light from a point source finding which rays enter the lens

### Appendix A Cg Language Specification

Appendix A Cg Language Specification Language Overview The Cg language is primarily modeled on ANSI C, but adopts some ideas from modern languages such as C++ and Java, and from earlier shading languages

### GLSL Language Details

GLSL Language Details 41 Design Focus Based on syntax of ANSI C Some additions to support graphics functionality Some additions from C++ Some differences for a cleaner language design December 9, 2005

### Design Focus. GLSL Language Details. Additions from C++ Additions for Graphics

GLSL Language Details Design Focus Based on syntax of ANSI C Some additions to support graphics functionality Some additions from C++ Some differences for a cleaner language design 41 December 9, 2005

### CS GPU and GPGPU Programming Lecture 7: Shading and Compute APIs 1. Markus Hadwiger, KAUST

CS 380 - GPU and GPGPU Programming Lecture 7: Shading and Compute APIs 1 Markus Hadwiger, KAUST Reading Assignment #4 (until Feb. 23) Read (required): Programming Massively Parallel Processors book, Chapter

### This Lecture. Introduction to OpenGL. Outline. Why OpenGL? Programmer s View. Foundations of Computer Graphics

Foundations of Computer Graphics Overview and Motivation This Lecture Introduction to OpenGL and simple demo code mytest1.cpp ; you compiled mytest3.cpp for HW 0 I am going to show (and write) actual code

### To Do. Demo: Surreal (HW 3) This Lecture. Introduction to OpenGL. Outline. Foundations of Computer Graphics (Spring 2012)

Foundations of Computer Graphics (Spring 2012) CS 184, Lecture 6: OpenGL 1 http://inst.eecs.berkeley.edu/~cs184 To Do HW 1 due on Thu Must find partners for HW 2 (if problems, speak to TAs during section).

### Shaders (some slides taken from David M. course)

Shaders (some slides taken from David M. course) Doron Nussbaum Doron Nussbaum COMP 3501 - Shaders 1 Traditional Rendering Pipeline Traditional pipeline (older graphics cards) restricts developer to texture

### OpenGL shaders and programming models that provide object persistence

OpenGL shaders and programming models that provide object persistence COSC342 Lecture 22 19 May 2016 OpenGL shaders We discussed forms of local illumination in the ray tracing lectures. We also saw that