Polygon Rendering - UMD

2y ago
19 Views
2 Downloads
737.75 KB
14 Pages
Last View : 13d ago
Last Download : 3m ago
Upload by : Kaydence Vann
Transcription

Polygon RenderingFlat RenderingGoraud RenderingUses Phong ReflectancePhong Rendering(Many slides adapted from AmitabhVarshney).Flat RenderingOne normal per triangleConstant color per triangleComputed using reflectance model.Best for flat surfaces to give afaceted appearanceAdvantages: simple and fast1

Diffuse Illumination & Flat RenderingImage courtesy, Foley, van Dam, Feiner, HughesGouraud RenderingOne normal per vertexCompute color per vertexInterpolate color per pixel (one addper R, G, B channel)Tolerable results for curvedsurfaces2

Diffuse & Gouraud ShadingImage courtesy, Foley, van Dam, Feiner, HughesSpecular & Gouraud ShadingImage courtesy, Foley, van Dam, Feiner, Hughes3

Phong RenderingOne normal per vertexInterpolate normal per pixelInterpolate each component of normaland then normalizeCompute color per pixelGood for curved and shiny surfacesNot available in OpenGLHow do we interpolate a surface normal? Keep in mind thata normal is a unit vector. We can’t just interpolate the x,y,zcomponents of the normal, because we wind up with a nonunit normal. Here’s a simple example:N1 (0, .436, -.9). N2 (0, -.436,.9)If we take the average of these, we get (0,0,.9), which is nota unit normal. We have to normalize this to get (0,0,1).4

Specular & Phong RenderingImage courtesy, Foley, van Dam, Feiner, HughesGouraud vs. PhongGouraud is fasterInterpolate 1 value instead of 3Don’t need to normalizeDon’t need to render at each point.Phong much more accurateEspecially when lighting effects change rapidlywith surface normal.True for shiny objectsAnd for cast shadows.5

DiscussionLight Source and/or Viewer at infinity simplifiescalculations at the cost of realismNeed to either clamp colors at max value ornormalize them preserving their relative weights(R R/(R G B) , . )OpenGL Support for IlluminationAmbient, Diffuse, Specularilluminations are supportedUsers have to define lightsposition, type, colorUsers also define object materialFront and/or back facing polygons, color6

OpenGL LightsGLfloat lightA position[ ] {1.0, 1.0, 1.0, 0.0};GLfloat lightB position[ ] {1.0, 2.0, 3.0, 1.0};glLightfv(GL LIGHT0, GL POSITION,lightA position);glLightfv(GL LIGHT1, GL POSITION,lightB position);The above defines a directional light source coming from thedirection (1, 1, 1), and a positional light source located at thepoint (1, 2, 3) in the world coordinates.OpenGL LightsOpenGL specifies at least 8 light sourcesGL LIGHT0 . GL LIGHT7To get maximum lights in your implementations use:glGetIntegerv(GL MAX LIGHTS, GLint*num lights);You need to enable each light that you plan to useand enable OpenGL lighting (they are all disabled bydefault):glEnable(GL LIGHT0); glEnable(GL LIGHT1); glEnable(GL LIGHTING);7

glLight*()glLight{if}(GLenum light, GLenum pname, TYPEparam)glLight{if}v(GLenum light, GLenum pname, TYPE*param)light can be GL LIGHT0 . GL LIGHT7pname can be one of following:GL POSITION: light positionGL AMBIENT, GL DIFFUSE, GL SPECULAR : light colorsGL SPOT DIRECTION, GL SPOT EXPONENT,GL SPOT CUTOFF: spotlight parametersGL CONSTANT ATTENUATION,GL LINEAR ATTENUATION,GL QUADRATIC ATTENUATION: parameters for attenuationSpotlightCutoffDirection8

glLight*()GLfloat light0 ambient[ ] {0.0, 0.1, 0.0, 1.0};GLfloat light0 diffuse[ ] {0.0, 0.0, 1.0, 1.0};GLfloat light0 specular[ ] {1.0, 1.0, 1.0, 1.0};GLfloat light0 position[ ] {1.0, 2.0, 3.0, 1.0};glLightfv(GL LIGHT0, GL POSITION, light0 position);glLightfv(GL LIGHT0, GL AMBIENT, light0 ambient);glLightfv(GL LIGHT0, GL DIFFUSE, light0 diffuse);glLightfv(GL LIGHT0, GL SPECULAR,light0 specular);glEnable(GL LIGHT0);glEnable(GL LIGHTING);Object MaterialsObject colors under illumination are computed as acomponent-wise multiplication of the light colors andmaterial colorsJust as light colors are specified differently forambient, diffuse, and specular illuminations, materialcolors are also specified for each of these threeilluminations.In addition to this emissive material color is alsodefined:Lights don’t influence emissive materialEmissive objects don’t add further light to environment9

glMaterial*()glMaterial{if}(GLenum face, GLenum pname, TYPEparam)glMaterial{if}v(GLenum face, GLenum pname, TYPE*param)face can be: GL FRONT, GL BACK, GL FRONT AND BACKpname can be:GL AMBIENT, GL DIFFUSE, GL SPECULAR, GL EMISSION:material colorsGL SHININESS: Specular (Phong) illumination exponentglMaterial*()GLfloat mat0 ambient[ ] {0.2, 0.2, 0.2, 1.0};GLfloat mat0 diffuse[ ] {0.7, 0.0, 0.0, 1.0};GLfloat mat0 specular[ ] {1.0, 1.0, 1.0, 1.0};GLfloat mat0 shininess[ ] {5.0};glMaterialfv(GL FRONT, GL AMBIENT,mat0 ambient);glMaterialfv(GL FRONT, GL DIFFUSE, mat0 diffuse);glMaterialfv(GL FRONT, GL SPECULAR,mat0 specular);glMaterialfv(GL FRONT, GL SHININESS,mat0 shininess);10

glColorMaterial()If only one material property is to be changed, it ismore efficient to use glColorMaterial( )glColorMaterial( ) causes material to trackglColor*( )glEnable(GL COLOR MATERIAL);glColorMaterial(GL FRONT, GL DIFFUSE);glColor3f(0.2, 0.5, 0.8); // this changes the diffuse materialcolorDraw objects hereglColorMaterial(GL FRONT, GL SPECULAR);glColor3f(0.9, 0.0, 0.2); // this changes the specular materialcolorDraw objects hereglDisable(GL COLOR MATERIAL);OpenGL ShadingOpenGL supports flat and Gouraud shading.No support for Phong shading yet.glShadeModel(GL FLAT)Flat shadingglShadeModel(GL SMOOTH)Gouraud shadingRemember to supply normals with triangles orvertices to get correct lighting and shading11

Phong Shading with SpecularIlluminationImage courtesy, Foley, van Dam, Feiner, HughesPhong Shading SpecularIllum. on Curved SurfacesImage courtesy, Foley, van Dam, Feiner, Hughes12

More and Better LightsImage courtesy, Foley, van Dam, Feiner, HughesImage TexturesImage courtesy, Foley, van Dam, Feiner, Hughes13

Displacement Textures ShadowsImage courtesy, Foley, van Dam, Feiner, Hughes14

Flat Rendering Goraud Rendering Uses Phong Reflectance Phong Rendering (Many slides adapted from Amitabh . Gouraud vs. Phong Gouraud is faster Interpolate 1 value instead of 3 . And for cast shadows. 6 Discussion Light Source and/or Viewer at infinity simplifies calculations at the cost of realism

Related Documents:

1. Tell whether the figure is a polygon. If it is a polygon, name it by the number of its sides. a. polygon, decagon b. polygon, hexagon c. polygon, dodecagon d. not a polygon of the polygon. Find m2. Tell whether the polygon is regular or irregular. Tell whether it is concave or convex. c. a. regular and concave b. irregular and concave

symbols palette, and using one of the polygon drawing tools, which are Draw Freehand Polygon, Draw Polygon, Draw Auto-Complete Freehand Polygon, Draw Auto-Complete Polygon, Draw Circle, Draw Ellipse, and Draw Rectangle tool. Follow the steps below to create some polygon features in the study area. 1.

Name the polygon. Then use the markings on the figure to tell whether it is a regular polygon or not a regular polygon. a. Name the polygon. _ b. Are all the sides and all the angles congruent? _ c. Is the polygon a regular polygon? _ Share and Show Try This! Label the Venn diagram

Number of sides Polygon type 7 5 Heptagon Pentagon 6 Hexagon Octagon Nanogon Heptagon Hexagon Decagon Octagon 7 6 8 4 9 10 8 Quadrilateral. Name : Printable Math Worksheets @ www.mathworksheets4kids.com Polygon - Types Regular: S2 1) Number of sides Polygon type 2) Number of sides Polygon type 3) Number of sides Polygon type 4)

congruent and all angles are congruent. Classify the polygon below. How many sides does this polygon have? How many angles does this polygon have? Name the polygon. Are all the sides congruent? Are all the angles congruent? So, the polygon above is a pentagon. It is not a regular polygon. Name each

GEOMETRY HONORS: SEMESTER 2 FINALS REVIEW PACKET 1. Tell whether the figure is a polygon. If it is a polygon, name it by the number of sides. a. b. c. 2. For a polygon to be regular, it must be both equiangular and equilateral. Name the only type of polygon that MUST be regular if it is equiangular. 3. Tell whether each polygon is regular or .

An n-gon is a polygon with n sides. A regular polygon is a polygon with all sides equal to one another and all angles equal to one another. Instructor Page Polygon Name of Polygon Number of Sides Number of Angles Measurement of an Interior angle Sum of Inte

How many vertices does it have? (A diagonal is a line segment that connects two non-adjacent vertices of a polygon). 2. The exterior angle to a regular polygon N (with N sides) is half that of a regular polygon M (with M sides). Polygon N has 7 times as many diagonals as polygon M. What is the value of ? 3. Tom stands exactly 2 miles west .