CSCI 4620/8626. Computer Graphics Illumination Models and Surface Rendering Methods (Chapter 17)

Similar documents
Lighting Models. CS116B Chris Pollett Mar 21, 2004.

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

CEng 477 Introduction to Computer Graphics Fall

INF3320 Computer Graphics and Discrete Geometry

CS Computer Graphics: Illumination and Shading I

CS Computer Graphics: Illumination and Shading I

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

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

Computer Graphics. Illumination and Shading

Illumination Model. The governing principles for computing the. Apply the lighting model at a set of points across the entire surface.

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

Surface Rendering Methods

Illumination and Shading

Lecture 15: Shading-I. CITS3003 Graphics & Animation

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

CS 325 Computer Graphics

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

Three-Dimensional Graphics V. Guoying Zhao 1 / 55

CS5620 Intro to Computer Graphics

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

Reflection and Shading

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

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

Illumination and Shading

Comp 410/510 Computer Graphics. Spring Shading

Lighting. Figure 10.1

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

Color and Light CSCI 4229/5229 Computer Graphics Fall 2016

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

Shading I Computer Graphics I, Fall 2008

Why we need shading?

Light Transport Baoquan Chen 2017

Virtual Reality for Human Computer Interaction

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

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

Illumination Models & Shading

Illumination & Shading I

Illumination & Shading: Part 1

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

Shading and Illumination

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

CPSC 314 LIGHTING AND SHADING

CENG 477 Introduction to Computer Graphics. Ray Tracing: Shading

From Graphics to Visualization

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

Visualisatie BMT. Rendering. Arjan Kok

Illumination Models and Surface-Rendering Methods. Chapter 10

Lighting and Shading

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

CS770/870 Spring 2017 Color and Shading

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

Illumination and Shading ECE 567

CS3500 Computer Graphics Module: Lighting and Shading

Illumination & Shading

蔡侑庭 (Yu-Ting Tsai) National Chiao Tung University, Taiwan. Prof. Wen-Chieh Lin s CG Slides OpenGL 2.1 Specification

Introduction to Computer Graphics 7. Shading

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

Lighting. CSC 7443: Scientific Information Visualization

Virtual Reality for Human Computer Interaction

Computer Graphics Lighting

Computer Graphics Lighting. Why Do We Care About Lighting?

CMSC427 Shading Intro. Credit: slides from Dr. Zwicker

Lights, Colour and Materials In OpenGL

Computer Graphics. Illumination and Shading

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

Shading. Brian Curless CSE 557 Autumn 2017

ECS 175 COMPUTER GRAPHICS. Ken Joy.! Winter 2014

Graphics Hardware and Display Devices

Graphics for VEs. Ruth Aylett

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

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

Simple Lighting/Illumination Models

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

Graphics and Visualization

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

9. Illumination and Shading

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

Given: scene specification (object positions, optical properties p of the surface, viewer position, viewing direction, )

Lecture 17: Shading in OpenGL. CITS3003 Graphics & Animation

Illumination and Shading

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

CS 4600 Fall Utah School of Computing

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

Complex Shading Algorithms

Homework #2. Shading, Ray Tracing, and Texture Mapping

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

Introduction to Visualization and Computer Graphics

LIGHTING AND SHADING

Sung-Eui Yoon ( 윤성의 )

Introduction Rasterization Z-buffering Shading. Graphics 2012/2013, 4th quarter. Lecture 09: graphics pipeline (rasterization and shading)

w Foley, Section16.1 Reading

CPSC / Illumination and Shading

CS Surface Rendering

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

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

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

Graphics for VEs. Ruth Aylett

Lecture 17: Recursive Ray Tracing. Where is the way where light dwelleth? Job 38:19

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

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

Transcription:

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 of natural lighting effects to visible surfaces! An illumination model (or lighting model, or shading model) is used to calculate the color of an illuminated position on the surface of an object.! A surface-rendering method uses these color calculations to determine pixel colors for all projected positions in a scene.! Photorealism requires two elements:! Accurate representation of surface properties! Good physical description of a scene s lighting effects (e.g. reflections, transparency, surface texture, and shadows) 2 1

Modeling Lighting Effects! In general, modeling lighting effects is complex, and involves physics and psychology.! Physical models involve! Material properties (opaque/transparent, shiny/dull, texture, etc.)! Object position relative to light sources and other objects! Features of light sources! Illumination models are often approximations to reduce computations. 3 Light Sources! A light source is any object emitting radiant energy contributing to the lighting effects in a scene.! Light sources may have a variety of shapes, and may also serve as reflectors of light.! Typical light source properties:! Position in the scene! Color and direction of emitted light (perhaps multiple)! Shape! Reflective properties! In many cases, simple models are used to avoid extensive calculation. 4 2

Point Light Sources! These are the simplest models of light sources.! They emit a specified color along radially diverging paths (see the next slide).! They are appropriate to model light sources that are small compared to other objects in a scene, or light sources that are far away.! The position of the point light source determines which scene objects are illuminated and the light direction to a selected object surface position. 5 Figure 17-1 Diverging ray paths from a point light source. 3

Infinitely Distant Light Sources! A large light source (like the sun) that is far from the scene can be modeled as a point source, but there s little variation in directional effects.! Such sources illuminate the scene from only one direction (see the next slide).! This can be simulated by assigning a color and a fixed direction for light rays emanating from the source; only the emission direction vector and color are needed for the illumination calculations. 7 Figure 17-2 Light rays from an infinitely distant light source illuminate an object along nearly parallel light paths. 4

Radial Intensity Attenuation! Light intensity from a source obeys an inverse square law.! That is, the intensity at a distance d is attenuated by a factor of 1/d 2.! A surface close to the source receives higher incident light than a more distant surface.! If this were not the case, then all objects would be similarly illuminated, and overlapping objects at different distances might not be distinguishable. 9 Realistic Attenuation! Since most light sources are not really point sources, a pure inverse square law might not yield realism as expected.! To get more realistic displays, it s often appropriate to use an inverse quadratic function of the distance that includes a linear term: f = 1 / (a 0 + a 1 d + a 2 d 2 )! The numerical values can then be adjusted as necessary to yield realistic results.! This approach is not used if the source is at infinity. 10 5

Directional Light Sources and Spotlight Effects! Local sources can be modified easily to produce directional, or spotlight, beams of light.! If an object is outside the directional beam of light, it can be excluded from illumination by that source.! One easy way to produce such effects is to add a vector and an angular limit θ measured from the vector direction, as well as position and color. 11 Figure 17-3 A directional point light source. The unit light-direction vector defines the axis of a light cone, and angle θ l defines the angular extent of the circular cone. 6

Angular Intensity Attenuation! For a directional light source, the light intensity is attenuated (or can be attenuated)! as a function of distance from the source, and! as a function of the angular distance from the direction vector for the source! There is no attenuation if the light source isn t directional (that is, not a spotlight).! Attenuation is 100% if the object is outside the spotlight cone. 13 Figure 17-4 An object illuminated by a directional point light source. 7

Extended Light Sources! Large light sources close to objects in a scene (like a large neon lamp see next slide) can be approximated as a light-emitting surface.! The Warn model provide a method for producing studio lighting effects.! It uses sets of point emitters with various parameters. 15 Figure 17-5 An object illuminated by a large nearby light source. 8

Surface Lighting Effects! When light is incident on an opaque surface! part of it is reflected, and! part of it is absorbed.! Diffuse reflection from a rough or grainy surface tends to scatter reflected light in all directions.! Specular reflection occurs when reflected light is concentrated into a highlight, or bright spot. This is more pronounced on shiny surfaces.! Background or ambient light is due to reflected light from nearby objects that are illuminated. 17 Figure 17-6 Diffuse reflections from a surface. 9

Figure 17-7 Specular reflection superimposed on diffuse reflection vectors. Figure 17-8 Surface lighting effects are produced by a combination of illumination from light sources and reflections from other surfaces. 10

Basic Illumination Models (1)! The basic illumination model included in most graphics systems provides point sources.! Many systems also include functions for dealing with directional lighting and extended light sources.! Ambient light: systems often provide a method for setting a general brightness level for a scene.! Diffuse reflection: reflection from a surface can often be modeled as perfect (the same in all directions). 21 Basic Illumination Models (2)! The goal of the basic illumination model is to develop a mathematical expression for I (illumination) at a point that is reasonably easy to compute.! I (the mathematical expression) can contain various terms resulting from different kinds of light sources, reflections, attenuation, surface properties, etc. 22 11

Figure 17-9 Radiant energy from a surface area element da in direction Φ N relative to the surface normal direction is proportional to cos ϕ N. Figure 17-10 A surface that is perpendicular to the direction of the incident light (a) is more illuminated than an equal-sized surface at an oblique angle (b) to the incoming light direction. 12

Figure 17-11 An illuminated area A projected perpendicular to the path of incoming light rays. This perpendicular projection has an area equal to A cos θ. Figure 17-12 Angle of incidence θ between the unit light-source direction vector L and the unit normal vector N at a surface position. 13

Specular Reflection, Phong Model! The bright spot in specular reflection from a shiny surface is the result of light in a concentrated region around the specular reflection angle.! A model developed by Phong Bui Thong, called the Phong model, mathematically sets the intensity of specular reflection proportional to cos n s ϕ! n s is as small as 1 for a dull surface, or large (e.g. 100 or more) for a shiny surface. 27 Figure 17-13 Specular reflection angle equals angle of incidence θ. 14

Figure 17-14 Modeling specular reflections (shaded area) with parameter n s. Figure 17-15 Plots of cos n s ϕ using five different values for the specular exponent n s. 15

Figure 17-16 Approximate variation of the specularreflection coefficient for different materials, as a function of the angle of incidence. Non-planar Surfaces! To easily compute specular reflection from nonplanar surfaces, models often compute N!H, where N is a surface normal and H is the orientation direction for the surface that would produce maximum specular reflection in the viewing direction.! This computation is easier than computing N!R (where R is the reflection vector), since both N and R have variable components, and H is fixed. 32 16

Figure 17-17 The projection of either L or R onto the direction of the normal vector N has a magnitude equal to N L. Figure 17-18 Halfway vector H along the bisector of the angle between L and V. 17

Surface Light Emissions! Surface light can be included in a model by including a term for constant simulated background lighting.! This simplistic model can be improved in a variety of ways, involving ray tracing and radiosity models.! Unfortunately, we don t have time to cover all of these here. 35 RGB Color Considerations! The light in an RGB color description is, as expected, a 3-element vector that designates the red, green, and blue components.! Although scenes are often illuminated with white light, other colors can be used for special effects.! Surfaces can also be specified with various color reflectivity properties that affect the intensity of light reflected from the surface. 36 18

Transparent Surfaces! At a transparent surface, some incident light is reflected, and some passes through the surface.! The light passing through the surface is scattered, so the objects in the background may be seen as blurred objects.! The angle of lighting changes when it passes through regions with different materials.! Snell s law specifies how this refraction affects the angle. 37 Figure 17-19 Light emission from a transparent surface is in general a combination of reflected and transmitted light. 19

Figure 17-20 Reflection direction R and refraction (transmission) direction T for a ray of light incident upon a surface with index of refraction η r. Figure 17-21 Refraction of light through a pane of glass. The emerging refracted ray travels along a path that is parallel to the incident light path (dashed line). 20

Table 17-1 Average Index of Refraction for Common Materials Figure 17-22 The intensity of a background object at point P can be combined with the reflected intensity off the surface of a transparent object along a perpendicular projection line (dashed). 21

Atmospheric Effects! Various effects on of the atmosphere on lighting can be modeled.! An obvious effect is due to haze (from smoke, fog, dust, etc.), and causes colors to fade and objects to appear dimmer. This is often modeled with an exponential attenuation function.! The atmosphere can also have a color, such as smoke in a room being slate-gray or perhaps pale blue. 43 Shadows! Visibility detection methods can be used to locate regions that are not illuminated.! These regions can then have their shadows treated as surface patterns.! These surface patterns can be stored in pattern arrays, and are valid for any viewing position as long as the light sources are not changed. 44 22

Camera Parameters! The general model assumes the scene is being viewed as through a pinhole camera.! For realism, it is appropriate to consider objects that are in focus, and objects that are not in focus, depending on the depth distribution of objects in the scene.! The out-of-focus positions can be simulated by projecting each position to an area covering multiple pixel positions, with the object colors merged to produce a blurred pattern. 45 Displaying Light Intensities! The real world has a continuous range of light intensities; computers can display only a limited number of intensities.! Therefore intensities calculated by a model must be mapped to one of a finite number of intensities.! Humans perceive light intensity in the same way as sound: on a logarithmic scale.! It is relatively easy, given monitor and display device characteristics, to determine how to map calculated intensities to system intensities. 46 23

Gamma Correction, Video Lookup Tables! When displayed on a monitor, perceived brightness variations are nonlinear, but illumination models produce a linear variation for intensity values.! To compensate, graphics systems use a video lookup table to adjust linear intensity values; these are computed using the so-called gamma correction of intensity. (See the text for the equation.) 47 Figure 17-23 A typical monitor response curve, showing the variation in displayed intensity (or brightness ) as a function of the normalized electron-gun voltage. 24

Figure 17-24 A video lookup correction curve for mapping a normalized intensity value to a normalized electron-gun voltage, using gamma correction with γ = 2.2. Halftone Patterns, Dithering! If a system has very few intensity levels, an apparent increase in the number of available intensities can be obtained by using multiple pixel positions to display the intensity of each logical pixel in a scene.! Our eyes tend to integrate or average fine detail into an overall intensity.! Newspapers and books often use halftoning; the reproduced pictures are called halftones. 50 25

Figure 17-25 A continuous-tone photograph (a) printed with two intensity levels (b), four intensity levels (c), and eight intensity levels (d). Figure 17-26 An enlarged section of a photograph reproduced with a halftoning method, showing how tones are represented with dots of varying sizes. 26

Figure 17-27 A set of 2 2 pixel grid patterns that can be used to display five intensity levels on a bilevel system, showing the on pixels as green circles. The intensity values that are mapped to each of the grid patterns are listed below the pixel arrays. Figure 17-28 A set of 3 3 pixel grid patterns that can be used to display 10 intensities on a bilevel system, showing the on pixels as green circles. The intensity values that are mapped to each of the grid patterns are listed below the pixel arrays. 27

Figure 17-29 For a 3 3 pixel grid, the pattern in (a) is better than any of the symmetrical patterns in (b) for representing the third intensity level above 0. Figure 17-30 Halftone grid patterns with isolated pixels that cannot be reproduced effectively on some hardcopy devices. 28

Figure 17-31 Intensity representations 0 through 12 obtained with halftone-approximation patterns using 2 2 pixel grids on a four-level system, with pixelintensity levels labeled 0 through 3. Figure 17-32 A 2 2 pixel-grid pattern for displaying RGB colors. 29

Figure 17-33 Fraction of intensity error that can be distributed to neighboring pixel positions using an error-diffusion scheme. Figure 17-34 One possible distribution scheme for dividing the intensity array into 64 dot-diffusion classes numbered from 0 through 63. 30

Polygon Rendering Methods! To reduce processing time, polygon surfaces are rendered by calculating surface light intensity only at polygon vertices.! The vertex intensities are then interpolated to the other positions on the polygon surface.! There are other more accurate techniques (raytracing was mentioned earlier).! Here we consider only scan-line surface-rendering. 61 Figure 17-35 The normal vector at vertex V is calculated as the average of the surface normals for each polygon sharing that vertex. 31

Figure 17-36 For Gouraud surface rendering, the intensity at point 4 is linearly interpolated from the intensities at vertices 1 and 2. The intensity at point 5 is linearly interpolated from intensities at vertices 2 and 3. An interior point p is then assigned an intensity value that is linearly interpolated from intensities at positions 4 and 5. Figure 17-37 Incremental interpolation of intensity values along a polygon edge for successive scan lines. 32

Phong Surface Rendering! The Phong surface rendering technique interpolates normal vectors instead of intensity values.! This technique is more accurate than the Gouraud method, but requires more calculation.! A fast Phong surface rendering technique reduces the computation time by using a truncated Taylor series expansion for calculating surface normal vectors. 65 Figure 17-38 Interpolation of surface normals along a polygon edge. 33

OpenGL Illumination Functions! OpenGL provides a variety of techniques for setting up point sources, specifying surface-reflection coefficients, and setting other values for the basic illumination model.! In addition, other things, like transparency, flat surface rendering, or Gouraud surface rendering can be simulated. 67 Point Sources! There are at least 8 point sources available, with IDs (names) GL_LIGHT0 GL_LIGHT7. (More may be available in some systems.)! Properties of these sources are set using gllight* (lightid, property, value); where * is i, f, iv, or fv (int, float, int/float vector).! We enable (or disable) point sources individually: glenable (lightid);! We must also enable lighting globally: glenable (GL_LIGHTING); 68 34

Light Source Position! For a local source: Glfloat L1[] = {2, 0, 3, 1}; // note: xyz pos + 1 gllightfv(gl_light1,gl_position,l1);! For a distant source: Glfloat L2[] = {0, 1, 0, 0}; // note: xyz dir + 0 gllightfv(gl_light2,gl_position,l2);! Default: distant source with light rays traveling in the z direction. 69 Light Colors! Specify a color vector: Glfloat white[] = {1,1,1,1}; // RBG values + alpha! Specify a lighting type: gllightfv(gl_light0,gl_ambient,white); gllightfv(gl_light0,gl_diffuse,white); gllightfv(gl_light0,gl_specular,white);! There are defaults for each of the lighting sources if they aren t specified.! Note that if color blending is enabled, the alpha parameter can be used as a factor. 70 35

Radial Intensity Attenuation! Various parameters can be specified for attenuation: gllightf(gl_light0,gl_constant_attenuation, 1.5); gllightf(gl_light0,gl_linear_attenuation, 0.75); gllightf(gl_light0,gl_quadratic_attenuation, 0.4);! These are the parameters (a 0, a 1, and a 2 ) used in the realistic attenuation model shown earlier (slide 10): f = 1 / (a 0 + a 1 d + a 2 d 2 ) 71 Directional Light Sources (Spotlights)! Specify the light direction vector: GLfloat dv[] = {1,0,0}; // positive x direction! Specify parameters: gllightfv(gl_light3,gl_spot_direction,dv); gllightf(gl_light3,gl_spot_cutoff,30.0); gllightf(gl_light3,gl_spot_exponent,2.5);! These parameters show light source 3 with a cone in the +x direction, a cone angle of 30 degrees, and the attenuation exponent of 2.5; see the figure on the next slide. 72 36

Figure 17-39 A circular cone of light emitted from an OpenGL light source. The angular extent of the light cone, measured from the cone axis, is θ l, and the angle from the axis to an object direction vector is labeled as α. OpenGL Global Lighting Params! To set a global parameter: gllightmodel* (paramname, paramvalue); As usual, the * is replaced by i, f, iv, or fv.! Background lighting: glfloat ga[] = {0,0,0.3,1}; gllightmodelfv(gl_light_model_ambient,ga);! Specular reflection uses (by default) a constant vector in the +z direction for specular reflection calculations. This can be turned off, and then the actual viewing position is used: gllightmodeli(gl_light_model_local_viewer,gl_true); 74 37

More Global Parameters! To enable combining texture patterns and specular effects: gllightmodeli(gl_light_model_color_control, GL_SEPARATE_SPECULAR_COLOR);! To apply lighting calculations using material properties of both the front and back of surfaces: gllightmodeli(gl_light_model_two_side,gl_true); 75 OpenGL Surface-Property Function! To set reflection coefficients and other optical properties of surfaces: glmaterial* (face, property, value);! face is GL_FRONT, GL_BACK, or GL_FRONT_AND_BACK.! To specify light emission: glmaterialfv(gl_front,gl_emission,colorvec); where colorvec is an RGBA value. 76 38

Other Surface Properties! Surface reflection can be specified using the parameter GL_AMBIENT_AND_DIFFUSE; a 4- element vector specifies the diffuse coefficients.! Similarly, GL_SPECULAR can be used as the property, with a 4-element vector giving the specular coeffients.! The shininess of a surface (or surfaces) can be set with the GL_SHININESS property; if requires only a single parameter value. 77 Atmospheric Effects! Fog is the general atmospheric effect provided by OpenGL.! It must be enabled if it is to be effective: glenable(gl_fog);! Then various parameters can be set: glfog* (atmoparameter, paramvalue) where atmoparameter is the name of a parameter and paramvalue provides the value. 78 39

Fog Parameters and Values! GL_FOG_COLOR, with a 4-element vector value, specifies the color (and alpha value) for the fog.! GL_FOG_MODE is used to set the atmosphere attenuation function. The integer parameter value may be GL_EXP (e -ρd ) or GL_EXP2 (e -(ρd)2 ), where d is the distance of the object from the viewing position, and ρ is a fog density parameter, set like this: glfog*(gl_fog_density, atmodensity); 79 Transparency (1)! Some transparency effects in OpenGL can be achieved with the color blending features.! But transparency implementation, in general, is not straightforward.! glcolor4f(r,g,b,a); is used to set the color and alpha parameter to be used for drawing, which can be used to effect transparency:! A = 1.0 would be used for a completely transparent surface.! A = 0.0 would be used for a completely opaque surface. 80 40

Transparency (2)! Now we enable blending: glenable (GL_BLEND);! The blend function used is glblendfunc(gl_one_minus_src_alpha, GL_SRC_ALPHA); This causes the surface color of objects further away from the viewer to be combined with the color of closer objects that overlap.! Example: if the more distant object has A = 0.3, then an overlapped objects color is 30% of the old object and 70% of the object reflection color. 81 Surface Rendering Functions (1)! glshademodel (surfrenderingmethod); is used to specify either constant-intensity surface rendering (GL_FLAT) or Gouraud surface rendering (GL_SMOOTH). No support is present for Phong surface rendering, ray tracing, or radiosity methods.! Surface normals are used to calculate the colors of polygon surfaces in a tessellated curved surface. The Cartesian coordinate components of the normals are defined using: glnormal3* (Nx, Ny, Nz); where Nx, Ny, and Nz range from -1.0 to +1.0. 82 41

Surface Rendering Functions (2)! For flat surface rendering, only one normal need be specified. This can be done before the specification of the three (or more) vertices for the polygon (e.g. outside the glbegin/glend code).! For Gouraud surface rendering, each vertex must have its normal specified, so to specify a triangle we d need to put 3 pairs of glnormal/glvertex calls between glbegin and glend.! If normals are unit vectors, computation can be reduced. To do this: glenable(gl_normalize); 83 OpenGL Halftoning Operations! Although they re hardware dependent, and probably not useful on systems with full-color graphics capabilities, halftone routines can be activated and deactivated with the somewhat expected functions:! glenable (GL_DITHER); // enable halftone routines! gldisable (GL_DITHER); // disable halftone routines 84 42

Table 17-2 Continued 43