Top Banner
1 06/27/22 10:41 UML Graphics: Conceptual Model Real Object Real Object Human Eye Human Eye Display Device Graphics System Synthetic Model Synthetic Camera Real Light Synthetic Light Source
33

19/17/2015 13:25 UML Graphics: Conceptual Model Real Object Human Eye Display Device Graphics System Synthetic Model Synthetic Camera Real Light Synthetic.

Dec 28, 2015

Download

Documents

Wesley Reeves
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: 19/17/2015 13:25 UML Graphics: Conceptual Model Real Object Human Eye Display Device Graphics System Synthetic Model Synthetic Camera Real Light Synthetic.

104/19/23 16:10

UML

Graphics: Conceptual Model

Real Object

Real Object

Human Eye

Human Eye

DisplayDevice

Graphics System

SyntheticModel

SyntheticCamera

Real Light

SyntheticLight Source

Page 2: 19/17/2015 13:25 UML Graphics: Conceptual Model Real Object Human Eye Display Device Graphics System Synthetic Model Synthetic Camera Real Light Synthetic.

204/19/23 16:10

UML

Lights, Surfaces, and Imaging

Proj. Plane

COP

Objects

Page 3: 19/17/2015 13:25 UML Graphics: Conceptual Model Real Object Human Eye Display Device Graphics System Synthetic Model Synthetic Camera Real Light Synthetic.

304/19/23 16:10

UML

Lights, Surfaces, and Imaging

Proj. Plane

COP

Light Source

Objects

Page 4: 19/17/2015 13:25 UML Graphics: Conceptual Model Real Object Human Eye Display Device Graphics System Synthetic Model Synthetic Camera Real Light Synthetic.

404/19/23 16:10

UML

Modes of Interaction ofLight with Materials

SpecularSurfaceReflection

DiffuseSurfaceReflection

TranslucentSurface

Note: Any given surface can have some of all threeproperties.

Page 5: 19/17/2015 13:25 UML Graphics: Conceptual Model Real Object Human Eye Display Device Graphics System Synthetic Model Synthetic Camera Real Light Synthetic.

504/19/23 16:10

UML

Reflection

Rough Surface:Light is reflected equally in all directions.

Smooth Surface:Light is reflected at an anglenear to the incident angle.

Diffuse

Specular

Page 6: 19/17/2015 13:25 UML Graphics: Conceptual Model Real Object Human Eye Display Device Graphics System Synthetic Model Synthetic Camera Real Light Synthetic.

604/19/23 16:10

UML

Illuminating Surfaces

z

x

y

I(x, y, z,,, )We can define illumination function:To obtain total light, must integrate over total surface.

I( ,,)

dAddzyxII total ),,,,,()(

Page 7: 19/17/2015 13:25 UML Graphics: Conceptual Model Real Object Human Eye Display Device Graphics System Synthetic Model Synthetic Camera Real Light Synthetic.

704/19/23 16:10

UML

Simpler Models

Exact model can easily get nasty to use! Three simplificationswill help.

1. We can consider four simplified classes of light sources

• ambient• point• spotlight• distant

2. Human color perception allows us to consider illuminationfunction in terms of the three primary colors.

3. We can (or must) neglect:

• multiple reflections• obstruction of light path by objects

Page 8: 19/17/2015 13:25 UML Graphics: Conceptual Model Real Object Human Eye Display Device Graphics System Synthetic Model Synthetic Camera Real Light Synthetic.

804/19/23 16:10

UML

Ambient Light

Simulates situations where light sources are designed to produceuniform lighting throughout a scene. Ambient light can be thought ofas present everywhere, coming from all directions.

Characterized by a scalar intensity, Ia , that is identical at every pointin the scene.

Ia Iar

Iag

Iab

Although every surface receives the same illumination, eachsurface can reflect the light differently.

Page 9: 19/17/2015 13:25 UML Graphics: Conceptual Model Real Object Human Eye Display Device Graphics System Synthetic Model Synthetic Camera Real Light Synthetic.

904/19/23 16:10

UML

Point Sources

An ideal point source radiates equally in all directions. It canbe characterized by:

I(p0 ) I r (p0 )

Ig (p0 )

Ib (p0 )

Intensity of illumination from a point source is proportionalto the inverse square of the distance between the point and theilluminated surface.

I(p,p0 ) 1

p p0

2 I(p0 )

Page 10: 19/17/2015 13:25 UML Graphics: Conceptual Model Real Object Human Eye Display Device Graphics System Synthetic Model Synthetic Camera Real Light Synthetic.

1004/19/23 16:10

UML

Spotlights

Spotlights are point sources for which the angle through whichlight has been emitted has been limited.

l

s

I k cose ( ) k(ls)e

Page 11: 19/17/2015 13:25 UML Graphics: Conceptual Model Real Object Human Eye Display Device Graphics System Synthetic Model Synthetic Camera Real Light Synthetic.

1104/19/23 16:10

UML

Distant Sources

Most shading calculations require the direction from the point ona surface to the light source. As light sources are moved to larger distances, this direction approaches a constant.

Therefore the point source location will be replaced by a vectorindicating the direction of the source.

p0

x

y

z

1

will be replaced by : p0

x

y

z

0

Page 12: 19/17/2015 13:25 UML Graphics: Conceptual Model Real Object Human Eye Display Device Graphics System Synthetic Model Synthetic Camera Real Light Synthetic.

1204/19/23 16:10

UML

Reflection

Rough Surface:Light is reflected equally in all directions.

Smooth Surface:Light is reflected at an anglenear to the incident angle.

Diffuse

Specular

Page 13: 19/17/2015 13:25 UML Graphics: Conceptual Model Real Object Human Eye Display Device Graphics System Synthetic Model Synthetic Camera Real Light Synthetic.

1304/19/23 16:10

UML

Vectors Used byPhong Lighting Model

n

l r

v

p is an arbitrary point on a surface.n is the unit normal to the surface at p.l is a unit vector in the direction of the light source.r is a unit vector in the direction of a perfectly (specular) reflectionv is a unit vector in thedirection of the viewer.

p

COP

Page 14: 19/17/2015 13:25 UML Graphics: Conceptual Model Real Object Human Eye Display Device Graphics System Synthetic Model Synthetic Camera Real Light Synthetic.

1404/19/23 16:10

UML

Elements of the Phong Lighting Model

L i Lira Liga Liba

Lird Ligd Libd

Lirs Ligs Libs

R i Rira Riga Riba

Rird Rigd Ribd

Rirs Rigs Ribs

I Ia Id Is La Ra Ld Rd Ls Rs

At each point p thereis an illumination matrixfrom the ith light source:

At each point p there is a reflection matrix forthe ith light source:

Assuming the calculations will be done separately foreach primary, we can sum over light sources to get:

Page 15: 19/17/2015 13:25 UML Graphics: Conceptual Model Real Object Human Eye Display Device Graphics System Synthetic Model Synthetic Camera Real Light Synthetic.

1504/19/23 16:10

UML

Elements of the Phong Lighting ModelAmbient Reflection

Ia ka La

0 ka 1

The intensity of ambient light is the same at every pointon the surface. The percentage of light reflected is givenby: Ra ka

Note that the ambient reflection terms can be differentfor red, green and blue.

Page 16: 19/17/2015 13:25 UML Graphics: Conceptual Model Real Object Human Eye Display Device Graphics System Synthetic Model Synthetic Camera Real Light Synthetic.

1604/19/23 16:10

UML

Elements of the Phong Lighting ModelDiffuse Reflection

Intensity of illumination is dependent upon the incidence angleof light from the source:

l

n

Rd cos ln

Id kd (ln)Ld

Adding a term for attenuationwith distance from source:

Id kd

a bd cd 2(ln)Ld

Page 17: 19/17/2015 13:25 UML Graphics: Conceptual Model Real Object Human Eye Display Device Graphics System Synthetic Model Synthetic Camera Real Light Synthetic.

1704/19/23 16:10

UML

Elements of the Phong Lighting ModelSpecular Reflection

For a shiny surface, most light is reflected around vector r,corresponding to a reflected angle equal to the angle of incidence.If is the angle between v and r,

Is ks Ls cos

Adding a distance term, and expressing the cosine in terms ofa dot product:

Is 1

a bd cd 2ks Ls (r v)

Page 18: 19/17/2015 13:25 UML Graphics: Conceptual Model Real Object Human Eye Display Device Graphics System Synthetic Model Synthetic Camera Real Light Synthetic.

1804/19/23 16:10

UML

The Complete Phong Model

I 1

a bd cd 2(kd Ld (l n) ks Ls (r v) ) ka La

Distance term Ambient term

Diffuse termSpecular term

Page 19: 19/17/2015 13:25 UML Graphics: Conceptual Model Real Object Human Eye Display Device Graphics System Synthetic Model Synthetic Camera Real Light Synthetic.

1904/19/23 16:10

UML

Specification of the Normal in OpenGL

Specification of the current normal is modal and associated withvertices.

glNormal3f(nx,ny,nz);glNormal3fv(pointer_to_normal_vector);

You have to calculate the normals yourself.

Page 20: 19/17/2015 13:25 UML Graphics: Conceptual Model Real Object Human Eye Display Device Graphics System Synthetic Model Synthetic Camera Real Light Synthetic.

2004/19/23 16:10

UML

Calculation of Normals

Normal exists at every point for mathematically defined smooth surfaces.

Exists for each polygon in surface defined by flat polygons.What about the shared lines?

Polygonal Case:

p0

p1

p2

n

n (p1 p0 ) (p2 p0 )

Page 21: 19/17/2015 13:25 UML Graphics: Conceptual Model Real Object Human Eye Display Device Graphics System Synthetic Model Synthetic Camera Real Light Synthetic.

2104/19/23 16:10

UML

Shading in OpenGL:Flat Shading

OpenGL uses the current normal and calculates thecolor at the first vertex of a polygon. This color is used for the entire polygon.

Requested by: glShadeModel(GL_FLAT);

Flat shading exaggerates the visual effect of the boundaries between polygons due to the Mach band effect.

Page 22: 19/17/2015 13:25 UML Graphics: Conceptual Model Real Object Human Eye Display Device Graphics System Synthetic Model Synthetic Camera Real Light Synthetic.

2204/19/23 16:10

UML

Mach Band Effect(Mach, 1865)

Color Science, Concepts and MethodsWyszecki, Stiles

Page 23: 19/17/2015 13:25 UML Graphics: Conceptual Model Real Object Human Eye Display Device Graphics System Synthetic Model Synthetic Camera Real Light Synthetic.

2304/19/23 16:10

UML

Mach Band Effect

Page 24: 19/17/2015 13:25 UML Graphics: Conceptual Model Real Object Human Eye Display Device Graphics System Synthetic Model Synthetic Camera Real Light Synthetic.

2404/19/23 16:10

UML

Mach Band Effect

Page 25: 19/17/2015 13:25 UML Graphics: Conceptual Model Real Object Human Eye Display Device Graphics System Synthetic Model Synthetic Camera Real Light Synthetic.

2504/19/23 16:10

UML

Shading in OpenGL:Smooth Shading

Requested by: glShadeModel(GL_SMOOTH);

Lighting calculations will be done at each vertex using thematerial properties, and the vectors v and l calculated forthat vertex.

Bilinear interpolation is used to determine color values inthe interior of the polygon.

Gouraud Shading:

Normal at a vertex is the normalized average of the normals of the polygons that share that vertex.

Page 26: 19/17/2015 13:25 UML Graphics: Conceptual Model Real Object Human Eye Display Device Graphics System Synthetic Model Synthetic Camera Real Light Synthetic.

2604/19/23 16:10

UML

Gouraud Shading

Page 27: 19/17/2015 13:25 UML Graphics: Conceptual Model Real Object Human Eye Display Device Graphics System Synthetic Model Synthetic Camera Real Light Synthetic.

2704/19/23 16:10

UML

Specifying Light Sources in OpenGL

General form: glLightf(source, parameter, value);glLightfv(source, parameter, *array);

source is one of at least eight lights: GL_LIGHTi

Parameters:

GL_AMBIENT contains four values that specify the ambient RGBAintensity of the light. Default is (0.0, 0.0, 0.0, 1.0).

GL_DIFFUSE contains four values that specify the diffuse RGBAintensity of the light. Default is (1.0, 1.0, 1.0, 1.0).

GL_SPECULAR contains four values that specify the secular RGBAintensity of the light. Default is (1.0, 1.0, 1.0, 1.0).

Page 28: 19/17/2015 13:25 UML Graphics: Conceptual Model Real Object Human Eye Display Device Graphics System Synthetic Model Synthetic Camera Real Light Synthetic.

2804/19/23 16:10

UML

Specifying Light Sources in OpenGl

GL_POSITION specifies the position of the light in homogeneousobject coordinates. If the w component is zero, the lightis treated as a directional source.

GL_SPOT_DIRECTION specifies the direction of the light in homogeneous object coordinates. Default is (0.0, 0.0, -1.0)

GL_SPOT_EXPONENT spotlight exponent, default 0.0

GL_SPOT_CUTOFF spot cutoff angle in [0,90] or (default) 180.

GL_CONSTANT_ATTENUATION constant atten. factor, default 1.0

GL_LINEAR_ATTENUATION linear atten. factor, default 0.0

GL_QUADRATIC_ATTENUATION quadratic atten. factor, default 0.0

Page 29: 19/17/2015 13:25 UML Graphics: Conceptual Model Real Object Human Eye Display Device Graphics System Synthetic Model Synthetic Camera Real Light Synthetic.

2904/19/23 16:10

UML

Enabling the Lights and Lighting

Enabling a light source: glEnable(GL_LIGHTi );

Enabling lighting: glEnable (GL_LIGHTING);

Page 30: 19/17/2015 13:25 UML Graphics: Conceptual Model Real Object Human Eye Display Device Graphics System Synthetic Model Synthetic Camera Real Light Synthetic.

3004/19/23 16:10

UML

Specifying Materials in OpenGL

General form: glMaterialf(face, parameter,value);glMaterialfv(face, parameter,*array);

face is GL_FRONT, GL_BACK, GL_FRONT_AND_BACK

parameter is:

GL_AMBIENT four values that specify the ambient RGBA reflectance of the material. (0.2,0.2,0.2,1.0)

GL_DIFFUSE four values that specify the diffuse RGBA reflectance of the material. (0.8,0.8,0.8,1.0)

GL_SPECULAR four values that specify the ambient RGBA reflectance of the material. (0.0,0.0,0.0,1.0)

GL_SHININESS specifies the specular reflectance exponent of the material. 0.0

Page 31: 19/17/2015 13:25 UML Graphics: Conceptual Model Real Object Human Eye Display Device Graphics System Synthetic Model Synthetic Camera Real Light Synthetic.

3104/19/23 16:10

UML

Lighting ChecklistLighting = Lights + Materials + Model

0 Lights- Color of lights is set as desired.

=Recommended: all lights set to white for diffuse, specular, and ambient

- Lights are positioned correctly.=Remember lights are positioned with current

MODELVIEW transformation at time of calling glLightfv() + GL_POSITION.

=Remember position (point) vs. direction (vector).- Remember: Lights are objects and retain properties.- Required lights are enabled.- Lighting is enabled.

Page 32: 19/17/2015 13:25 UML Graphics: Conceptual Model Real Object Human Eye Display Device Graphics System Synthetic Model Synthetic Camera Real Light Synthetic.

3204/19/23 16:10

UML

Lighting ChecklistLighting = Lights + Materials + Model

0 Materials- Color of materials is set as desired.

=Recommended: Set ambient color to zero initially until lighting is working perfectly. Use ambient with care!

=Remember: Material properties are modal and there is only one current material. Therefore set all properties that are required and keep track of current state.

- Be sure the proper normal is set for every polygon drawn. =Make sure the normal is of unit magnitude. You can

use glEnable(GL_NORMALIZE).=Remember: Normals are modal, like materials.

- Do not use glcolor3f() with lighting. Do not use glColorMaterial() in submissions for this class.

Page 33: 19/17/2015 13:25 UML Graphics: Conceptual Model Real Object Human Eye Display Device Graphics System Synthetic Model Synthetic Camera Real Light Synthetic.

3304/19/23 16:10

UML

Lighting ChecklistLighting = Lights + Materials + Model

0 Model- glShadeModel() determines where lighting is calculated

=GL_SMOOTH calculates at each polygon vertex and interpolates (default)

=GL_FLAT calculates at first vertex and uses one color

- glLightModel() sets global properties of lighting=GL_LIGHT_MODEL_TWO_SIDE reverses normals for

back facing polygons. This is the only argument that we should ever require.

=Do not use this function unless you really understand what the effects are.