CSPC 352: PC Illustrations.


118 views
Uploaded on:
Category: Home / Real Estate
Description
CSPC 352: PC Representation Section 6: Lighting and Shading Review Nearby and worldwide enlightenment Phong reflectance model (neighborhood brightening) Level, Gouraud, and Phong Shading on a polygonal lattice Surface subdivisions Shading in OpenGL Point of view
Transcripts
Slide 1

CSPC 352: Computer Graphics Chapter 6: Lighting and Shading

Slide 2

Overview Local and worldwide brightening Phong reflectance model (nearby enlightenment) Flat, Gouraud, and Phong Shading on a polygonal cross section Surface subdivisions Shading in OpenGL

Slide 3

Perspective Modeling so as to light and shading are proficient the world and reproducing the laws of material science Short story [ Stanislaw Lem, The Cyberiad ]: The constructor Trurl makes a small recreation of a kingdom in a case to make an ousted, banished autocrat cheerful. Trurl’s companion believes that is terrible… There are the individuals who say that we exist in the psyche of God . What do you think about that thought? Pascal, Pens é es : “The arithmetical machine produces impacts which come closer to thought than anything which creatures can do; yet it can do nothing which may lead us to say that it has choice, as the creatures have.”

Slide 5

Need for shading Was it difficult to make the 3D bloom (first program) look 3D? Shading that is suitable for the lighting is the essential sign to 3D appearance [What are some other cues?]

Slide 6

Illumination models General methodology: show the world reenact material science Global bouncing so as to brighten models (beam following, radiosity) focus shading light around a whole domain (too moderate for intelligent design) Local enlightenment models consider just the surface, light heading, and review bearing

Slide 8

Local enlightenment To make lighting sufficiently quick, we will at first limit our thoughtfulness regarding: Light source, one surface, and viewer (disregard between item reflections, shadows) Ambient, diffuse, and specular reflection (overlook straightforwardness, refraction, reflection, …)

Slide 10

Light sources when all is said in done, a light source is a somewhat muddled thing. It can discharge distinctive measures of light for every Location (x, y, z) Direction (  , f ) Wavelength ( l ) Illumination capacity: I(x, y, z,  , f , l ) Examples: surrounding, point, region, spot, far off, …

Slide 11

Colored lights Intensity of transmitted light can likewise be an element of wavelength We typically display as I = [I r , I g , I b ] parts Some analyses have been finished with an entire range of shading qualities, giving more reasonable results now and again

Slide 12

Ambient light Intensity doesn’t differ with x, y, z,  , f I = [I ar , I ag , I abdominal muscle ]

Slide 13

Point lights Point lights have an area (so more remote articles get less light) yet are not directional I(p 0 ) = [I r (p 0 ), I b (p 0 ), I g (p 0 )] How might you figure the enlightenment at point p? Brightening corresponding to opposite square of separation I(p, p 0 ) = (1/d 2 ) [I r (p 0 ), I b (p 0 ), I g (p 0 )]

Slide 14

Limitations of point lights Usually bring about misleadingly high-complexity pictures Can produce umbra (full shadow) yet not penumbra (halfway shadow) Area lights create milder shadows, yet are generally utilized just as a part of raytracing or radiosity

Slide 15

Distant (directional) lights Light point lights, however Without lessening in view of the separation Without distinction in bearing (parallel beams) Location of light source gets to be [x, y, z, 0]; no constriction More proficient to register than point sources

Slide 16

Spotlights Directional, i.e. light is transmitted in a restricted scope of edges, q More reasonable spotlights would show a progressive tumble off of light E.g. cos e f = (s • l) e if s is bearing of source, l course to source, both unit vectors

Slide 17

Illumination and shading How do these light sources influence splendor of a surface point? Most regularly utilized model for intuitive representation: Phong Illumination Model Involves terms: Ambient Diffuse Specular It is an (improved) model of the material science of reflection

Slide 18

Vectors utilized by Phong model The headings utilized by the phong model n : surface outward typical v : bearing to viewer l : course to light source r : reflection bearing Since these are headings, they are unit vectors.

Slide 19

Ambient term of Phong model An item has a surrounding reflectivity coefficient, k an A light source emits a sure measure of encompassing light, L a Total surrounding brightening: I a = k a L a (For hued light, we rehash this calculation for R, G, and B encompassing light values and reflectivity coefficients)

Slide 21

Diffuse term A consummately diffuse reflector is rough to the point that it dissipates light similarly in all bearings But take note of that when the light comes in at an edge, the same vitality is spread out over bigger zone Such surfaces are called Lambertian surfaces (obeying Lambert’s Law)

Slide 22

Diffuse shading At twelve, illum. is 1 As the edge q (u in figure) diminishes, light goes to zero Illumination is corresponding to cos( q ) (Lambert’s law) cos( q ) = l • n I d = k d l • n L d

Slide 24

Specular Term Specular term includes highlights in the reflection heading Note that the smoother and shinier the item, the tigher and brighter the Highlight force falls as viewer v moves far from reflection dir, r . (cos f = v • r ) Modeled as cos a f , an is sparkle coefficient (1..200) I s = k s L s ( r • v ) a

Slide 26

Phong brightening model Phong enlightenment model: I = Ambient + Diffuse + Specular = I a + I d + I s = k a L a + k d L d l • n + k s L s ( r • v ) a May include light constriction term 1/(a+bd+cd 2 ) ( k a L a + k d l • n L d ) + k s L s ( r • v ) a Parameters required: Light: L a , L d , L s for every light Surface: k a , k d , k s , a Repeat for every shading segment, light source How difficult to figure?

Slide 27

Polygon shading How would you utilize the Phong Illumination Model to render an item with shading? Consider a polygonal circle close estimation How would you discover the normals to the appearances? Shade a face with a consistent shading? glShadeModel(GL_FLAT); Called level shading or Constant shading How much calculation would this oblige Per pixel? Per vertex?

Slide 29

Flat shading disadvantages The human visual framework improves edges We see stripes (known as Mach Bands) along edges Much like a convolution! How to maintain a strategic distance from?

Slide 30

Gouraud shading Gouraud shading: Define vertex normals as normal of encompassing confronts Compute lighting mathematical statement at every vertex Interpolate hues crosswise over polygon glShadeModel(GL_SMOOTH); Computation obliged Per pixel? Per vertex? Fast! Particularly with sensibly expansive polygons and equipment shading interjection

Slide 32

Gouraud disadvantages Drawbacks of Gouraud shading? Polygon edges are still unmistakable Brightness is demonstrated as a direct capacity, however that’s not so much precise Real highlights are little and brilliant and drop off pointedly If polygons are too vast, highlights get misshaped and darkened (notification the interesting shape) How to dodge these antiquities?

Slide 33

Phong shading To wipe out ancient rarities, insert normals Results: better shading, much more pleasant highlights Computation obliged per pixel? This is still excessively lavish, making it impossible to do in equipment, when all is said in done

Slide 35

Shading rundown Don’t confound Phong Illumination Model and Phong Shading Gouraud shading: process light model at every vertex. Introduce hues. (Regularly done in equipment) Phong shading: interject vertex normals. Process brightening model at every vertex

Slide 36

Specifying lights in OpenGL bolsters those four light sorts Point, directional lights GLfloat light0_pos[] = {1.0, 2.0, 3.0, 1.0}; GLfloat light0_pos[] = {1.0, 2.0, 3.0, 0.0}; Diffuse, Ambient, Specular coefficients GLfloat diffuse0[] = {1, 0, 0, 1}; GLfloat ambient0[] = {1, 0, 0, 1}; GLfloat spedular0[] = {1, 1, 1, 1}; glEnable(GL_LIGHTING)

Slide 38

Enabling lights Can empower no less than 8 lights: glEnable(GL_LIGHT0); glLightfv(GL_LIGHT0, GL_POSITION, light0_pos); glLightfv(GL_LIGHT0, GL_AMBIENT, ambient0); glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuse0); glLightfv(GL_LIGHT0, GL_SPECULA, specular0); Spotlights: set all the more light parameters as above GL_SPOT_DIRECTION GL_SPOT_EXPONENT GL_SPOT_CUTOFF

Slide 39

Specifying Materials Material properties are a drawing\'s piece state, determined by glMaterialfv GLfloat ambient[] = {0.2, 0.2, 0.2, 1.0}; GLfloat diffuse[] = {1.0, 0.8, 0.0, 1.0}; GLfloat specular[] = {1.0, 1.0, 1.0, 1.0}; glMaterialfv(GL_FRONT, GL_AMBIENT, encompassing); glMaterialfv(GL_FRONT, GL_DIFFUSE, diffuse); glMaterialfv(GL_FRONT, GL_SPECULAR, specular); glMaterialf(GL_FRONT, GL_SHININESS, 100.0); GLfloat emission[]={0.0, 0.3, 0.3, 1.0}; glMaterialfv(GL_FRONT, GL_EMISSION, emanation); Use GL_FRONT_AND_BACK for two-sided appearances

Slide 41

OpenGL Gouraud Shading OpenGL needs to know vertex normals and in addition areas glNormal3fv(n); glVertex3fv(p); How to register vertex normals? Cross item for face normals Average normals of encompassing confronts How to discover neighboring countenances?

Slide 42

Virtual Trackball shading Flat shading Compute an ordinary for every face Gouraud shading Compute a typical for every vertex as normal of neighboring confronts [Defect: you may not have any desire to smooth-shade over each edge: in what capacity would it be a good idea for it to truly be done?] What might you need to do to handle material properties, surface hues, and so forth?

Slide 43

Surface subdivision In genuine modelers… one can ordinarily characterize smooth bended surfaces Eg circles, quadrics, NURBS, smoothed polygons Modeler renders with smoothness setting Recursively split polygons into littler pieces, with new vertices on the smooth surface Bisecting so as to split a triangle should be possible points Computing the centrum Bisecting sides obviously, smoother surfaces take more time

Recommended
View more...