C O M P U T E R G R A P H I C S. Computer Graphics. Three-Dimensional Graphics V. Guoying Zhao 1 / 65

Similar documents
Shading. Why we need shading. Scattering. Shading. Objectives

Lighting and Shading II. Angel and Shreiner: Interactive Computer Graphics 7E Addison-Wesley 2015

Overview. Shading. Shading. Why we need shading. Shading Light-material interactions Phong model Shading polygons Shading in OpenGL

Three-Dimensional Graphics V. Guoying Zhao 1 / 55

WHY WE NEED SHADING. Suppose we build a model of a sphere using many polygons and color it with glcolor. We get something like.

Lessons Learned from HW4. Shading. Objectives. Why we need shading. Shading. Scattering

Comp 410/510 Computer Graphics. Spring Shading

Objectives. Introduce Phong model Introduce modified Phong model Consider computation of required vectors Discuss polygonal shading.

Introduction to Computer Graphics 7. Shading

CS452/552; EE465/505. Lighting & Shading

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

CS 4600 Fall Utah School of Computing

Illumination & Shading

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

Why we need shading?

Shading I Computer Graphics I, Fall 2008

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

Lecture 17: Shading in OpenGL. CITS3003 Graphics & Animation

Lecture 15: Shading-I. CITS3003 Graphics & Animation

CS452/552; EE465/505. Intro to Lighting

Objectives Shading in OpenGL. Front and Back Faces. OpenGL shading. Introduce the OpenGL shading methods. Discuss polygonal shading

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

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

Shading II. CITS3003 Graphics & Animation

Computer Graphics (CS 543) Lecture 7b: Intro to lighting, Shading and Materials + Phong Lighting Model

Computer Graphics (CS 4731) Lecture 16: Lighting, Shading and Materials (Part 1)

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

w Foley, Section16.1 Reading

Today. Global illumination. Shading. Interactive applications. Rendering pipeline. Computergrafik. Shading Introduction Local shading models

CS130 : Computer Graphics Lecture 8: Lighting and Shading. Tamar Shinar Computer Science & Engineering UC Riverside

Virtual Reality for Human Computer Interaction

ECS 175 COMPUTER GRAPHICS. Ken Joy.! Winter 2014

Computer Graphics (CS 543) Lecture 8a: Per-Vertex lighting, Shading and Per-Fragment lighting

Today. Global illumination. Shading. Interactive applications. Rendering pipeline. Computergrafik. Shading Introduction Local shading models

Lighting. Figure 10.1

Reading. Shading. An abundance of photons. Introduction. Required: Angel , 6.5, Optional: Angel 6.4 OpenGL red book, chapter 5.

Illumination & Shading I

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

Illumination in Computer Graphics

Reflection and Shading

Computer Graphics. Illumination and Shading

Introduction to Computer Graphics with WebGL

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

Local Illumination. CMPT 361 Introduction to Computer Graphics Torsten Möller. Machiraju/Zhang/Möller

CS 418: Interactive Computer Graphics. Basic Shading in WebGL. Eric Shaffer

TSBK 07! Computer Graphics! Ingemar Ragnemalm, ISY

Reading. Shading. Introduction. An abundance of photons. Required: Angel , Optional: OpenGL red book, chapter 5.

Illumination Models & Shading

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

Introduction. Lighting model Light reflection model Local illumination model Reflectance model BRDF

Introduction to Computer Graphics with WebGL

CHAPTER5. We have learned to build three-dimensional graphical models and to LIGHTING AND SHADING

Illumination & Shading: Part 1

CS5620 Intro to Computer Graphics

CMSC427 Shading Intro. Credit: slides from Dr. Zwicker

Rendering. Illumination Model. Wireframe rendering simple, ambiguous Color filling flat without any 3D information

Graphics for VEs. Ruth Aylett

Graphics for VEs. Ruth Aylett

Shading. Reading. Pinhole camera. Basic 3D graphics. Brian Curless CSE 557 Fall Required: Shirley, Chapter 10

Computer Graphics. Illumination Models and Surface-Rendering Methods. Somsak Walairacht, Computer Engineering, KMITL

Computer Graphics (CS 4731) Lecture 18: Lighting, Shading and Materials (Part 3)

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

CS Computer Graphics: Illumination and Shading I

CS Computer Graphics: Illumination and Shading I

Shading. Brian Curless CSE 457 Spring 2017

Lighting and Shading. Slides: Tamar Shinar, Victor Zordon

Topic 9: Lighting & Reflection models. Lighting & reflection The Phong reflection model diffuse component ambient component specular component

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

Pipeline Operations. CS 4620 Lecture 14

Illumination and Shading

Shading. Brian Curless CSE 557 Autumn 2017

Shading Intro. Shading & Lighting. Light and Matter. Light and Matter

Illumination and Shading

Pipeline Operations. CS 4620 Lecture Steve Marschner. Cornell CS4620 Spring 2018 Lecture 11

Computer Graphics. Illumination and Shading

Chapter 10. Surface-Rendering Methods. Somsak Walairacht, Computer Engineering, KMITL

CEng 477 Introduction to Computer Graphics Fall

Shading. Brian Curless CSE 457 Spring 2015

Models and Architectures

OpenGl Pipeline. triangles, lines, points, images. Per-vertex ops. Primitive assembly. Texturing. Rasterization. Per-fragment ops.

CPSC 314 LIGHTING AND SHADING

Display Issues Week 5

Today s class. Simple shadows Shading Lighting in OpenGL. Informationsteknologi. Wednesday, November 21, 2007 Computer Graphics - Class 10 1

Virtual Reality for Human Computer Interaction

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

Graphics and Visualization

CS Illumination and Shading. Slide 1

Introduction to Visualization and Computer Graphics

Shading. CSE 457 Winter 2015

CS Surface Rendering

Visualisatie BMT. Rendering. Arjan Kok

Color and Light CSCI 4229/5229 Computer Graphics Fall 2016

Today we will start to look at illumination models in computer graphics

Computer Graphics with OpenGL ES (J. Han) Chapter 6 Fragment shader

Shading. Slides by Ulf Assarsson and Tomas Akenine-Möller Department of Computer Engineering Chalmers University of Technology

Pipeline Operations. CS 4620 Lecture 10

Topics and things to know about them:

Computer Graphics. Ray Tracing. Based on slides by Dianna Xu, Bryn Mawr College

Simple Lighting/Illumination Models

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

Transcription:

Computer Graphics Three-Dimensional Graphics V Guoying Zhao 1 / 65

Shading Guoying Zhao 2 / 65

Objectives Learn to shade objects so their images appear three-dimensional Introduce the types of light-material interactions Build a simple reflection model --- the Phong model --- that can be used with real time graphics hardware Introduce modified Phong model Consider computation of required vectors Guoying Zhao 3 / 65

Why we need shading Suppose we build a model of a sphere using many polygons and color it with a constant color. We get something like consequence of our unnatural assumption that each surface is colored with a single color But we want a circular shape with many gradations or shades of color Guoying Zhao 4 / 65

Shading Why does the image of a real sphere look like Light-material interactions cause each point to have a different color or shade Need to consider Light sources Material properties Location of viewer Surface orientation Guoying Zhao 5 / 65

Scattering Light strikes A Some scattered Some absorbed Some of scattered light strikes B Some scattered Some absorbed Some of this scattered light strikes A, and so on This recursive scattering of light between surfaces accounts for subtle shading effects Guoying Zhao 6 / 65

Guoying Zhao 7 / 65 Rendering Equation The infinite scattering and absorption of light can be described by the rendering equation Cannot be solved analytical in general Numerical methods not fast enough Various approximation: Ray tracing, radiosity Rendering equation is global and includes Shadows Multiple scattering from object to object Focus on a simple local model -> compromise between physical correctness and efficient calculation.

Global Effects shadow translucent surface multiple reflection We start following rays of light from a point source. Viewer sees only the light that leaves the source and reaches his eyes-perhaps through a complex path and multiple interactions with objects in the scene. Guoying Zhao 8 / 65

Guoying Zhao 9 / 65 Physical Approaches Ray tracing: follow rays of light from center of projection until they either are absorbed by objects or go off to infinity Can handle global effects Multiple reflections Translucent objects Slow Must have whole data base available at all times Radiosity: Energy based approach viewpoint independent Very slow

Local illumination models Local illumination: (compromise between physical correctness and efficient calculation) consider only the light source(s) and a surface point Global illumination: also take all the other surfaces into account Guoying Zhao 10 / 65

Local vs Global Rendering Correct shading requires a global calculation involving all objects and light sources Incompatible with pipeline model which shades each polygon independently (local rendering) However, in computer graphics, especially real time graphics, we are happy if things look right Exist many techniques for approximating global effects Guoying Zhao 11 / 65

Light-Material Interaction Light that strikes an object is partially absorbed and partially scattered (reflected) The amount reflected determines the color and brightness of the object A surface appears red under white light because the red component of the light is reflected and the rest is absorbed The reflected light is scattered in a manner that depends on the smoothness and orientation of the surface Guoying Zhao 12 / 65

Light Sources General light sources are difficult to work with because we must integrate light coming from all points on the source Light can leave a surface through two fundamental processes: self-emission and reflection. A light source: an object with a surface Each point can emit light: direction and intensity Guoying Zhao 13 / 65

Simple Light Sources Point source: emits light equally Model with position and color Distant source = infinite distance away (parallel) Spotlight: narrow range of angles Restrict light from ideal point source: limiting the angles at which light from the source can be seen. Ambient light: uniform lighting Same amount of light everywhere in scene Can model contribution of many sources and reflecting surfaces Guoying Zhao 14 / 65

Surface Types The smoother a surface, the more reflected light is concentrated in the direction a perfect mirror would reflect the light A very rough surface scatters light in all directions smooth surface rough surface Guoying Zhao 15 / 65

Phong illumination model We re going to build up to an approximation of reality called the Phong illumination model It has the following characteristics: a local illumination model not physically based gives a first-order approximation to physical light reflection very fast widely used Guoying Zhao 16 / 65

Phong Model A simple model that can be computed rapidly Introduced by Phone and later modified by Blinn Proved to be efficient and to be a close enough approximation to physical reality to produce good renderings under a variety of lighting conditions and material properties. Guoying Zhao 17 / 65

Phong Model Uses four vectors: calculate a color for an arbitrary point p on a surface Normal: n To viewer: v To source: l Perfect reflector: r of l (determined by n and l) Has three components: light-material interactions Diffuse Specular Ambient Guoying Zhao 18 / 65

Ideal Reflector Normal is determined by local orientation Angle of incidence = angle of reflection The three vectors must be coplanar r = 2 (l n ) n - l Guoying Zhao 19 / 65

Guoying Zhao 20 / 65 Lambertian Surface Perfectly diffuse reflector Light scattered equally in all directions Appears same to all viewers Amount of light reflected is proportional to the vertical component of incoming light reflected light ~cos q i cos q i = l n if vectors normalized: I =k d I d l n There are also three coefficients, k r, k b, k g that show how much of each color component is reflected

Specular Surfaces Whereas a diffuse surface is rough, a specular surface is smooth Smooth surfaces show specular highlights due to incoming light being reflected in directions concentrated close to the direction of a perfect reflection Most surfaces are neither ideal diffusers nor perfectly specular (ideal reflectors) Guoying Zhao 21 / 65 specular highlight

Specular reflection Specular reflection accounts for the highlight that you see on some objects It is particularly important for smooth, shiny surfaces, such as: metal polished stone plastics apples on a supermarket The color is often determined solely by the color of the light corresponds to absence of internal reflections Guoying Zhao 22 / 65

Modeling Specular Reflections Phong proposed using a term that dropped off as the angle between the viewer and the ideal reflection increased I r ~ k s I cos α φ reflected shininess coef intensity incoming intensity absorption coef φ Guoying Zhao 23 / 65

The Shininess Coefficient As α increases, how the reflected light is concentrated in a narrower region centered on the angle of a perfect reflector Values of a between 100 and 200 correspond to metals: narrow highlights Values between 5 and 10 give surface that look like plastic: broad highlights cos α φ -90 φ 90 Guoying Zhao 24 / 65

Derivation, cont. One way to model near-perfect reflector is to take cos φ = (r v)/( r v ), raised to a power α (cos φ) α φ As α gets larger, the dropoff becomes {more,less} gradual gives a {larger,smaller} highlight simulates a {more,less} glossy surface Guoying Zhao 25 / 65 -pi/2 0 pi/2 smaller more less φ

Ambient reflection Ambient light is the result of multiple interactions between (large) light sources and the objects in the environment Amount and color depend on both the color of the light(s) and the material properties of the object Add k a I a to diffuse and specular terms reflection coef intensity of ambient light I a can be any of the individual light sources, or it can be a global ambient term. Guoying Zhao 26 / 65

Guoying Zhao 27 / 65 Distance Terms The light from a point source that reaches a surface is inversely proportional to the square of the distance between them We can add a factor of the quadratic form 1/(a + bd +cd 2 ) to the diffuse and specular Terms The constant and linear terms soften the effect of the point source

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 Guoying Zhao 28 / 65

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 K -r, k -g, k -b : how much of each color component is absorbed Shininess coefficient a Guoying Zhao 29 / 65

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 ) a + k a I a For each color component we add contributions from all sources Guoying Zhao 30 / 65

Modified Phong Model I =k d I d l n + k s I s (v r ) a + k a I a 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 Halfway vector: the unit vector halfway between the view vector v and the lightsource vector l Guoying Zhao 31 / 65

The Halfway Vector h is normalized vector halfway between l and v h = ( l + v )/ l + v If the normal is in the direction of the halfway vector, then the maximum reflection from the surface is in the direction of the viewer. Guoying Zhao 32 / 65

Using the halfway angle Replace (v r ) a by (n h ) b b is chosen to match shineness Note that halway angle is half of angle between r and v if vectors are coplanar Resulting model is known as the modified Phong or Blinn-Phong model Specified in OpenGL standard Guoying Zhao 33 / 65

Example Only differences in these teapots are the parameters in the modified Phong model Guoying Zhao 34 / 65

Emissive Term We can simulate a light source in object with an emissive component This component is unaffected by any light sources or transformations Often used for effects where texture drives emission Guoying Zhao 35 / 65 Image by Witch Beam

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 n can be determined but how we determine n differs depending on underlying representation of surface OpenGL leaves determination of normal to application Guoying Zhao 36 / 65

Plane Normals Equation of plane: ax+by+cz+d = 0 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 ) Guoying Zhao 37 / 65

Normal to Sphere Implicit function f(x,y,z)=0 Normal given by gradient Sphere f(p)=p p-1 in the vector form The normal at every point on the surface of the sphere points directly out of the sphere, that is, in a direction from the origin through the point. n = [ f/ x, f/ y, f/ z] T =p Guoying Zhao 38 / 65

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 Guoying Zhao 39 / 65

General Case We can compute parametric normals for other simple cases Quadrics Parameteric polynomial surfaces Bezier surface patches Guoying Zhao 40 / 65

Shading in OpenGL Guoying Zhao 41 / 65

Objectives Introduce the OpenGL shading Discuss polygonal shading Flat Smooth Gouraud Implementing Blinn-Phong model using shaders Guoying Zhao 42 / 65

Steps in OpenGL shading 1. Enable vertex and fragment shaders 2. Specify normals 3. Specify material properties 4. Specify lights Guoying Zhao 43 / 65

Normals In OpenGL the normal vectors can be defined using Vertex Buffer Objects Defined as per vertex data like vertex positions, texture coordinates, vertex colors etc. Use GL_ARRAY_BUFFER Bind normal vectors to shader attribute locations. struct Vertex X Y Z Nx Ny Nz X Y Z... glbindbuffer(gl_array_buffer, vbo); glbufferdata(gl_array_buffer, model.size() * sizeof (struct Vertex), &model[0], GL_STATIC_DRAW); glvertexattribpointer(normalattriblocation, 3, GL_FLOAT, GL_FALSE, sizeof(struct Vertex), (const GLvoid*)offsetof(struct Vertex, normal)); glenablevertexattribarray(normalattriblocation); Guoying Zhao 44 / 65

Normals Usually we want to set the normal to have unit length so cosine calculations are correct Length can be affected by transformations Note that scaling does not preserve length We should normalize lengths in shaders to avoid problems with scaling Guoying Zhao 45 / 65

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

Defining a Point Light Source For each light source, we need to define diffuse, specular and ambient components, material shininess and light position. We can precalculate the product of light and material properties in our application I =k d I d l n + k s I s (v r ) a + k a I a GLfloat materialshininess = 100.0f; glm::vec4 lightposition(10.0f, 5.0f, 0.0f, 1.0f); glm::vec4 lightambient(0.2f, 0.2f, 0.2f, 1.0f); glm::vec4 materialambient(1.0f, 0.0f, 1.0f, 1.0f); glm::vec4 ambientproduct = glm::matrixcompmult(lightambient, materialambient); //.. and the same for diffuse and specular components Guoying Zhao 47 / 65

Defining a Point Light Source We then need to select what kind of attenuation we want to use for the light source. In this example, only constant term is used and we store all the parameters as a 3-component vector glm::vec3 lightattenuation(1.0f, 0.0f, 0.0f); Guoying Zhao 48 / 65

Moving Light Sources Light sources are geometric objects whose positions or directions can be manipulated with the model-view matrix Depending on where we place the position (direction), 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 Guoying Zhao 49 / 65

Different coordinate frames to use We can do shading calculations in different coordinate frames World coordinate frame May cause numerical precision problems with large scenes Object coordinate frame Requires object s model-matrix inverse to get light position View coordinate frame World coordinates centered at camera position Traditional model for OpenGL shading Verify that coordinate frames match Guoying Zhao 50 / 65

Front and Back Faces Usually we want to shade only front faces OpenGL face culling removes back-facing polygons It is also possible to disable culling and render and shade both sides of the face in different way back faces not visible back faces visible Guoying Zhao 51 / 65

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 regardless of A Later we will enable blending and use this feature Guoying Zhao 52 / 65

Polygon Normals Polygons have a single normal Shades at the vertices as computed by the Phong model can be almost same Identical for a distant viewer or if there is no specular component Consider model of sphere Want different normals at each vertex even though this concept is not quite correct mathematically Guoying Zhao 53 / 65

Smooth Shading We can set a new normal at each vertex Easy for sphere model If centered at origin n = p Now smooth shading works Note silhouette edge Guoying Zhao 54 / 65

Mesh Shading The previous example is not general because we knew the normal at each vertex analytically For polygonal models, Gouraud proposed we use the average of the normals around a mesh vertex n = (n 1 +n 2 +n 3 +n 4 )/ n 1 +n 2 +n 3 +n 4 Guoying Zhao 55 / 65

Gouraud Shading Gouraud and Phong Shading Find average normal at each vertex (vertex normals) Apply modified Phong model at each vertex Interpolate vertex shades across each polygon Phong shading Find vertex normals Interpolate vertex normals across edges Interpolate edge normals across polygon Apply modified Phong model at each fragment Guoying Zhao 56 / 65

Comparison If the polygon mesh approximates surfaces with a high curvatures, Phong shading may look smooth while Gouraud shading may show edges Phong shading requires much more work than Gouraud shading Until recently not available in real-time systems Now can be done using fragment shaders Both need data structures to represent meshes so we can obtain vertex normals Guoying Zhao 57 / 65

Gouraud shading Vertex Shader example (For OpenGL 3.2, no distance term for brevity) #version 150 // TODO: 1. Define inputs, outputs and uniform variables void main() { // TODO: 2. Transform input coordinates and vectors // TODO: 3. Compute terms in the illumination equation // TODO: 4. Store results in output variables } Guoying Zhao 58 / 65

Gouraud shading Vertex Shader example (For OpenGL 3.2, no distance term for brevity) // 1. Define inputs, outputs and uniform variables in vec4 vposition; in vec4 vnormal; // As a vector, must have vnormal.w == 0 out vec4 fcolor; // out vec4 gl_position; // predefined in OpenGL 3.2 uniform vec4 ambientproduct, diffuseproduct, specularproduct; uniform mat4 modelviewmatrix; uniform mat4 projectionmatrix; uniform vec4 lightposition; // in view space: viewmat * lpos; uniform float shininess; Guoying Zhao 59 / 65

Gouraud shading Vertex Shader example (For OpenGL 3.2, no distance term for brevity) // 1. Define inputs, outputs and uniform variables... void main() { // 2. Transform input coordinates and vectors vec3 pos = (modelviewmatrix * vposition).xyz; vec3 light = lightposition.xyz; // Light position already in view coordinate frame vec3 L = normalize(light - pos); // Light direction vec3 E = normalize(-pos); // Eye is at origin -> opposite direction of vertex position } vec3 H = normalize(l + E); // Halfway vector vec3 N = normalize((modelviewmatrix * vnormal).xyz); // TODO: 3. Compute terms in the illumination equation // TODO: 4. Store results in output variables Guoying Zhao 60 / 65

void main() {... Gouraud shading Vertex Shader example (For OpenGL 3.2, no distance term for brevity) // 3. Compute terms in the illumination equation vec4 ambient = ambientproduct; float Kd = max(dot(l, N), 0.0); vec4 diffuse = Kd * diffuseproduct; vec4 specular = vec4(0.0, 0.0, 0.0, 1.0); if (Kd > 0.0) { } float Ks = pow(max(dot(n, H), 0.0), shininess); specular = Ks * specularproduct; // TODO: 4. Store results in output variables... Guoying Zhao 61 / 65

... Gouraud shading Vertex Shader example (For OpenGL 3.2, no distance term for brevity) out vec4 fcolor; // out vec4 gl_position; // predefined in OpenGL 3.2... void main() { }... // 4. Store results in output variables // TODO: Scaling for diffuse and specular components fcolor = ambient + diffuse + specular; fcolor.a = 1.0; gl_position = projectionmatrix * modelviewmatrix * vposition; Guoying Zhao 62 / 65

#version 150 Gouraud shading Fragment Shader example (For OpenGL 3.2) in vec4 fcolor; // Interpolated between vertex values for each fragment out vec4 gl_fragcolor; void main(void) { gl_fragcolor = fcolor; } Guoying Zhao 63 / 65

Gouraud shading Fragment Shader example (For OpenGL 3.2) Guoying Zhao 64 / 65

Texture Mapping Next Lecture OpenGL Texture Mapping Compositing and Blending Guoying Zhao 65 / 65