# CS452/552; EE465/505. Lighting & Shading

Save this PDF as:

Size: px
Start display at page:

## Transcription

1 CS452/552; EE465/505 Lighting & Shading

2 Outline! More on Lighting and Shading Read: Angel Chapter 6 Lab2: due tonight use ASDW to move a 2D shape around; 1 to center

3 Local Illumination! Approximate model! Local interaction between light, surface & viewer! Phong model: fast, supported in OpenGL/WebGL! Pixar Renderman (offline) Rendered without global illumination Rendered with global illumination wikipedia.org

4 Recap: Phong Reflection Model! Identify the important vectors in the diagram below: l n v r θ θ n the normal of the plane/vertex l the incoming light vector r the reflection vector v the viewpoint (camera)

5 INTERACTION BETWEEN MATERIAL AND LIGHTS! Final color of an object is comprised of many things: The base object color (called a material ) The light color Example: a purple light on a white surface Any textures we apply (later)! Materials and lights have four individual components Diffuse color (c d and l d ) Specular color (c s and l s ) Ambient color (c a and l a ) Emit color (c e and l e ) c d * l d = [c d.r *l d.r, c d.g *l d.g, c d.b *l d.b ] // R, G, B COPYRIGHT 2015 JEFF CHASTINE 5

6 FINAL COLOR!To determine the final color (excluding textures) we sum up all components: + final_color diffuse final_color specular final_color ambient final_color emit final_color COPYRIGHT 2015 JEFF CHASTINE 6

7 How OpenGL Simulates Lights! Phong lighting model The model is a balance between simple computation and physical realism a simple reflection model that can be used with real time graphics hardware The model uses Light positions and intensities Surface orientation (normals) Material properties (reflectivity) Viewer location Computed at the vertices for each source and each color component

8 COMMON KINDS OF LIGHTS Point light Directional Light Spot Light Area Light Interesting fact: Lights cannot be seen! Only their effects We can light per vertex (fast) or per fragment (slower) JEFF CHASTINE 8

9 POINT LIGHTS JEFF CHASTINE Here, per fragment lighting used 9

10 POINT LIGHTS JEFF CHASTINE Here, per vertex lighting used 10

11 DIRECTIONAL LIGHTS Are infinitely far away position in NO WAY matters Have only direction All objects are lit evenly Sometimes called a Sun JEFF CHASTINE 11

12 SPOTLIGHTS Point light source Conical in shape JEFF CHASTINE 12

13 SPOTLIGHTS Point light source Conical in shape Have: An inner and outer cone angle Umbra areas that are fully in shadow Penumbra areas that are in partial shadow Note: There s an ambient light JEFF CHASTINE 13

14 AREA LIGHTS A surface lights objects Has a position and direction Provides for a smoother drop off than point Larger surface == smoother shadows Expensive to calculate JEFF CHASTINE 14

15 Light Sources! In the Phong Model, we add the results from each light source! Each light source has separate diffuse, specular, and ambient terms to allow for maximum flexibility even though this form does not have a physical justification! Separate red, green and blue components! Hence, 9 coefficients for each point source I dr, I dg, I db, I sr, I sg, I sb, I ar, I ag, I ab

16 Material Properties! Material properties match light source properties Nine absorbtion coefficients k dr, k dg, k db, k sr, k sg, k sb, k ar, k ag, k ab Shininess coefficient α

17 Adding up the Components For each light source and each color component, the Phong model can be written (without the distance terms) as I =k d I d l n + k s I s (v r ) α + k a I a For each color component we add contributions from all sources

18 Modified Phong Model! The specular term in the Phong model is problematic because it requires the calculation of a new reflection vector and view vector for each vertex! Blinn suggested an approximation using the halfway vector that is more efficient

19 The Halfway Vector h is the normalized vector halfway between l and v h = ( l + v )/ l + v

20 Using the halfway vector! Replace (v r ) α by (n h ) β! β is chosen to match shininess! Note that halfway angle is half of angle between r and v if vectors are coplanar! Resulting model is known as the modified Phong or Phong-Blinn lighting model Specified in OpenGL standard

21 Example Only differences in these teapots are the parameters in the modified Phong model

22 Computation of Vectors! l and v are specified by the application! Can compute r from l and n! Problem is determining n! For simple surfaces it can be determined but how we determine n differs depending on underlying representation of surface! OpenGL leaves determination of normal to application Exception for GLU quadrics and Bezier surfaces was deprecated

23 Computing Reflection Direction! Angle of incidence = angle of reflection! Normal, light direction and reflection direction are coplaner! Want all three to be unit length r = 2(l n)n l

24 Plane Normals! Equation of plane: ax+by+cz+d = 0! From Chapter 4 we know that plane is determined by three points p 0, p 1, p 2 or normal n and p 0! Normal can be obtained by n = (p 2 -p 0 ) (p 1 -p 0 )

25 Normal to Sphere! Implicit function f(x,y.z)=0! Normal given by gradient! Sphere f(p)=p p-1! n = [ f/ x, f/ y, f/ z] T =p

26 Parametric Form! For sphere x=x(u,v)=cos u sin v y=y(u,v)=cos u cos v z= z(u,v)=sin u! Tangent plane determined by vectors p/ u = [ x/ u, y/ u, z/ u]t p/ v = [ x/ v, y/ v, z/ v]t! Normal given by cross product n = p/ u p/ v

27 General Case! We can compute parametric normals for other simple cases Quadrics Parametric polynomial surfaces Bezier surface patches (Chapter 11)

28 Lighting and Shading in WebGL! Introduce the WebGL shading methods Light and material functions on MV.js per vertex vs per fragment shading Where to carry out

29 WebGL lighting! Need Normals Material properties Lights State-based shading functions have been deprecated (glnormal, glmaterial, gllight) Compute in application or in shaders

30 Normalization! Cosine terms in lighting calculations can be computed using dot product! Unit length vectors simplify calculation! Usually we want to set the magnitudes to have unit length but Length can be affected by transformations Note that scaling does not preserved length! GLSL has a normalization function

31 Normal for Triangle p 1 n plane n (p - p 0 ) = 0 p 2 n = (p 2 - p 0 ) (p 1 - p 0 ) p normalize n n/ n p 0 Note that right-hand rule determines outward face

32 Specifying a Point Light Source! For each light source, we can set an RGBA for the diffuse, specular, and ambient components, and for the position var diffuse0 = vec4(1.0, 0.0, 0.0, 1.0); var ambient0 = vec4(1.0, 0.0, 0.0, 1.0); var specular0 = vec4(1.0, 0.0, 0.0, 1.0); var light0_pos = vec4(1.0, 2.0, 3,0, 1.0);

33 Distance and Direction! The source colors are specified in RGBA! The position is given in homogeneous coordinates If w =1.0, we are specifying a finite location If w =0.0, we are specifying a parallel source with the given direction vector! The coefficients in distance terms are usually quadratic (1/(a+b*d+c*d*d)) where d is the distance from the point being rendered to the light source

34 Spotlights! Derive from point source Direction Cutoff Attenuation Proportional to cos α φ θ φ θ

35 Global Ambient Light! Ambient light depends on color of light sources A red light in a white room will cause a red ambient term that disappears when the light is turned off! A global ambient term that is often helpful for testing

36 Moving Light Sources! Light sources are geometric objects whose positions or directions are affected by the model-view matrix! Depending on where we place the position (direction) setting function, we can Move the light source(s) with the object(s) Fix the object(s) and move the light source(s) Fix the light source(s) and move the object(s) Move the light source(s) and object(s) independently

37 Light Properties var lightposition = vec4(1.0, 1.0, 1.0, 0.0 ); var lightambient = vec4(0.2, 0.2, 0.2, 1.0 ); var lightdiffuse = vec4( 1.0, 1.0, 1.0, 1.0 ); var lightspecular = vec4( 1.0, 1.0, 1.0, 1.0 );

38 Material Properties! Material properties should match the terms in the light model! Reflectivities! w component gives opacity var materialambient = vec4( 1.0, 0.0, 1.0, 1.0 ); var materialdiffuse = vec4( 1.0, 0.8, 0.0, 1.0); var materialspecular = vec4( 1.0, 0.8, 0.0, 1.0 ); var materialshininess = 100.0;

39 Using MV.js for Products var ambientproduct = mult(lightambient, materialambient); var diffuseproduct = mult(lightdiffuse, materialdiffuse); var specularproduct = mult(lightspecular, materialspecular); gl.uniform4fv(gl.getuniformlocation(program, "ambientproduct"), flatten(ambientproduct)); gl.uniform4fv(gl.getuniformlocation(program, "diffuseproduct"), flatten(diffuseproduct) ); gl.uniform4fv(gl.getuniformlocation(program, "specularproduct"), flatten(specularproduct) ); gl.uniform4fv(gl.getuniformlocation(program, "lightposition"), flatten(lightposition) ); gl.uniform1f(gl.getuniformlocation(program, "shininess"),materialshininess);

40 Adding Normals for Quads function quad(a, b, c, d) { var t1 = subtract(vertices[b], vertices[a]); var t2 = subtract(vertices[c], vertices[b]); var normal = cross(t1, t2); var normal = vec3(normal); normal = normalize(normal); pointsarray.push(vertices[a]); normalsarray.push(normal);...

41 Front and Back Faces! Every face has a front and back! For many objects, we never see the back face so we don t care how or if it s rendered! If it matters, we can handle in shader back faces not visible back faces visible

42 Emissive Term! We can simulate a light source in WebGL by giving a material an emissive component! This component is unaffected by any sources or transformations

43 Transparency! Material properties are specified as RGBA values! The A value can be used to make the surface translucent! The default is that all surfaces are opaque! Later we will enable blending and use this feature! However with the HTML5 canvas, A<1 will mute colors

44 Adding Lighting to Cube // vertex shader attribute vec4 vposition; attribute vec3 vnormal; varying vec4 fcolor; uniform vec4 ambientproduct, diffuseproduct, specularproduct; uniform mat4 modelviewmatrix; uniform mat4 projectionmatrix; uniform vec4 lightposition; uniform float shininess;

45 Adding Lighting to Cube void main() { // Transform vertex position into eye coords vec3 pos = -(modelviewmatrix * vposition).xyz; vec3 light = lightposition.xyz; vec3 L = normalize( light - pos ); vec3 E = normalize( -pos ); vec3 H = normalize( L + E ); vec4 NN = vec4(vnormal,0); // Transform vertex normal into eye coordinates vec3 N = normalize( (modelviewmatrix*nn).xyz);

46 Adding Lighting to Cube // Compute terms in the illumination equation vec4 ambient = ambientproduct; float Kd = max( dot(l, N), 0.0 ); vec4 diffuse = Kd*diffuseProduct; float Ks = pow( max(dot(n, H), 0.0), shininess ); vec4 specular = Ks * specularproduct; if(dot(l, N)<0.0) {specular=vec4(0.0,0.0,0.0,1.0);} gl_position = projectionmatrix * modelviewmatrix * vposition; fcolor = ambient + diffuse +specular; fcolor.a = 1.0;}

47 Polygonal Shading! Now we know vertex colors can be determined either via OpenGL/WebGL lighting, or by setting directly if lighting disabled! How do we shade the interior of the triangle?

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

### Objectives. Introduce the OpenGL shading Methods 1) Light and material functions on MV.js 2) per vertex vs per fragment shading 3) Where to carry out

Objectives Introduce the OpenGL shading Methods 1) Light and material functions on MV.js 2) per vertex vs per fragment shading 3) Where to carry out 1 Steps in OpenGL shading Enable shading and select

### Shading II. Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts University of New Mexico

Shading II Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts University of New Mexico 1 Objectives Continue discussion of shading Introduce modified Phong model

### Objectives. Continue discussion of shading Introduce modified Phong model Consider computation of required vectors

Objectives Continue discussion of shading Introduce modified Phong model Consider computation of required vectors 1 Lambertian Surface Perfectly diffuse reflector Light scattered equally in all directions

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

### Three-Dimensional Graphics V. Guoying Zhao 1 / 55

Computer Graphics Three-Dimensional Graphics V Guoying Zhao 1 / 55 Shading Guoying Zhao 2 / 55 Objectives Learn to shade objects so their images appear three-dimensional Introduce the types of light-material

### Objectives. Shading II. Distance Terms. The Phong Reflection Model

Shading II Objectives Introduce distance terms to the shading model. More details about the Phong model (lightmaterial interaction). Introduce the Blinn lighting model (also known as the modified Phong

### Comp 410/510 Computer Graphics. Spring Shading

Comp 410/510 Computer Graphics Spring 2017 Shading Why we need shading Suppose we build a model of a sphere using many polygons and then color it using a fixed color. We get something like But we rather

Why we need shading? Suppose we build a model of a sphere using many polygons and color it with glcolor. We get something like But we want Light-material interactions cause each point to have a different

Illumination & Shading Goals Introduce the types of light-material interactions Build a simple reflection model---the Phong model--- that can be used with real time graphics hardware Why we need Illumination

CS 543: Computer Graphics Illumination & Shading I Robert W. Lindeman Associate Professor Interactive Media & Game Development Department of Computer Science Worcester Polytechnic Institute gogo@wpi.edu

### Computer Graphics. Shading. Based on slides by Dianna Xu, Bryn Mawr College

Computer Graphics Shading Based on slides by Dianna Xu, Bryn Mawr College Image Synthesis and Shading Perception of 3D Objects Displays almost always 2 dimensional. Depth cues needed to restore the third

### Lighting and Shading Computer Graphics I Lecture 7. Light Sources Phong Illumination Model Normal Vectors [Angel, Ch

15-462 Computer Graphics I Lecture 7 Lighting and Shading February 12, 2002 Frank Pfenning Carnegie Mellon University http://www.cs.cmu.edu/~fp/courses/graphics/ Light Sources Phong Illumination Model

### Computer Graphics. Illumination and Shading

() Illumination and Shading Dr. Ayman Eldeib Lighting So given a 3-D triangle and a 3-D viewpoint, we can set the right pixels But what color should those pixels be? If we re attempting to create a realistic

Shading and Illumination OpenGL Shading Without Shading With Shading Physics Bidirectional Reflectance Distribution Function (BRDF) f r (ω i,ω ) = dl(ω ) L(ω i )cosθ i dω i = dl(ω ) L(ω i )( ω i n)dω

### CS Illumination and Shading. Slide 1

CS 112 - Illumination and Shading Slide 1 Illumination/Lighting Interaction between light and surfaces Physics of optics and thermal radiation Very complex: Light bounces off several surface before reaching

### ECS 175 COMPUTER GRAPHICS. Ken Joy.! Winter 2014

ECS 175 COMPUTER GRAPHICS Ken Joy Winter 2014 Shading To be able to model shading, we simplify Uniform Media no scattering of light Opaque Objects No Interreflection Point Light Sources RGB Color (eliminating

### Orthogonal Projection Matrices. Angel and Shreiner: Interactive Computer Graphics 7E Addison-Wesley 2015

Orthogonal Projection Matrices 1 Objectives Derive the projection matrices used for standard orthogonal projections Introduce oblique projections Introduce projection normalization 2 Normalization Rather

### Methodology for Lecture. Importance of Lighting. Outline. Shading Models. Brief primer on Color. Foundations of Computer Graphics (Spring 2010)

Foundations of Computer Graphics (Spring 2010) CS 184, Lecture 11: OpenGL 3 http://inst.eecs.berkeley.edu/~cs184 Methodology for Lecture Lecture deals with lighting (teapot shaded as in HW1) Some Nate

### Deferred Rendering Due: Wednesday November 15 at 10pm

CMSC 23700 Autumn 2017 Introduction to Computer Graphics Project 4 November 2, 2017 Deferred Rendering Due: Wednesday November 15 at 10pm 1 Summary This assignment uses the same application architecture

### Introduction to Computer Graphics. Farhana Bandukwala, PhD Lecture 14: Light Interacting with Surfaces

Introduction to Computer Graphics Farhana Bandukwala, PhD Lecture 14: Light Interacting with Surfaces Outline Computational tools Reflection models Polygon shading Computation tools Surface normals Vector

### 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:

### CGT520 Lighting. Lighting. T-vertices. Normal vector. Color of an object can be specified 1) Explicitly as a color buffer

CGT520 Lighting Lighting Color of an object can be specified 1) Explicitly as a color buffer Bedrich Benes, Ph.D. Purdue University Department of Computer Graphics 2) Implicitly from the illumination model.

### Color and Light. CSCI 4229/5229 Computer Graphics Summer 2008

Color and Light CSCI 4229/5229 Computer Graphics Summer 2008 Solar Spectrum Human Trichromatic Color Perception Are A and B the same? Color perception is relative Transmission,Absorption&Reflection Light

### Illumination and Shading with GLSL/WebGL

Illumination and Shading with GLSL/WebGL Illumination with Shaders! Remember the local illumination model (Phong illumination) Illumination = ambient + diffuse + specular = Ka x Ia + Kd x Id x (N.L) +

### CS5620 Intro to Computer Graphics

So Far wireframe hidden surfaces Next step 1 2 Light! Need to understand: How lighting works Types of lights Types of surfaces How shading works Shading algorithms What s Missing? Lighting vs. Shading

Illumination and Shading Illumination (Lighting)! Model the interaction of light with surface points to determine their final color and brightness! The illumination can be computed either at vertices or

### CPSC 314 LIGHTING AND SHADING

CPSC 314 LIGHTING AND SHADING UGRAD.CS.UBC.CA/~CS314 slide credits: Mikhail Bessmeltsev et al 1 THE RENDERING PIPELINE Vertices and attributes Vertex Shader Modelview transform Per-vertex attributes Vertex

### CEng 477 Introduction to Computer Graphics Fall

Illumination Models and Surface-Rendering Methods CEng 477 Introduction to Computer Graphics Fall 2007 2008 Illumination Models and Surface Rendering Methods In order to achieve realism in computer generated

Illumination and Shading Illumination (Lighting) Model the interaction of light with surface points to determine their final color and brightness OpenGL computes illumination at vertices illumination Shading

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

CSE 167: Introduction to Computer Graphics Lecture #8: Lighting Jürgen P. Schulze, Ph.D. University of California, San Diego Fall Quarter 2011 Announcements Homework project #4 due Friday, October 28 Introduction:

### Lighting and Shading. Slides: Tamar Shinar, Victor Zordon

Lighting and Shading Slides: Tamar Shinar, Victor Zordon Why we need shading Suppose we build a model of a sphere using many polygons and color each the same color. We get something like But we want 2

### 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

### Shading , Fall 2004 Nancy Pollard Mark Tomczak

15-462, Fall 2004 Nancy Pollard Mark Tomczak Shading Shading Concepts Shading Equations Lambertian, Gouraud shading Phong Illumination Model Non-photorealistic rendering [Shirly, Ch. 8] Announcements Written

### So far, we have considered only local models of illumination; they only account for incident light coming directly from the light sources.

11 11.1 Basics So far, we have considered only local models of illumination; they only account for incident light coming directly from the light sources. Global models include incident light that arrives

### CENG 477 Introduction to Computer Graphics. Ray Tracing: Shading

CENG 477 Introduction to Computer Graphics Ray Tracing: Shading Last Week Until now we learned: How to create the primary rays from the given camera and image plane parameters How to intersect these rays

Illumination and Shading Computer Graphics COMP 770 (236) Spring 2007 Instructor: Brandon Lloyd 2/14/07 1 From last time Texture mapping overview notation wrapping Perspective-correct interpolation 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

### 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:

### Illumination Models and Surface-Rendering Methods. Chapter 10

Illumination Models and Surface-Rendering Methods Chapter 10 Illumination and Surface- Rendering Given scene specifications object positions, optical properties of the surface, viewer position, viewing

### Recall: Indexing into Cube Map

Recall: Indexing into Cube Map Compute R = 2(N V)N-V Object at origin Use largest magnitude component of R to determine face of cube Other 2 components give texture coordinates V R Cube Map Layout Example

9. Illumination and Shading Approaches for visual realism: - Remove hidden surfaces - Shade visible surfaces and reproduce shadows - Reproduce surface properties Texture Degree of transparency Roughness,

### Lecture 10: Shading Languages. Kayvon Fatahalian CMU : Graphics and Imaging Architectures (Fall 2011)

Lecture 10: Shading Languages Kayvon Fatahalian CMU 15-869: Graphics and Imaging Architectures (Fall 2011) Review: role of shading languages Renderer handles surface visibility tasks - Examples: clip,

### CS452/552; EE465/505. Texture Mapping in WebGL

CS452/552; EE465/505 Texture Mapping in WebGL 2-26 15 Outline! Texture Mapping in WebGL Read: Angel, Chapter 7, 7.3-7.5 LearningWebGL lesson 5: http://learningwebgl.com/blog/?p=507 Lab3 due: Monday, 3/2

Shaders Oscar 1/43 Apodaca and Gritz, Advanced RenderMan Pixel Color Irradiance measures the power per unit area hitting a pixel E = න L i cos θ i dω i (obtained by integrating an equation form last class)

### Ambient reflection. Jacobs University Visualization and Computer Graphics Lab : Graphics and Visualization 407

Ambient reflection Phong reflection is a local illumination model. It only considers the reflection of light that directly comes from the light source. It does not compute secondary reflection of light

### CS452/552; EE465/505. Models & Viewing

CS452/552; EE465/505 Models & Viewing 2-03 15 Outline! Building Polygonal Models Vertex lists; gl.drawarrays( ) Edge lists: gl.drawelements( )! Viewing Classical Viewing Read: Viewing in Web3D Angel, Section

### 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

### Topic 9: Lighting & Reflection models 9/10/2016. Spot the differences. Terminology. Two Components of Illumination. Ambient Light Source

Topic 9: Lighting & Reflection models Lighting & reflection The Phong reflection model diffuse component ambient component specular component Spot the differences Terminology Illumination The transport

### 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

### CSE 167: Lecture #7: Color and Shading. Jürgen P. Schulze, Ph.D. University of California, San Diego Fall Quarter 2011

CSE 167: Introduction to Computer Graphics Lecture #7: Color and Shading Jürgen P. Schulze, Ph.D. University of California, San Diego Fall Quarter 2011 Announcements Homework project #3 due this Friday,

### Introduction to 3D Graphics

Introduction to 3D Graphics Using OpenGL 3D 1/46 Classical Polygon Graphics (H/W) Pipeline Mesh objects with 3D polygons (triangles or quads usually) Apply material properties to each object (for reflectance

### 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

### The Rasterization Pipeline

Lecture 5: The Rasterization Pipeline Computer Graphics and Imaging UC Berkeley CS184/284A, Spring 2016 What We ve Covered So Far z x y z x y (0, 0) (w, h) Position objects and the camera in the world

### 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

### Ø Sampling Theory" Ø Fourier Analysis Ø Anti-aliasing Ø Supersampling Strategies" Ø The Hall illumination model. Ø Original ray tracing paper

CS 431/636 Advanced Rendering Techniques Ø Dr. David Breen Ø Korman 105D Ø Wednesday 6PM 8:50PM Presentation 6 5/16/12 Questions from ast Time? Ø Sampling Theory" Ø Fourier Analysis Ø Anti-aliasing Ø Supersampling

### Computer Graphics - Week 4

Computer Graphics - Week 4 Bengt-Olaf Schneider IBM T.J. Watson Research Center Questions about Last Week? Information about ACIS will be available tomorrow... Check the newsgroup You should have started

### The Rasterization Pipeline

Lecture 5: The Rasterization Pipeline Computer Graphics and Imaging UC Berkeley What We ve Covered So Far z x y z x y (0, 0) (w, h) Position objects and the camera in the world Compute position of objects

### CSE 681 Illumination and Phong Shading

CSE 681 Illumination and Phong Shading Physics tells us What is Light? We don t see objects, we see light reflected off of objects Light is a particle and a wave The frequency of light What is Color? Our

### Assignment 6: Ray Tracing

Assignment 6: Ray Tracing Programming Lab Due: Monday, April 20 (midnight) 1 Introduction Throughout this semester you have written code that manipulated shapes and cameras to prepare a scene for rendering.

### x ~ Hemispheric Lighting

Irradiance and Incoming Radiance Imagine a sensor which is a small, flat plane centered at a point ~ x in space and oriented so that its normal points in the direction n. This sensor can compute the total

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

Building Models 1 Objectives Introduce simple data structures for building polygonal models Vertex lists Edge lists 2 Representing a Mesh Consider a mesh v 5 v 6 e e e 3 v 9 8 8 v e 4 1 e 11 e v v 7 7

### CMSC427 Advanced shading getting global illumination by local methods. Credit: slides Prof. Zwicker

CMSC427 Advanced shading getting global illumination by local methods Credit: slides Prof. Zwicker Topics Shadows Environment maps Reflection mapping Irradiance environment maps Ambient occlusion Reflection

Fall 2017 CSCI 420: Computer Graphics 5.2 Shading in OpenGL Hao Li http://cs420.hao-li.com 1 Outline Normal Vectors in OpenGL Polygonal Shading Light Sources in OpenGL Material Properties in OpenGL Example:

### Lets assume each object has a defined colour. Hence our illumination model is looks unrealistic.

Shading Models There are two main types of rendering that we cover, polygon rendering ray tracing Polygon rendering is used to apply illumination models to polygons, whereas ray tracing applies to arbitrary

### Raytracing CS148 AS3. Due :59pm PDT

Raytracing CS148 AS3 Due 2010-07-25 11:59pm PDT We start our exploration of Rendering - the process of converting a high-level object-based description of scene into an image. We will do this by building

### 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

### CS 5625 Lec 2: Shading Models

CS 5625 Lec 2: Shading Models Kavita Bala Spring 2013 Shading Models Chapter 7 Next few weeks Textures Graphics Pipeline Light Emission To compute images What are the light sources? Light Propagation Fog/Clear?

### Lights, Colour and Materials In OpenGL

Illumination Models Lights, Colour and Materials In OpenGL Illumination models are used to generate the colour of an object s surface at a given point on that surface. The factors that govern the illumination

### 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

Illumination and Shading Illumination and Shading z Illumination Models y Ambient y Diffuse y Attenuation y Specular Reflection z Interpolated Shading Models y Flat, Gouraud, Phong y Problems CS4451: Fall

### Shading Languages. Seminar Computer Graphics. Markus Kummerer

Shading Languages Markus Kummerer ABSTRACT Shading Languages provide a highly flexible approach for creating visual structures in computer imagery. The RenderMan Interface provides an API for scene description,

### COMP environment mapping Mar. 12, r = 2n(n v) v

Rendering mirror surfaces The next texture mapping method assumes we have a mirror surface, or at least a reflectance function that contains a mirror component. Examples might be a car window or hood,

### 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:

### 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

### Photorealism: Ray Tracing

Photorealism: Ray Tracing Reading Assignment: Chapter 13 Local vs. Global Illumination Local Illumination depends on local object and light sources only Global Illumination at a point can depend on any

### Computer Graphics I. Assignment 3

UNIVERSITÄT DES SAARLANDES Dr.-Ing. Hendrik P.A. Lensch Max Planck Institut Informatik Art Tevs (tevs@mpi-inf.mpg.de) Boris Ajdin (bajdin@mpi-inf.mpg.de) Matthias Hullin (hullin@mpi-inf.mpg.de) 12. November

### Introduction to 3D Graphics

Introduction to 3D Graphics Using OpenGL 3D 1/46 Classical Polygon Graphics (H/W) Pipeline Mesh objects with 3D polygons (triangles or quads usually) Apply material properties to each object (for reflectance

### CG Surfaces: Materials, Shading, and Texturing

CG Surfaces: Materials, Shading, and Texturing ART/CSC/FST 220 Spring 2007 From text: 3D for Beginners, Chapter 7 Art of Maya (pages 116-126, 185-194) Shading and texturing involves materials and their

### Computergrafik. Matthias Zwicker Universität Bern Herbst 2016

Computergrafik Matthias Zwicker Universität Bern Herbst 2016 Today More shading Environment maps Reflection mapping Irradiance environment maps Ambient occlusion Reflection and refraction Toon shading

### Notes on Computer Graphics and OpenGL. Thomas Strathmann

Notes on Computer Graphics and OpenGL Thomas Strathmann February 2, 2011 Preface The purpose of this document is to server as a sort of logbook in which I put down all the interesting math and assorted

### Curves and Surfaces Computer Graphics I Lecture 9

15-462 Computer Graphics I Lecture 9 Curves and Surfaces Parametric Representations Cubic Polynomial Forms Hermite Curves Bezier Curves and Surfaces [Angel 10.1-10.6] February 19, 2002 Frank Pfenning Carnegie

### 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

### Surface Reflection Models

Surface Reflection Models Frank Losasso (flosasso@nvidia.com) Introduction One of the fundamental topics in lighting is how the light interacts with the environment. The academic community has researched

### 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

### Light Sources. Spotlight model

lecture 12 Light Sources sunlight (parallel) Sunny day model : "point source at infinity" - lighting - materials: diffuse, specular, ambient spotlight - shading: Flat vs. Gouraud vs Phong light bulb ambient

### AGDC Per-Pixel Shading. Sim Dietrich

AGDC Per-Pixel Shading Sim Dietrich Goal Of This Talk The new features of Dx8 and the next generation of HW make huge strides in the area of Per-Pixel Shading Most developers have yet to adopt Per-Pixel

### Texture Mapping. CS 537 Interactive Computer Graphics Prof. David E. Breen Department of Computer Science

Texture Mapping CS 537 Interactive Computer Graphics Prof. David E. Breen Department of Computer Science 1 Objectives Introduce Mapping Methods - Texture Mapping - Environment Mapping - Bump Mapping Consider

### Open Game Engine Exchange Specification

Open Game Engine Exchange Specification Version 1.0.1 by Eric Lengyel Terathon Software LLC Roseville, CA Open Game Engine Exchange Specification ISBN-13: 978-0-9858117-2-3 Copyright 2014, by Eric Lengyel

### Computer Graphics. Lecture 13. Global Illumination 1: Ray Tracing and Radiosity. Taku Komura

Computer Graphics Lecture 13 Global Illumination 1: Ray Tracing and Radiosity Taku Komura 1 Rendering techniques Can be classified as Local Illumination techniques Global Illumination techniques Local

### Announcement. Lighting and Photometric Stereo. Computer Vision I. Surface Reflectance Models. Lambertian (Diffuse) Surface.

Lighting and Photometric Stereo CSE252A Lecture 7 Announcement Read Chapter 2 of Forsyth & Ponce Might find section 12.1.3 of Forsyth & Ponce useful. HW Problem Emitted radiance in direction f r for incident

DH2323 DGI15 INTRODUCTION TO COMPUTER GRAPHICS AND INTERACTION LIGHTING AND SHADING Christopher Peters HPCViz, KTH Royal Institute of Technology, Sweden chpeters@kth.se http://kth.academia.edu/christopheredwardpeters

### 3D Programming. 3D Programming Concepts. Outline. 3D Concepts. 3D Concepts -- Coordinate Systems. 3D Concepts Displaying 3D Models

3D Programming Concepts Outline 3D Concepts Displaying 3D Models 3D Programming CS 4390 3D Computer 1 2 3D Concepts 3D Model is a 3D simulation of an object. Coordinate Systems 3D Models 3D Shapes 3D Concepts

### 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)?

### 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