Lights, Colour and Materials In OpenGL
|
|
- Emma Hunt
- 6 years ago
- Views:
Transcription
1 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 model determine the visual representation of that surface. Due to the relationship defined in the model between the surface of the objects and the lights affecting it, illumination models are also called shading models or lighting models. Light The Simplest Shading Model The physics of light is a complex subject. Shading models are approximations of these laws, in varying levels of realism/complexity. This is based on the fact that surfaces, for the most part, are approximations. Micro facet details defines the lighting characteristics of surface colour. CG Object representation (usually) does not transcend to that level. Radiosity algorithms now mimic photonic reactions with surfaces. The simplest shading model is a simple constant illumination. The model represents an unrealistic assumption in that the surface is self illuminating (the colour of this constant shading is defined by the user).
2 Illumination Equation We can now introduce the illumination equation, using the notion that Where I represents the illumination colour intensity and value represents the expression resulting in that colour value. Constant shading illumination equation can be defined as: Constant Illumination This simple equation has no reference to light sources, and as such every point on the object has the same intensity. This equation need only be calculated once per object. The process of evaluating the illumination equation at one or more points on an object s surface is referred to as lighting the object. where k represents the basic object intensity. Ambient Light Ambient light is usually a scene-based intensity of non directional light. It affects every object in that scene. We can then incorporate this into our illumination equation Diffuse Reflection Diffuse reflections consider point lights to generate shading properties a change in colour intensity across the surface of an object in relation to light sources. I = I a k a I a is the ambient light intensity the scene-based value that remains the same for all surfaces in the scene. K a is the ambient reflection coefficient a material based property that determines how much ambient light is actually reflected. Material based properties are the properties that characterise one surface from another. This equation allows individual surface properties to reflect a level of ambient light. The simplest of these models is the Lambert Illumination Model.
3 Lambert s Law Lambertian Reflection light is reflected with equal intensity in all directions (isotropic). The distribution is a basic consideration towards surface detail: Lambert s Law Lambert s law states that the intensity of illumination on a diffuse surface is proportional to the cosine of the angle generated between the surface normal vector and the surface to the light source vector. Light scattering on the surface and in the medium. The only data used in this equation is the surface normal and a light vector that uses the light source position(taken as a point light for simplicity). The intensity is irrespective of the actual viewpoint, hence the illumination is the same when viewed from any direction. Lambert s Model The equation for Lambert s illumination model is: I = I p k d cos(") Directional Light Where: I p is the intensity of the point light source k d is the material diffuse reflection coefficient the amount of diffuse light reflected. By using the dot product between 2 vectors v 1 and v 2 v 1 v 2 = v 1 v 2 cos(") I = I p k d (N L) and if N and L are normalised, we can re-write the illumination equation: So far, we have considered only point lights A light source at a near-infinite distance away from a surface has near-parallel rays. The vector made from the surface to the light source is always the same for every surface. This is known as a directional light light from a known direction- not position. We do not specify a position for directional lights, just a vector to indicate ray direction.
4 Application of Directional Lights Concatenation of Illuminations To implement a directional light into the illumination equation, Lambert s lighting model can be combined with the previous ambient light equation. we simply use the same light vector in every different surface illumination equation i.e. L does not change, as it is constant for the light source. I = I p k d (N L) Ambient Light I = I a k a Lambert s I = I p k d (N L) I = I a k a + I p k d (N L) Attenuation of Light Application of Attenuation To include attenuation into our illumination equation, we need to insert an attenuation factor into the lighting section in this case labelled f att. I = I a k a + f att I p k d (N L) The above is an example of lighting with no attenuation and below is an example with a more realistic attenuation of light. With this multiplying factor in place, we can control the intensity of light based on distance. An f att of 0 would effectively turn the light off. An f att of 1 would result in a maximum intensity of the light. Light falloff obeys what is commonly known as the inverse square law its intensity decreases exponentially in relation to distance. Real light has an attenuation factor light intensity becomes weaker over distance. In a similar manner, the perception of sound volume decreases the further away you are from its source. If we consider the distance from the surface point to the light L as d L f att = 1 d L 2
5 Light Colour Specular Reflection So far the notion of using the illumination equation has had no reference to actual colour only monochromatic intensity. What we require to do so, are 3 equations, to represent the Red, Green and Blue data. E.g. Shiny surfaces exhibit specular reflection the reflection of the light source towards the viewer. Specular reflection has 2 main colour biases: 1. The colour of the specular reflection is determined by the light source colour. or I R = I a R k ar + f att I pr k dr (N L) I G = I ag k ag + f att I pg k dg (N L) I B = I ab k ab + f att I pb k db (N L) 2. The colour of the specular reflection is determined by the colour of the surface. Objects that have waxed, or transparent surfaces (apples, plastic, etc.) tend to reflect the colour of the light source. Plastic, for example, is composed of colour pigments suspended in a transparent material. and Gold has a gold coloured highlight. Specular Realism Specular Realism II Most shiny surfaces are not perfect mirrors. Shiny surfaces will reflect the largest intensity where the viewing angle is directly opposite the reflection angle. They usually also reflect a diminishing gradient of highlight as well, enabling light to be seen from angles not directly opposed to the angle of reflection. The above diagram describes a perfectly mirrored surface. The viewer is seen looking at a point on the surface: viewing vector E. The light source L emanates a ray of light that that hits the surface with an angle of i relative to the normal. The angle of reflection of the light ray then leaves with an angle r relative to the normal. The angle of incidence i is the same as angle r. Phong Bui-Tuong developed an illumination model for non-perfect reflectors that has become widely used to portray realistic shiny surfaces. In a perfect mirror (above), the viewer may ONLY see the light ray if the viewing angle E is directly opposite of the reflection vector R. It is commonly known as the Phong illumination model. 20
6 Colour in OpenGL OpenGL specifies Colour using either a 3 or 4 tuple value. to represent r,g,b or r,g,b,a values or Colour Index mode which uses a user defined palette to set the current colour. As RGBA is the most common this will be discussed in most depth. to set the current colour the command glcolor[3/4] [b,s,i,f,d,ub,us,ui](v) is used Colour in OpenGL 1 // set colour using direct values 2 glcolor3f(1.0f,0.0f,0.0f); 3 4 // or using an array 5 GLfloat col[]={1.0,0.0,0.3,1.0}; 6 glcolor4fv(col); Colour state values The colour acts as a typical OpenGL state variable, so the colour value is retain until another call to glcolor. depending upon the Shade model used the colour for each vertex will be calculated per vertex based on the current colour state. If the GL_FLAT shade model is set each face in a model will have the same colour (i.e. the last colour called using glcolor3f) if GL_SMOOTH is used the colour will be interpolated for each set vertex colour across the face Colour state values The colour acts as a typical OpenGL state variable, so the colour value is retain until another call to glcolor. depending upon the Shade model used the colour for each vertex will be calculated per vertex based on the current colour state. If the GL_FLAT shade model is set each face in a model will have the same colour (i.e. the last colour called using glcolor3f) if GL_SMOOTH is used the colour will be interpolated for each set vertex colour across the face
7 gllightfv Lighting Parameters 1 void gllightfv( GLenum light, GLenum pname, const GLfloat * params); The light Parameter specifies the light Number GL_LIGHT0 - GL_LIGHT(GL_MAX_LIGHTS-1) (Usually 8 lights) pname specifies the lighting parameter to be changed these parameters are shown on the next slide params Specifies the value that parameter pname of light source light will be set to. Parameter GL_AMBIENT GL_DIFFUSE GL_SPECULAR GL_POSITION GL_SPOT_CUTOFF GL_SPOT_DIRECTION GL_SPOT_EXPONENT GL_CONSTANT_ATTENUATION GL_LINEAR_ATTENUATION GL_QUADRATIC_ATTENUATION Usage Sets RGBA Ambient Light Value Sets RGBA Diffuse Light Value Sets RGBA Specular Light Value Sets Light Position (x,y,z,w) Sets cutoff value for Spotlight Sets spotlight direction Sets the intensity distribution of the light Modifies Light Attenuation Modifies Light Attenuation Modifies Light Attenuation Using Light Sources in OpenGL OpenGL provides a number of functions for setting up lighting, and material properties for objects. A default OpenGL configuration allows for 8 light sources to be used in a scene. These are defined as GL_LIGHT0 - GL_LIGHT7. For example to create a light source located at (3,6,5) in world coordinates we use the following code. Light Position The array LighPos[] specifies the location of the light source and is passed to gllightfv() along with the name GL_LIGHT0 to attach is to the particular source. 1 // array for light position 2 GLfloat LightPos[]={3.0,6.0,5.0,1.0}; 3 4 // set the light pos 5 gllightfv(gl_light0,gl_position,lightpos); 6 7 // enable light 8 glenable(gl_lighting); 9 glenable(gl_light0);
8 Local or Remote Light Sources Some sources such as a desk lamp, are in the scene, whereas others, like the sun, are infinitely remote. OpenGL allows you to create both types by using homogeneous coordinates to specify the position of the source, thus we have (x,y,z,1) : a local light source at the position (x,y,z) and (x,y,z,0) : a vector to an infinitely remote light source in the direction (x,y,z) Local or Remote Light Sources Infinitely remote light sources are often called directional There are computational advantages to using directional light sources since the direction S in the calculations of the diffuse and specular reflections is constant for all vertices in the scene. Some times light must be placed local to an object in a scene and thus the directional light is not appropriate. However this will increase the computation time Setting Light Colour values A light is said to emit ambient, diffuse and specular colour. The ambient colour is attached to the light and is still treated as a non-directional light that bathes the entree scene. However this light may be turned on and off with the light in question. OpenGL also has a true ambient light which is associated with the whole scene. 1 // create ambient light values 2 GLfloat amb[]={0.2,0.4,0.6,1.0}; 3 // diffuse 4 GLfloat diff[]={0.8,0.9,0.5,1.0}; 5 // specular 6 GLfloat spec[]={1.0,0.8,1.0,1.0}; 7 // now set the values 8 gllightfv(gl_light0,gl_ambient,amb); 9 gllightfv(gl_light0,gl_diffuse,diff); 10 gllightfv(gl_light0,gl_specular,spec);
9 Light Colour Colours are specified in RGBA format using Red, Green, Blue and Alpha. The alpha colour is used for blending two colours. The default OpenGL values for a light are as follows and give a good general light for a scene. For all sources :- default ambient =(0,0,0,1); - dimmest possible = black For GL_LIGHT0 default diffuse = (1,1,1,1) - brightest possible = white. default specular = (1,1,1,1) - brightest possible = white. For all other Lights the diffuse and specular default to black Spotlights Light sources are point sources by default; that is they emit light uniformly in all directions. A spotlight is a restricted version of a normal light so that the light travels in only a certain direction. The light in the above figure shows a light aimed in the direction d with a cutoff angle of α No light is seen at points lying outside of the cutoff cone. For vertices such a P which lie inside the cone the amount of light reaching the P is attenuated by the factor cos ε (β) where β is the angle between d ε and a line from the source to P and is an exponent chosen by the user to give the desired fall-off of light with angle Spotlight Code The following code shows how to make a light into a spot light 1 // set the light direction 2 GLfloat dir[]={2.0,1.0,-4.0}; gllightf(gl_light0,gl_spot_cutoff,45.0); 6 7 gllightf(gl_light0,gl_spot_exponent,4.0); 8 9 gllightfv(gl_light0,gl_spot_direction,dir); The default values for these parameters are d=(0,0,-1), α=180 ε =0 which makes the light an omnidirectional point source. Attenuation of light with distance OpenGL allows the specification of how rapidly light diminishes with distance from a source. Most of the light models seen so far do not rely on this factor however it can add interesting effects to a scene. OpenGL attenuates the strength of a positional light source using the attenuation factor
10 Attenuation of light with distance atten = 1 k c + k l D + k q D 2 where kc,kl and kq are coefficients and D is the distance between the position of the light and the vertex in question. These can be set by the function call 1 // set Kc 2 gllightf(gl_light0,gl_constant_attenuation,2.0); 3 // set Kl 4 gllightf(gl_light0,gl_linear_attenuation,2.0); 5 // set Kq 6 gllightf(gl_light0,gl_quadratic_attenuation,2.0); Adding Global Ambient Light In any given scene a global ambient light may be added which is independent of any other light source. This is done using the following code 1 GLfloat amb[]={0.2,0.3,0.1,1.0}; 2 3 gllightmodelfv(gl_light_model_ambient,amb); The default value is (0.2,0.2,0.2,1.0) so the ambient light is always present, unless it is purposely altered. Making the ambient light source value non-zero makes any object in a scene visible even if no other lights are turned on. Local or Remote Viewpoint? OpenGL computes specular reflections using the halfway vector h=s+v The true directions s and v are normally different at each vertex in a mesh. If the light source is directional, then s is constant, but v still varies from vertex to vertex. The rendering speed is increased if v is kept constant from all vertices. As a default OpenGL uses v=(0,0,1) which points down the positive z axis. You can force OpenGL to compute v for each vertex by using the following gllightmodeli(gl_light_model_local_viewer,gl_true); By default this is set to GL_FALSE Front and Back Faces Each polygonal face in a model had two sides. When modelling we tend to think of these sides as inside and outside surfaces. The convention is to list the vertices of a face in counterclockwise (CCW) order as seen from the outside of the object OpenGL has no notion of inside or outside; it can only distinguish between front faces and back faces A face is a front face is its vertices are listed in CCW order as seen by the eye.
11 Front and Back Faces For an object that encloses some space, all faces that are visible to the eye are front faces. If one face is removed so we can see inside the object the inside faces are deemed to be back faces and are thus not shaded but left dark. If we wish for these to be shaded properly we need to reverse the normals for each of the faces inside. To do this we use the following code gllightmodeli(gl_light_model_two_side,gl_true) By default this value is set to GL_FALSE Note that faces drawn by OpenGL do not cast shadows, so all of the back faces receive the same light from the source, even thought there may be some other face between them and the light source. Moving a Light Source. Light sources pass through the model view matrix just as vertices do. Therefore light sources can be re-positioned by suitable uses of glrotated and gltranslated. The array pos[] specified by using gllightfv(gl_light0,gl_position,pos); is modified by the model view matrix that is in effect at the time gllightfv is called So to modify the position of the light with transformations and independently move the camera we embed the light positioning command in a push-pop pair as in the following code Moving a Light Source. 1 void Display() 2 { 3 GLfloat pos[]={2,1,3,1}; 4 5 glmatrixmode(gl_modelview); 6 glloadidentity(); 7 glpushmatrix(); 8 glrotated(...); //move light 9 gltranslated(...); // 10 gllightfv(gl_ligt0,gl_position,pos); 11 glpopmatrix(); glulookat(..); //set the camera // draw obj glutswapbuffers(); 19 } Moving a light To have a light move with a camera we use the following code. 1 GLfloat pos[]={0,0,0,1}; 2 3 glmatrixmode(gl_modelview); 4 5 glloadidentity(); 6 7 gllightfv(gl_light0,gl_position,pos); 8 9 glulookat(...); //move the light and the camera
12 Material Properties and OpenGL You can only see the effect of a light source when light reflects off an object's surface. OpenGL allows the programmer to set the reflection coefficients that appear in the lighting equations (effectively the material properties) These coefficients are set with variations of the function glmaterial, and they can be specified individually for front and back faces. face glmaterialfv 1 void glmaterialfv( GLenum face, GLenum pname, GLfloat param ); glmaterialfv allows us to set the material parameters The first parameter of glmaterialfv() can take the following values GL_FRONT GL_BACK GL_FRONT_AND_BACK Usage Set the reflection coefficient for the front faces Set the reflection coefficient for the back faces Set the reflection coefficient for both the front and back faces Param GL_AMBIENT GL_DIFFUSE GL_SPECULAR GL_AMBIENT_AND_DIFFUSE GL_EMISSIVE glmaterialfv Usage Set the ambient reflection coefficients Set the diffuse reflection coefficients Set the specular reflection coefficients Set the ambient and diffuse reflection coefficients Set the emissive reflection coefficients, this causes the face to have a glow in a particular colour without a light being turned on. OpenGL Lighting Model Equation I r = e r + I mr ρ ar + i atten i spot i (I i arρ ar + I i drρ dr lambert i + I i sprρ sr phong f i ) Expressions for the Green and blue are similar. The emissive light is er and Imr is the global ambient light. The summation indicates that the contribution of all the sources (i indicating the index) is added to the final value.
13 Flat and Smooth Shading In the modelling process, we attach a normal vector to each vertex of each face. If a certain face is to appear as a distinct polygon we attach the same normal vector to all of its vertices; The normal vector chosen is that indicating the direction normal to the plane of the face If the face is supposed to approximate an underlying surface, we attach to each vertex the normal to the underlying surface at that point. The main distinction between shading models is how they paint the individual polygons. Flat shading gives all polygons the same colour, where as smooth shading tries to de-emphasize the edges between the polygons Flat Shading When a face is flat and the light sources are quite distant, the diffuse light component varies little over different points on the roof. In such cases, it is reasonable to use the same colour for every pixel covered by the face. OpenGL provides a rendering mode that does this with the following command glshademodel(gl_flat); Smooth Shading Smooth shading attempts to de-emphasize edges between faces by computing colours at more points on each face OpenGL only does Gouraud shading as part of the fixed functionality pipeline. OpenGL >2.0 supports Vertex/Fragment Shaders which will be able to apply user defined shading to each vertex Gouraud Shading Computationally Gouraud shading is slightly more expensive than than flat shading. To enable Gouraud shading in OpenGL we use glshademodel(gl_smooth); The above figure shows that the buckyball remains the same as in flat shading mode, however the sphere now looks smooth. There are no abrupt jumps in colour between neighboring faces, and the edges of the faces (and the Mach bands) are gone. However along the silhouette, we can still see the bounding edges of the individual faces.
14 Transparency OpenGL uses blending to create the effect of transparency. With blending enabled the alpha value is used to combine the colour value of the current fragment being processed with the pixel value stored in the framebuffer. During blending the colour values of the incoming fragment (source) are combined with the values of the corresponding currently stored pixels (destination) The way the blending occurs is based on the glbendfunc set by the programmer. it must be enabled using glenable(gl_blend); glblendfunc( GLenum sfactor, GLenum dfactor); the sfactor and dfactor specifies how the blending functions are calculated as shown in the following table Constant factor Computed blend Factor GL ZERO src / dest (0,0,0,0) GL ONE src / dest (1,1,1,1) GL DST COLOR src (R d,g d,b d,a d ) GL SRC COLOR dest (Rs,Gs,Bs,As) GL ONE MINUS DST COLOR src (1, 1, 1, 1) (R d,g d,b d,a d ) GL ONE MINUS SRC COLOR dest (1, 1, 1, 1) (Rs,Gs,Bs,As) GL SRC ALPHA src / dest (As,As,As,As) GL ONE MINUS SRC ALPHA src / dest (1, 1, 1, 1) (As,As,As,As) GL DST ALPHA src / dest (A d,a d,a d,a d ) GL ONE MINUS DEST ALPHA src / dest (1, 1, 1, 1) (A d,a d,a d,a d ) GL SRC ALPHA SATURATE src (f,f,f,f); f=min(as, 1 A d ) GL CONSTANT COLOR src / dest (Rc,Gc,Bc,Ac) GL ONE MINUS CONSTANT COLOR src / dest (1,1,1,1)-(Rc,Gc,Bc,Ac) GL CONSTANT ALPHA src / dest (Ac,Ac,Ac,Ac) GL ONE MINUS CONSTANT ALPHA src / dest (1,1,1,1)-(Ac,Ac,Ac,Ac) Fog As images can seem too sharp and well defined especially with distant object OpenGL allows the user to make distant images fade into a background colour by using fog. To enable Fog glenable(gl_fog); is used Fog then blends a fog colour with an incoming fragment's colour by using one of three equations f = e (density z) (GL EXP) f = e (density z)2 (GL EXP2) Fog 2 1 GLfloat fogcolour[4]={0.5,0.5,0.5,1.0}; 2 3 glfogi(gl_fog_mode,gl_exp); 4 5 glfogfv(gl_fog_color,fogcolour); 6 7 glfogf(gl_fog_density,0.35); 8 9 glhint(gl_fog_hint,gl_dont_care); glfogf(gl_fog_start,1.0); glfogf(gl_fog_end,5.0); f = end z end start (GL LINEAR)
15 References Computer Graphics With OpenGL, F.S. Hill jr, Prentice Hall Shreiner Et Al OpenGL Programming Guide: The Official Guide to Learning OpenGL Foley & van Dam Computer Graphics: Principles and Practice in C (2nd Edition) (Redbook online) theredbook/
Overview. Shading. Shading. Why we need shading. Shading Light-material interactions Phong model Shading polygons Shading in OpenGL
Overview Shading Shading Light-material interactions Phong model Shading polygons Shading in OpenGL Why we need shading Suppose we build a model of a sphere using many polygons and color it with glcolor.
More informationThree-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
More informationWhy we need shading?
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
More informationComputer 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
More informationGraphics and Visualization
International University Bremen Spring Semester 2006 Recap Hierarchical Modeling Perspective vs Parallel Projection Representing solid objects Displaying Wireframe models is easy from a computational
More informationINF3320 Computer Graphics and Discrete Geometry
INF3320 Computer Graphics and Discrete Geometry Visual appearance Christopher Dyken and Martin Reimers 23.09.2009 Page 1 Visual appearance Real Time Rendering: Chapter 5 Light Sources and materials Shading
More informationCEng 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
More informationToday s class. Simple shadows Shading Lighting in OpenGL. Informationsteknologi. Wednesday, November 21, 2007 Computer Graphics - Class 10 1
Today s class Simple shadows Shading Lighting in OpenGL Wednesday, November 21, 27 Computer Graphics - Class 1 1 Simple shadows Simple shadows can be gotten by using projection matrices Consider a light
More informationAmbient 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
More informationCS Computer Graphics: Illumination and Shading I
CS 543 - Computer Graphics: Illumination and Shading I by Robert W. Lindeman gogo@wpi.edu (with help from Emmanuel Agu ;-) Illumination and Shading Problem: Model light/surface point interactions to determine
More informationCS Computer Graphics: Illumination and Shading I
CS 543 - Computer Graphics: Illumination and Shading I by Robert W. Lindeman gogo@wpi.edu (with help from Emmanuel Agu ;-) Illumination and Shading Problem: Model light/surface point interactions to determine
More informationShading and Illumination
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ω
More informationToday. Global illumination. Shading. Interactive applications. Rendering pipeline. Computergrafik. Shading Introduction Local shading models
Computergrafik Thomas Buchberger, Matthias Zwicker Universität Bern Herbst 2008 Today Introduction Local shading models Light sources strategies Compute interaction of light with surfaces Requires simulation
More informationLighting. CSC 7443: Scientific Information Visualization
Lighting Why Lighting? What light source is used and how the object response to the light makes difference Ocean looks bright bluish green in sunny day but dim gray green in cloudy day Lighting gives you
More informationReading. Shading. Introduction. An abundance of photons. Required: Angel , Optional: OpenGL red book, chapter 5.
Reading Required: Angel 6.1-6.5, 6.7-6.8 Optional: Shading OpenGL red book, chapter 5. 1 2 Introduction So far, we ve talked exclusively about geometry. What is the shape of an obect? How do I place it
More informationVirtual Reality for Human Computer Interaction
Virtual Reality for Human Computer Interaction Appearance: Lighting Representation of Light and Color Representation of Light and Color Do we need to represent all I! to represent a color C(I)? Representation
More informationObjectives. Introduce Phong model Introduce modified Phong model Consider computation of required vectors Discuss polygonal shading.
Shading II 1 Objectives Introduce Phong model Introduce modified Phong model Consider computation of required vectors Discuss polygonal shading Flat Smooth Gouraud 2 Phong Lighting Model A simple model
More informationCSE 167: Introduction to Computer Graphics Lecture #6: Lights. Jürgen P. Schulze, Ph.D. University of California, San Diego Fall Quarter 2016
CSE 167: Introduction to Computer Graphics Lecture #6: Lights Jürgen P. Schulze, Ph.D. University of California, San Diego Fall Quarter 2016 Announcements Thursday in class: midterm #1 Closed book Material
More informationIllumination and Shading ECE 567
Illumination and Shading ECE 567 Overview Lighting Models Ambient light Diffuse light Specular light Shading Models Flat shading Gouraud shading Phong shading OpenGL 2 Introduction To add realism to drawings
More informationCS Surface Rendering
CS10101001 Surface Rendering Junqiao Zhao 赵君峤 Department of Computer Science and Technology College of Electronics and Information Engineering Tongji University Surface rendering How do we choose a color
More informationReading. Shading. An abundance of photons. Introduction. Required: Angel , 6.5, Optional: Angel 6.4 OpenGL red book, chapter 5.
Reading Required: Angel 6.1-6.3, 6.5, 6.7-6.8 Optional: Shading Angel 6.4 OpenGL red book, chapter 5. 1 2 Introduction An abundance of photons So far, we ve talked exclusively about geometry. Properly
More informationLight 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
More informationComp 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
More informationComputer Graphics Lighting
Lighting 1 Mike Bailey mjb@cs.oregonstate.edu This work is licensed under a Creative Commons Attribution-NonCommercial- NoDerivatives 4.0 International License Lighting.pptx Why Do We Care About Lighting?
More informationComputer Graphics Lighting. Why Do We Care About Lighting?
Lighting 1 Mike Bailey mjb@cs.oregonstate.edu This work is licensed under a Creative Commons Attribution-NonCommercial- NoDerivatives 4.0 International License Lighting.pptx Why Do We Care About Lighting?
More informationLecture 15: Shading-I. CITS3003 Graphics & Animation
Lecture 15: Shading-I CITS3003 Graphics & Animation E. Angel and D. Shreiner: Interactive Computer Graphics 6E Addison-Wesley 2012 Objectives Learn that with appropriate shading so objects appear as threedimensional
More informationComputer 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
More informationChapter 10. Surface-Rendering Methods. Somsak Walairacht, Computer Engineering, KMITL
Computer Graphics Chapter 10 llumination Models and Surface-Rendering Methods Somsak Walairacht, Computer Engineering, KMTL 1 Outline Light Sources Surface Lighting Effects Basic llumination Models Polygon
More informationIllumination & Shading
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
More informationLecture 17: Shading in OpenGL. CITS3003 Graphics & Animation
Lecture 17: Shading in OpenGL CITS3003 Graphics & Animation E. Angel and D. Shreiner: Interactive Computer Graphics 6E Addison-Wesley 2012 Objectives Introduce the OpenGL shading methods - per vertex shading
More informationToday. Global illumination. Shading. Interactive applications. Rendering pipeline. Computergrafik. Shading Introduction Local shading models
Computergrafik Matthias Zwicker Universität Bern Herbst 2009 Today Introduction Local shading models Light sources strategies Compute interaction of light with surfaces Requires simulation of physics Global
More informationIllumination and Shading
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
More informationWHY WE NEED SHADING. Suppose we build a model of a sphere using many polygons and color it with glcolor. We get something like.
LIGHTING 1 OUTLINE Learn to light/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
More informationComputer Graphics. Illumination Models and Surface-Rendering Methods. Somsak Walairacht, Computer Engineering, KMITL
Computer Graphics Chapter 10 llumination Models and Surface-Rendering Methods Somsak Walairacht, Computer Engineering, KMTL Outline Light Sources Surface Lighting Effects Basic llumination Models Polygon
More informationIllumination Model. The governing principles for computing the. Apply the lighting model at a set of points across the entire surface.
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
More informationComputer Graphics (CS 4731) Lecture 16: Lighting, Shading and Materials (Part 1)
Computer Graphics (CS 4731) Lecture 16: Lighting, Shading and Materials (Part 1) Prof Emmanuel Agu Computer Science Dept. Worcester Polytechnic Institute (WPI) Why do we need Lighting & shading? Sphere
More informationReflection and Shading
Reflection and Shading R. J. Renka Department of Computer Science & Engineering University of North Texas 10/19/2015 Light Sources Realistic rendering requires that we model the interaction between light
More informationCS 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
More informationVirtual Reality for Human Computer Interaction
Virtual Reality for Human Computer Interaction Appearance: Lighting Representation of Light and Color Do we need to represent all I! to represent a color C(I)? No we can approximate using a three-color
More informationLecture 4 Advanced Computer Graphics (CS & SE )
Lecture 4 Advanced Computer Graphics (CS & SE 233.420) Topics Covered Animation Matrices Viewing Lighting Animating Interactive Programs Consider planet.c Want to animate rotating the Earth around the
More informationShading. Why we need shading. Scattering. Shading. Objectives
Shading Why we need shading Objectives Learn to shade objects so their images appear three-dimensional Suppose we build a model of a sphere using many polygons and color it with glcolor. We get something
More informationIllumination & Shading I
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
More informationComputer Graphics (CS 543) Lecture 7b: Intro to lighting, Shading and Materials + Phong Lighting Model
Computer Graphics (CS 543) Lecture 7b: Intro to lighting, Shading and Materials + Phong Lighting Model Prof Emmanuel Agu Computer Science Dept. Worcester Polytechnic Institute (WPI) Why do we need Lighting
More informationObjectives Shading in OpenGL. Front and Back Faces. OpenGL shading. Introduce the OpenGL shading methods. Discuss polygonal shading
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
More informationCS 4600 Fall Utah School of Computing
Lighting CS 4600 Fall 2015 Utah School of Computing Objectives Learn to shade objects so their images appear three-dimensional Introduce the types of light-material interactions Build a simple reflection
More informationCSCI 4620/8626. Computer Graphics Illumination Models and Surface Rendering Methods (Chapter 17)
CSCI 4620/8626 Computer Graphics Illumination Models and Surface Rendering Methods (Chapter 17) Last update: 2016-04-19 Realism! Realistic displays of a scene use! Perspective projections of objects! Application
More informationCPSC 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
More informationShading I Computer Graphics I, Fall 2008
Shading I 1 Objectives Learn to shade objects ==> images appear threedimensional Introduce types of light-material interactions Build simple reflection model Phong model Can be used with real time graphics
More informationLight Transport Baoquan Chen 2017
Light Transport 1 Physics of Light and Color It s all electromagnetic (EM) radiation Different colors correspond to radiation of different wavelengths Intensity of each wavelength specified by amplitude
More informationIntroduction to Computer Graphics 7. Shading
Introduction to Computer Graphics 7. Shading National Chiao Tung Univ, Taiwan By: I-Chen Lin, Assistant Professor Textbook: Hearn and Baker, Computer Graphics, 3rd Ed., Prentice Hall Ref: E.Angel, Interactive
More informationMethodology 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
More informationLessons Learned from HW4. Shading. Objectives. Why we need shading. Shading. Scattering
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
More informationIllumination & Shading: Part 1
Illumination & Shading: Part 1 Light Sources Empirical Illumination Shading Local vs Global Illumination Lecture 10 Comp 236 Spring 2005 Computer Graphics Jargon: Illumination Models Illumination - the
More informationLIGHTING AND SHADING
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
More informationCSE 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:
More informationShading. Brian Curless CSE 457 Spring 2015
Shading Brian Curless CSE 457 Spring 2015 1 Reading Required: Angel chapter 5. Optional: OpenGL red book, chapter 5. 2 Basic 3D graphics With affine matrices, we can now transform virtual 3D objects in
More informationDisplay Issues Week 5
CS 432/637 INTERACTIVE COMPUTER GRAPHICS Display Issues Week 5 David Breen Department of Computer Science Drexel University Based on material from Ed Angel, University of New Mexico Objectives Consider
More informationTopic 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
More informationShading. CSE 457 Winter 2015
Shading CSE 457 Winter 2015 Reading Required: Angel chapter 5. Optional: OpenGL red book, chapter 5. 2 Basic 3D graphics With affine matrices, we can now transform virtual 3D objects in their local coordinate
More informationCSE 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,
More informationLighting/Shading III. Week 7, Wed Mar 3
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2010 Tamara Munzner Lighting/Shading III Week 7, Wed Mar 3 http://www.ugrad.cs.ubc.ca/~cs314/vjan2010 reminders News don't need to tell
More informationTopic 9: Lighting & Reflection models. Lighting & reflection The Phong reflection model diffuse component ambient component specular component
Topic 9: Lighting & Reflection models Lighting & reflection The Phong reflection model diffuse component ambient component specular component Spot the differences Terminology Illumination The transport
More informationToday we will start to look at illumination models in computer graphics
1 llumination Today we will start to look at illumination models in computer graphics Why do we need illumination models? Different kinds lights Different kinds reflections Basic lighting model 2 Why Lighting?
More informationShading , 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
More informationGraphics for VEs. Ruth Aylett
Graphics for VEs Ruth Aylett Overview VE Software Graphics for VEs The graphics pipeline Projections Lighting Shading VR software Two main types of software used: off-line authoring or modelling packages
More informationAPI for creating a display window and using keyboard/mouse interations. See RayWindow.cpp to see how these are used for Assignment3
OpenGL Introduction Introduction OpenGL OpenGL is an API for computer graphics. Hardware-independent Windowing or getting input is not included in the API Low-level Only knows about triangles (kind of,
More informationGraphics for VEs. Ruth Aylett
Graphics for VEs Ruth Aylett Overview VE Software Graphics for VEs The graphics pipeline Projections Lighting Shading Runtime VR systems Two major parts: initialisation and update loop. Initialisation
More informationLigh%ng and Shading. Ligh%ng and Shading. q Is this a plate or a ball? q What color should I set for each pixel?
Ligh%ng and Shading Ligh%ng and Shading Is this a plate or a ball? What color should I set for each pixel? 1 Physical Reality As light hits the surface: Part is absorbed Part is reflected Visible light
More informationC 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
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
More informationCS130 : Computer Graphics Lecture 8: Lighting and Shading. Tamar Shinar Computer Science & Engineering UC Riverside
CS130 : Computer Graphics Lecture 8: Lighting and Shading Tamar Shinar Computer Science & Engineering UC Riverside Why we need shading Suppose we build a model of a sphere using many polygons and color
More informationSurface Rendering Methods
Surface Rendering Methods 6 th Week, 2008 Sun-Jeong Kim Polygon Rendering Methods Determining the surface intensity at every projected pixel position using an illumination model Light-material interactions
More informationIntroduction 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
More informationLighting and Shading II. Angel and Shreiner: Interactive Computer Graphics 7E Addison-Wesley 2015
Lighting and Shading II 1 Objectives Continue discussion of shading Introduce modified Phong model Consider computation of required vectors 2 Ambient Light Ambient light is the result of multiple interactions
More informationECS 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
More informationLocal Illumination. CMPT 361 Introduction to Computer Graphics Torsten Möller. Machiraju/Zhang/Möller
Local Illumination CMPT 361 Introduction to Computer Graphics Torsten Möller Graphics Pipeline Hardware Modelling Transform Visibility Illumination + Shading Perception, Interaction Color Texture/ Realism
More informationShading. Slides by Ulf Assarsson and Tomas Akenine-Möller Department of Computer Engineering Chalmers University of Technology
Shading Slides by Ulf Assarsson and Tomas Akenine-Möller Department of Computer Engineering Chalmers University of Technology Overview of today s lecture l A simple most basic real-time lighting model
More informationCS5620 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
More informationIllumination Models & Shading
Illumination Models & Shading Lighting vs. Shading Lighting Interaction between materials and light sources Physics Shading Determining the color of a pixel Computer Graphics ZBuffer(Scene) PutColor(x,y,Col(P));
More informationIllumination and Shading
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
More informationLighting 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
More informationShading. Brian Curless CSE 557 Autumn 2017
Shading Brian Curless CSE 557 Autumn 2017 1 Reading Optional: Angel and Shreiner: chapter 5. Marschner and Shirley: chapter 10, chapter 17. Further reading: OpenGL red book, chapter 5. 2 Basic 3D graphics
More informationShading Intro. Shading & Lighting. Light and Matter. Light and Matter
Shading Intro Shading & Lighting Move from flat to 3-D models Orthographic view of sphere was uniformly color, thus, a flat circle A circular shape with many gradations or shades of color Courtesy of Vincent
More informationObjectives. 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
More informationCMSC427 Shading Intro. Credit: slides from Dr. Zwicker
CMSC427 Shading Intro Credit: slides from Dr. Zwicker 2 Today Shading Introduction Radiometry & BRDFs Local shading models Light sources Shading strategies Shading Compute interaction of light with surfaces
More informationIllumination in Computer Graphics
Illumination in Computer Graphics Ann McNamara Illumination in Computer Graphics Definition of light sources. Analysis of interaction between light and objects in a scene. Rendering images that are faithful
More informationVisualisatie BMT. Rendering. Arjan Kok
Visualisatie BMT Rendering Arjan Kok a.j.f.kok@tue.nl 1 Lecture overview Color Rendering Illumination 2 Visualization pipeline Raw Data Data Enrichment/Enhancement Derived Data Visualization Mapping Abstract
More informationCS 325 Computer Graphics
CS 325 Computer Graphics 04 / 02 / 2012 Instructor: Michael Eckmann Today s Topics Questions? Comments? Illumination modelling Ambient, Diffuse, Specular Reflection Surface Rendering / Shading models Flat
More informationw Foley, Section16.1 Reading
Shading w Foley, Section16.1 Reading Introduction So far, we ve talked exclusively about geometry. w What is the shape of an object? w How do I place it in a virtual 3D space? w How do I know which pixels
More information蔡侑庭 (Yu-Ting Tsai) National Chiao Tung University, Taiwan. Prof. Wen-Chieh Lin s CG Slides OpenGL 2.1 Specification
蔡侑庭 (Yu-Ting Tsai) Department of Computer Science National Chiao Tung University, Taiwan Prof. Wen-Chieh Lin s CG Slides OpenGL 2.1 Specification OpenGL Programming Guide, Chap. 5 2 http://caig.cs.nctu.edu.tw/course/cg2007/files
More informationLets 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
More informationSimple Lighting/Illumination Models
Simple Lighting/Illumination Models Scene rendered using direct lighting only Photograph Scene rendered using a physically-based global illumination model with manual tuning of colors (Frederic Drago and
More informationCOMP3421. Hidden surface removal Illumination
COMP3421 Hidden surface removal Illumination Revision Write a snippet of jogl code to draw a triangle with vertices: (2,1,-4) (0,-1,-3) (-2,1,-4) Assume back face culling is on. Make sure you specify normals
More informationCS452/552; EE465/505. Lighting & Shading
CS452/552; EE465/505 Lighting & Shading 2-17 15 Outline! More on Lighting and Shading Read: Angel Chapter 6 Lab2: due tonight use ASDW to move a 2D shape around; 1 to center Local Illumination! Approximate
More informationCS452/552; EE465/505. Intro to Lighting
CS452/552; EE465/505 Intro to Lighting 2-10 15 Outline! Projection Normalization! Introduction to Lighting (and Shading) Read: Angel Chapter 5., sections 5.4-5.7 Parallel Projections Chapter 6, sections
More informationIllumination Models. To calculate the color of an illuminated position on the
llumination Models 5 th Week, 2008 Sun-Jeong Kim Realistic Scene in CG Perspective projection of objects + natural lighting effects to the visible surface Light reflections, transparency, surface texture,
More informationCSE 167: Introduction to Computer Graphics Lecture #6: Colors. Jürgen P. Schulze, Ph.D. University of California, San Diego Fall Quarter 2013
CSE 167: Introduction to Computer Graphics Lecture #6: Colors Jürgen P. Schulze, Ph.D. University of California, San Diego Fall Quarter 2013 Announcements Homework project #3 due this Friday, October 18
More informationLocal Illumination physics. Law of reflection and Snell s law of refraction
Local Illumination physics Law of reflection and Snell s law of refraction What are we trying to model? Surface Proof of Lambert s cosine law n db da Computing R All vectors unit length!! The effect
More informationObjectives. 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
More informationLighting 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
More informationLighting. Figure 10.1
We have learned to build three-dimensional graphical models and to display them. However, if you render one of our models, you might be disappointed to see images that look flat and thus fail to show the
More information