LIGHTING 1
OUTLINE Review – Factors affecting light • • Review – Types of lights Materials • • Lighting Computations Implementing Lighting • • Gouraud Shading Phong Shading • • Blinn-Phong Shading Combining Light and Texture • 2
FACTORS AFFECTING LIGHT • Type of light source Ambient, diffuse and specular components • • Object material Ambient, diffuse and specular characteristics • • Object’s shininess Angle at which light hits object • • Angle of incidence Angle from which object is viewed •
TYPES OF LIGHTS • Global “Global ambient” • • Only includes an ambient component Directional (or distant) • • No location, only a direction Positional (point source) • • Location and direction May include attenuation factors • • Spotlight Location, direction, cutoff and exponent (intensity factor) •
POSITIONAL AND SPOTLIGHT ATTENUATION
SPOTLIGHT
MATERIALS • Ambient, diffuse and specular characteristics One each for R, G, B • • Shininess coefficient Transparency • • Emissiveness • graphicsLib3D includes predefined materials of GOLD, SILVER and BRONZE e.g.: graphicsLib3D.Materials.BRONZE •
LIGHTING COMPUTATIONS
LIGHTING - DIFFUSE
LIGHTING - SPECULAR
SHININESS COEFFICIENT (N IN PREVIOUS SLIDE)
FACETED SHADING
GOURAUD SHADING • Determine the lighting/color at each vertex Interpolate between vertices • • Using the normal rasterization process • Means that lighting will be done in the vertex shader
PHONG SHADING • Shading done per pixel instead of per vertex Normal and light vectors calculated in vertex shader • • Interpolation done per pixel in the fragment shader
PHONG SHADING • Normals get interpolated instead of just colors
PHONG SHADING • Drawback is that it is expensive to calculate
BLINN-PHONG SHADING • Instead of calculating R, use L + V to calculate H Angle α not exactly the same as ψ , but gives very similar results •
BLINN-PHONG LIGHTING
EXTERNAL MODELS AND PHONG LIGHTING Both use Phong lighting • • Stanford dragon has over 800,000 triangles
COMBINING LIGHT AND TEXTURE • If only a texture (no material): fragColor = textureColor * • (ambientLight + diffuseLight) + specularLight • If both texture and material: fragColor = textureColor * • (ambientLight + diffuseLight + specularLight) Can use weighted sum when there are • multiple lights and/or textures
SUMMARY Review – Factors affecting light • • Review – Types of lights Materials • • Lighting Computations Implementing Lighting • • Gouraud Shading Phong Shading • • Blinn-Phong Shading Combining Light and Texture • 23
Recommend
More recommend