CG Unit - 4
CG Unit - 4
Illumination model, also known as Shading model or Lighting model, is used to calculate
the intensity of light that is reflected at a given point on surface. There are three factors on
which lighting effect depends on:
• Light Source : Light source is the light emitting source. There are three types of light
sources: Their position, electromagnetic spectrum and shape determine the lighting
effect.
Point Sources – The source that emit rays in all directions (A bulb in a room).
Parallel Sources – Can be considered as a point source which is far from the
surface (The sun).
Distributed Sources – Rays originate from a finite area (A tubelight).
Illumination models :
• Surface : When light falls on a surface part of it is reflected and part of it is absorbed.
Now the surface structure decides the amount of reflection and absorption of light. The
position of the surface and positions of all the nearby surfaces also determine the lighting
effect.
• Observer : The observer’s position and sensor spectrum sensitivities also affect the
lighting effect
Ambient Illumination :
Assume you are standing on a road, facing a building with glass exterior and sun rays are
falling on that building reflecting back from it and the falling on the object under
observation. This would be Ambient Illumination, In simple words, Ambient Illumination is
the one where source of light is indirect. The reflected intensity Iamb of any point on the
surface is:
Diffuse Reflection :
Diffuse reflection occurs on the surfaces which are rough or grainy. In this reflection the
brightness of a point depends upon the angle made by the light source and the surface. The
reflected intensity Idiff of a point on the surface is:
Specular Reflection :
When light falls on any shiny or glossy surface most of it is reflected back, such reflection
is known as Specular Reflection. Phong Model is an empirical model for Specular
Reflection which provides us with the formula for calculation the reflected intensity I spec.
Phong Model of Reflection :
• A Shiny surface has a narrow specular reflection range, while a dull surface has a
wider reflection range.
• An empirical model for calculating the specular reflection range, invented by the
Phong Bui Tuong is also known as Phong specular reflection model.
• This model sets the intensity of specular reflection directly proportional to
the cosns(∅).
Phong Model of Reflection :
• We can control the intensity variation of the light through, specular-reflection, using
spectral-reflection function W(∅) for each surface.
• Where ∅ the value lies in the range of 0 ≤ ∅ ≤ 1. In general W(∅) tend to increase as the
angle of incidence increases, at ∅=90* W(90*)=1, and in this case, all the light incidents
on the surface of the material is reflected.
• So, using the spectral-reflection function W(∅) we can write the Phong specular reflection
model as :
Phong Model of Reflection :
What are Color Modes?
Imagine yourself painting a vibrant sunset. Would you use the same set of paints on a
canvas as you would on a digital screen? The answer lies in the fascinating world of color
modes, the unsung heroes that ensure colors translate seamlessly across different mediums.
But what exactly are color modes? In essence, they’re like different languages that colors
speak, influencing how they appear and function depending on the platform or material.
Each mode has its unique characteristics, opening up a kaleidoscope of possibilities for
designers.
Types of Color Modes :
4. Grayscale:
• The timeless minimalist, focusing on tonal variations (from black to white), perfect for:
• Classic photography and artwork: Creating mood and evoking timeless elegance.
• Logos and minimalist designs: Delivering a sophisticated and focused visual impact.
Types of Color Modes :
5. Bitmap:
• The pixelated pioneer, using individual colored pixels to construct images. While limited
in detail, it’s:
• Essential for retro-inspired designs: Evoking nostalgia and pixel art aesthetics.
• Used in early computer graphics and simple platforms: Maintaining compatibility with
older systems.
Types of Color Modes :
6. Indexed:
• The web-savvy optimizer, offering a limited palette (256 colors) but significantly
reducing file size, making it ideal for:
• Web graphics and animations: Maintaining essential visual elements while ensuring fast
loading times.
• Logos and icons: Preserving clarity and brand recognition on web platforms.
Uses
RGB: Websites, apps, games, digital art, photography, animation. (Brings digital
experiences to life with stunning and diverse color palettes.)
LAB: Color correction, multi-platform design, color theory applications. (Simplifies color
management across different media while maintaining visual harmony.)
Grayscale: Photography, logos, minimalist design, editorial, art posters. (Adds timeless
elegance and focuses on form and composition in various design projects.)
Bitmap: Retro design, pixel art, game development, early computer graphics. (Offers
unique aesthetics for specific design styles, evoking nostalgia or replicating early digital
visuals.)
Indexed: Web graphics, animations, logos, icons, email marketing visuals. (Optimizes file
size for fast web loading while maintaining essential visual elements.)
Benefits
RGB: Vibrant colors, vast gamut. (Offers unmatched color range for displaying stunning
visuals on digital screens.)
CMYK: Faithful color reproduction for print. (Guarantees brand consistency and accurate
color representation in printed materials.)
LAB: Consistent color perception across media. (Simplifies color management and ensures
consistent visual experience across different platforms.)
Grayscale: Timeless elegance, focus on form. (Enhances sophistication and emphasizes
composition in various design applications.)
Bitmap: Unique aesthetics, efficient for specific styles. (Provides distinct visual appeal for
retro designs, pixel art, and early computer graphics.)
Indexed: Smaller file size, faster loading times. (Optimizes web graphics and animations
for efficient performance and improved user experience.)
Limitations of Color Modes
RGB: Not ideal for print, colors can shift. (Colors might not translate accurately to printed
materials due to different color mixing methods.)
CMYK: Limited gamut compared to RGB. (Offers a smaller range of colors compared to
digital displays, potentially restricting creative freedom.)
LAB: Complex to use, not always necessary. (Requires advanced understanding and might
be overkill for simple design projects.)
Grayscale: Limited color expression. (Restricts design possibilities due to the absence of
color, not suitable for all projects.)
Bitmap: Low detail, not suitable for complex visuals. (Limited resolution and detail might
not be suitable for showcasing intricate graphics or photographs.)
Indexed: Limited color palette. (Restricts creative freedom by providing a smaller range
of colors to work with.)
CIE Chromaticity Diagram :
The chromaticity diagram represents the spectral colours and their mixtures based on the
values of the primary colours(i.e Red, Green, Blue) contained by them. Chromaticity
contains two parameters i.e, hue and saturation. When we put hue and saturation together
then it is known as Chrominance.
CIE Chromaticity Diagram :
CIE Chromaticity Diagram :
Chromaticity diagram represents visible colours using X and Y as horizontal and vertical
axis. The various saturated pure spectral colours are represented along the perimeter of the
curve representing the three primary colours – red, green and blue. Point C marked in
chromaticity diagram represents a particular white light formed by combining colours
having wavelength :
RED: 700 nm
GREEN : 546.1 nm
BLUE: 438.8 nm
In Chromaticity diagram colours on boundary are completely saturated. The corners in this
chromaticity diagram represents by three primary colours (Red, Green and Blue).
C.I.E. Color Space :
It uses combination of 3 color values that are close to red, green and blue values which are
plotted on a 3D space. Mapped physical wavelengths to perceived colors. It is used to
identify the relative similarity and differences between colors. It is used to represents the
wide range of colors.
Here,
X: Perceived color
Y: Perceived luminance
Z:Perceived color
Advantages:
• Simple geometric construction for mixing two or more colours.
• Both Perceptual attributes used: hue and saturation.
C.I.E. Color Space :
Advantages:
• Simple geometric construction for mixing two or more colours.
• Both Perceptual attributes used: hue and saturation.
Constant-Intensity Shading :
• In computer graphics shading is referred to as the process of altering the color of an object
in the 3D scene based on the surface angle to lights, its distance from the light, and the
material properties. Constant intensity is also known as flat shading.
• This is the most simple and very fast method to specify a color of an object. Flat shading
of a polygon assumes that each polygon is strictly planar and all the points on the polygon
have exactly the same blind light treatment. In this method, a single intensity is calculated
for each polygon.
• This technique thus displays all the points in a polygon with a single color. In this method,
the main idea is that we use only one surface normal per polygon.
Constant-Intensity Shading :
• In general, flat shading of polygon facets provides an accurate rendering for an object if
all the following are valid:
• The object is a polyhedron and is not an approximation of an object with a curved surface.
• Light sources illuminating the objects are sufficiently far from the surface so that the unit
is normal to a surface; unit direction vector to the point light source from a position on a
surface and attenuation is constant over the surface.
• the vector position is sufficiently far from the surface so that the unit vector pointer to the
viewer from the surface position, a unit vector in the diversion of ideal specular reflection
is constant over a surface.
Constant-Intensity Shading :
Advantage:
• Constant shading can be useful for quickly displaying the general appearance of a curved
surface.
Constant-Intensity Shading :
Disadvantage:
• One of the disadvantages of constant-intensity shading is a very poor display of polygon-
mesh approximations to curved surfaces.
Gouraud Shading :
• Gouraud shading is a method used in computer graphics to simulate the differing effect
of light and color across the surface of an object. Intensity- interpolation is used to
develop Gouraud shading.
• By intensity interpolation, the intensity of each and every pixel is calculated. Gouraud
shading shades a polygon by linearly interpolating intensity values across the surface. By
this, if we know the intensities of two points then we can able to find the intensity of any
point in between them.
• By Gouraud shading, we can overcome the discontinue intensity values for each polygon
that are matched with the values of adjacent polygons along the common edges.
Each polygon surface is rendered with Gouraud shading by performing the following
calculations.
• The first step is to determine the average normal vector as add a polygon vertex.
Determining the average unit normal vertex at each polygon vertex.
Gouraud Shading :
Calculating the average unit normal vector at point p. Point p is attached with four polygons.
So, the average unit normal vector = N1+N2+N3+N4/|N1+N2+N3+N4|
for n polygons —-> summation of k Nk / | summation of k Nk | (where k is initialized
from 1 to N)
• Applying an illumination model at each vertex to calculate vertex intensity.
• In computer graphics, we use an illumination model to calculate vertex intensity at each
vertex.
• Linearly interpolated the vertex intensities over the surface of the polygon for each
scanline the intensity at the intersection with a polygon edge is linearly interpolated.
Gouraud Shading :
I1 intensity at vertex 1
I2 intensity at vertex 2
I3 intensity at vertex 3
I4 intensity at vertex 4
I5 intensity at vertex 5
Gouraud Shading :
Similar calculations are used to obtain intensities at successive horizontal pixel positions
along each scan line. Incremental interpolation of intensity value along a polygon edge for
successive scan line:
When the surfaces are to be rendered in color, the intensities of each color component are
calculated at the vertices. Gouraud can be connected with a hidden surface algorithm to fill
in the visible polygons along each scan line.
Gouraud Shading :
Advantages :
• Gouraud shading discards the intensity discontinuities associated with the constant
shading model.
• Linear intensity interpolation can cause bright or dark intensity streaks, called match
bands, to appear on the surface.
• The match band effect can decrease by dividing the surface into a higher no of polygon
faces or by using other methods such as Phong shading which requires more calculations
.
Gouraud Shading :
Disadvantages :
• Highlights on the surface are sometimes displayed with anomalous shapes.
• The linear intensity interpolation can result bright or dark intensity streaks to appear on
the surface. These bright or dark intensity streaks, are called Mach bands. The mach
band effect can be reduced by breaking the surface into a greater number of smaller
polygons.
• Sharp drop of intensity values on the polygon surface can not be displayed.
How to Design Phong Shading :
Phong Shading Algorithm: There are three distinct components involved in Phong
Shading:
• Ambient: This component approximates light coming from a surface due to all the non-
directional ambient light that is in the environment.
• Diffuse: This component approximates light, originally from light source, reflecting
from a surface which is diffuse or non glossy.
Visual Illustration of Phong Shading: Here the light is white with position x=1, y
=1, z=-1. The ambient and diffuse component colors are both purple, the specular color is
white which is reflecting a small part of the light hitting the surface of the object in
narrow highlights. The intensity of the diffuse component varies with the direction of the
surface and due to different light positions. The ambient component is uniformly shaded.