1 / 23

250 likes | 476 Vues

Lighting. Quick recap of viewing and projection Reflection models Shading models. 3D Graphics Pipeline. Creating objects/scene 3D modeling and/or transformation Determining how objects/scene can be viewed Specification of camera view volume

Télécharger la présentation
## Lighting

**An Image/Link below is provided (as is) to download presentation**
Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.
Content is provided to you AS IS for your information and personal use only.
Download presentation by click this link.
While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.
During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

**Lighting**Quick recap of viewing and projection Reflection models Shading models**3D Graphics Pipeline**• Creating objects/scene • 3D modeling and/or transformation • Determining how objects/scene can be viewed • Specification of camera view volume • Transformation of objects to camera coordinate system • Clipping against view volume to determine visible objects • Hidden surface removal • Projection of visible objects to obtain a 2D image • Determining which pixels should be filled • Rasterization from vectors/polygons to pixels • Determining color/texture/lighting at each pixel • Lighting models and texture mapping**Rasterization**• This takes an image described in a vector graphics format and converting it into a raster image (pixels) • Polygon is then broken down into fragments, one for each pixel it covers. Colour is interpolated across the fragments Rasterise 1 Fragment ~ Pixel**Illumination/Lighting**• Illumination/light model simulates the reflection of light off a surface and the effect it has on the colour of the surface • We calculate, for each polygon, the amount of light it is able to reflect and transmit to the eye • We need to know, • how to represent light sources (approximate it with point sources for efficiency) • how to describe light interaction with surfaces - reflection models • how to calculate the intensity of light at a given point on an object surface - shading models**Reflection Model**Three general types of interaction: • Ambient light – is light with the same intensity everywhere, and appears to have no direction, as if reflected from other surfaces. Position of light is irrelevant • Diffuse light – is light from a point source that radiates equally in all directions. Position of light is relevant • Specular light – is light from a point source that radiates in a mirror-like fashion. Both position of light and position of observer are used in calculating specular light**The Phong Reflection Model**• The Phong reflection model was developed by Bui Tuong Phong in his University of Utah PhD dissertation "Illumination for Computer Generated Pictures" in 1973 • It is a local reflection model, i.e. it doesn't take into account for second-order reflections, as does ray tracing • It is an empirical model, based on informal observation, rather than physical description of light interaction,**The Phong Reflection Model**It uses four vectors to calculate light intensity for a point on a surface V = Direction to the viewer (COP) R = Direction of perfect reflection N = Surface normal L = Direction of light source light source N R eye L V surface**Ambient Reflection(only light intensity matters )**surface P Ia = KaLa Ia = Reflected intensity Ka = Reflection coefficient La = Intensity of light (same for every point)**light**source N R eye L V surface Diffuse Reflection(not affected by viewer direction, only light direction) Light reflected equally in all directions, with intensity dependent on angle between light and surface normal Id= KdLd(L.N) Id= Reflected intensity Kd = Diffuse reflection coefficient Ld = Intensity of light source (Id largest when light direction L is the same as N, as cos(0o)=1)**light**source light source Specular Reflection N • In perfect specular reflection, light is reflected along the direction symmetric to the incoming light • In practice, light is reflected within a small angle of the perfect reflection direction - a narrow cone for shiny surfaces, and a broader cone for dull surfaces R P N R P**eye**Specular Reflection(reflection depends on light, viewing, and surface normal) Amount of light visible to viewer depends on the angle between R and V: Is = KsLs(R.V)n n varies with material, large n: shiny, small n: dull (largest only when viewer direction is aligned with reflection direction) light source N R L V surface V = Direction to the viewer (COP) R = Direction of perfect reflected light N = Surface normal L = Direction of light source I* = Intensity of light source Ks = Specular reflection coefficient I = Reflected intensity**light**source N R eye L V surface Ambient, Diffuse and Specular • Phong reflection model decomposes reflection into three subcomponents, specular, diffuse, and ambient reflection I = Ambient + Diffuse + Specular I = KaLa + KdLd ( L . N ) + Ks Ls( R . V )n**light**viewer N V L R Flat Shading • We know how to give a point a light intensity value • Now we need to do that for each pixel of the image • Shading assigns brightness and colour to a polygon • In flat shading, the normal of the polygon is used to shade the entire polygon uniformly. A ‘scan line’ is used to fill a polygon with a constant colour**N**Gouraud Shading • Gouraud (Henri Gouraud) shading was invented by Gouraud in 1971 • It linearly interpolates a colour or shade across a polygon • Unlike flat shading, it may use a different shade for each vertex of the polygon • The rendering engine then smoothly interpolates the shade across the surface**It begins by calculating the normal at each vertex – by**calculating the average of normals of neighbouring polygons It then uses the reflection model to calculate intensities to each vertex, then interpolates P2 P3 P1 P5 P4 Gouraud Shading**P3**P3 P2 P2 1- Q Q P P P1 P1 P4 Gouraud Shading • We use linear interpolation to calculate intensity at any point P on the edge IP = (1-) IP1 + IP2 where P divides P1 P2 in the ratio 1- • Similarly for Q using P3 and P4 • Then we do linear interpolation to calculate colour of pixels on scanline PQ**Gouraud Shading Limitations**• With Gouraud shading, as it interpolates light/colour at the vertices, the light intensity far away from the vertices will be quite low and rendered quite dark • The rate of change of pixel intensity is even across any polygon, but not at the boundaries, so we see changes at the polygon edges - known as Mach Bands**Phong Shading**• In Phong shading, the normals themselves are interpolated across the polygon, producing a smoother shading effect, at the cost of much higher rendering time • The normal for each polygon vertex is calculated and for each scan line in the polygon the normal vectors are linearly interpolated at the end points. • The interpolated normal vector is then used in to calculate the intensity for that point • Overcomes some of the disadvantages of Gouraud Shading**P3**P3 P2 P2 N2 N2 N N Q Q P P N1 N1 P1 P1 P4 P4 Phong Shading • In Phongshading, there are three values to interpolate, Nx, Ny and Nz (three components of a normal vector), in contrast to Gouraudshading, which has one value to interpolate • It then applies the Phongreflection model at each pixel to calculate the intensity IRED, IGREEN, IBLUE**Comparison**Geometry Flat Shading Gouraud Shading Phong Shading**Summary**• It is expensive to calculate the intensity at each pixel of a projected polygon, and so there is a family of methods which use interpolation to calculate intermediate values • Flat shading: reflection calculation is carried out once for each polygon, and the polygon is assigned a constant shade according to that calculation • Gouraud shading: an estimate is made of the normal at each vertex of a polygon (for example, by averaging the normals of all surrounding polygons); reflected intensity at each vertex is then calculated; linear interpolation is then used to estimate the intensity at any interior pixel as the shading is carried out • Phong shading: as with Gouraud, normal estimates are made at each vertex; but in contrast, we proceed to interpolate the normals at each pixel and then calculate the intensity for that pixel

More Related