shading & texture. shading flat shading the process of assigning colors to pixels. smooth shading...

Download Shading & Texture. Shading Flat Shading The process of assigning colors to pixels. Smooth Shading Gouraud ShadingPhong Shading Shading

Post on 30-Dec-2015




0 download

Embed Size (px)


Slide 1

Shading & TextureShadingFlat ShadingThe process of assigning colors to pixels.Smooth ShadingGouraud ShadingPhong ShadingShadingShading ModelFlat ShadingCompute Phong lighting once for entire polygonGouraud ShadingCompute Phong lighting at the vertices and interpolate lighting values across polygonPhong ShadingInterpolate normals across polygon and perform Phong lighting across polygonFlat ShadingFor each polygon Determines a single intensity value at a chosen point on the polygon. Uses that value to shade the entire polygon.

AssumptionsLight source at infinityViewer at infinityOnly ambient light is present

Problems of Flat ShadingSpecular highlights tends to get lostIf chosen point on polygon is at location of the light soure, then color of the polygon will be significantly distortes.Flat Shading

Smooth ShadingIntroduce vertex normals at eachvertexUsually different from facet normalUsed only for shadingThink of as a better approximation of the real surface that the polygons approximateFinds color value for each point in the polygon individually.Two typesGouraud ShadingPhong Shading (do not confuse with Phong Lighting Model)

Gouraud ShadingThis is the most common approachPerform Phong lighting at the verticesLinearly interpolate the resulting colors over facesAlong edgesAlong scanline

7Gouraud Shadingxrightysytopybottxleftcolor1color2color3color4y4

Gouraud Shadingxrightysytopybottxleftcolor1color2color3color4y4

Calculate the surface normals along the scan line and the edge using incremental approach

YsFlat vs Gouraud ShadingImages in left column are shaded using Flat Shading Images in right column are shaded using Gouraud Shading

Problem of Gouraud ShadingGood for diffuse reflectionBut lacks accurate specular component for bigger surface

C1C2C3Cant shade the specular reflectionPhong Shadingxysm1m2m3m4mleftmrightmxInterpolate normal vectors of face vertices at each pixel, then perform phong lighting at each pixel.mleft = m1 + (m4-m1)ys - y1Y4 - y1mright = m1 + (m2-m1)ys - y1Y2 - y1mx= mleft + (mright -mleft)x - xleftx right - xleftCalculate the surface normals along the scan line and the edge using incremental approach

If a highlight does not fall on a vertex Gouraud shading may miss it completely, but Phong shading does not.Phong vs Gouraud ShadingPhong Shading is more smooth.TextureTextureTexture TypesBitmap textures: Using some image fileProcedural textures: Changing pixel intensity in some controlled fashion without using external image source

Texture(s, t): produces a color or intensity value for each value of s and t between 0 and 1.TextureBitmap textures: Using some image file having dimension CxR presented as txtr[c][r] 0