Computer Graphics Material Colours and Lighting - PowerPoint PPT Presentation

1 / 15
About This Presentation
Title:

Computer Graphics Material Colours and Lighting

Description:

Another key light effect is specular lighting ... Can use different light colours for calculating diffuse and specular to get nicest result ... – PowerPoint PPT presentation

Number of Views:91
Avg rating:3.0/5.0
Slides: 16
Provided by: lauren80
Category:

less

Transcript and Presenter's Notes

Title: Computer Graphics Material Colours and Lighting


1
Computer GraphicsMaterial Colours and Lighting
  • CO2409 Computer Graphics
  • Week 11

2
Lecture Contents
  • Materials
  • Shading
  • Lighting
  • Light Types
  • Light Models
  • Applying Lighting

3
Materials
  • A material defines the surface properties of a
    polygon
  • Colour, shininess, texture, bumpiness,
    transparency, etc.
  • This lecture only concerns material colours
  • Face colours
  • Each polygon has a single colour
  • Vertex colours
  • Each vertex has a colour
  • The colour is blended across the polygon using
    the nearest vertex colours

4
Shading
  • Two shading methods for material colours
  • Flat shading
  • Polygon vertices have same colour
  • The polygon appears flat
  • Gouraud shading
  • Polygon vertices - different colours
  • Pixel colours are a linear blend of the vertex
    colours
  • Blended or curved looking surface
  • Flat shading only useful for very simple models
  • Gouraud shading is better, but still simplistic
    alone
  • Lighting / textures provide improvements

5
Lighting
  • Can improve realism of scenes by using lighting
  • To help calculate the vertex / face colours
  • Previous examples have assumed constant white
    light everywhere
  • so everything is perfectly clear
  • Lights can make a huge difference to the look of
    a scene
  • Even with simple models
  • Several types of light
  • Several ways to model the interaction of light
    with surfaces

6
Light Types Directional / Point
  • Three main types of light
  • Directional Lights
  • Considered to be infinitely far away
  • All the light comes from the same direction
  • No attenuation (see later)
  • Sunlight is the main example
  • Point Lights
  • Light emitting in all directions from a single
    point
  • Light attenuates with distance
  • A light bulb is a good example

7
Light Types Spotlights
  • Spotlights are more complex
  • Like point lights
  • Light emitting from single point
  • Light attenuates with distance
  • But also
  • Light is constrained to a cone
  • Only emits in the direction bounded by the cone
  • Brightest at centre of the cone
  • Less bright towards the edges

8
Light Attenuation
  • The light emitted from point lights and
    spotlights attenuates over distance
  • Is diffused (i.e. scattered) by the air
  • Light from a distant source is weaker than that
    from a near source
  • Typically assume that the light intensity is in
    inverse proportion to distance
  • Attenuated Light Light / Distance
  • The following lighting equations assume we have
    calculated this attenuation

9
Light Models Ambient Lighting
  • The most basic lighting effect is Ambient Light
  • A constant level of light, lighting everything
    evenly
  • An approximation to the complex light
    interactions between surfaces in a scene
  • Gives a general background ambience.
  • Set to a constant colour for an entire scene
  • Or add an ambient colour for each light
  • Call the ambient level AmbL

10
Diffuse Lighting
  • Diffuse Lighting affects vertices that point
    towards the light source
  • The diffuse light hitting a vertex is calculated
    using a dot product
  • Diffuse max(0, DiffL N L)
  • DiffL is the light colour
  • N is the vertex normal
  • L is a normal pointing from the vertex to the
    light
  • DiffL if normal points directly at the light
  • 0 if it points away

11
Specular Lighting
  • Another key light effect is specular lighting
  • Treats the surface as reflective resulting in a
    reflection of the light source becoming visible
  • The reflection is called a highlight
  • On a shiny surface highlights are sharp and
    bright
  • The surface is smooth, so the reflection is
    focused
  • Rougher surfaces have wider and softer highlights
  • The rough surface diffuses the reflection more

12
Specular Lighting - Phong
  • Several mathematical models for specular light
  • The Phong model is commonly supported in hardware
  • The Phong specular calculation for each vertex
    is
  • Specular max(0, SpecL(N H)P )
  • SpecL is the light colour
  • Can use different light colours for calculating
    diffuse and specular to get nicest result
  • N is the vertex normal
  • H is the halfway normal
  • Described on the diagram
  • p is the specular power
  • A measure of shininess

13
Applying Lighting
  • Light hitting a vertex is the sum of the three
    effects
  • Incident Light AmbL max(0, DiffL N L)
  • max(0,
    SpecL(N H)P )
  • Combine with material colour for final pixel
    colour
  • Colour ColourM (AmbL max(0, DiffL N L)

  • max(0, SpecL(N H)P ))
  • Can specify three material colours rather than
    one
  • One for each lighting effect
  • Colour AmbM AmbL DiffM max(0, DiffL N L)
  • SpecM
    max(0, SpecL(N H)P )

14
Blending with Vertex Colours
  • The final effect on a sphere
  • Using typical material colours
  • AmbM DiffM Red
  • Basic sphere colour
  • SpecM White
  • The specular light is reflected without tint
    (colour of the light)
  • Note that the calculation is performed separately
    for the red, green and blue components
  • If there are several lights then
  • Accumulate the incident light for all of them
  • Then combine with the material colours

15
Programming Lighting
  • These equations can be calculated by the API
    (fixed pipeline) or in a shader (programmable)
  • Need to set up
  • Light types, positions, directions, attenuation
    etc.
  • Material colours (if used)
  • Fixed pipeline calculates equations automatically
  • We must program them explicitly for a shader
  • The given Phong equations are not physically
    accurate, just approximations to reality
  • Other lighting models are available
  • E.g. look at available materials in Maya
  • Cant use alternatives in fixed pipeline, only
    with shaders
Write a Comment
User Comments (0)
About PowerShow.com