Upload
myrtle-ferguson
View
241
Download
0
Tags:
Embed Size (px)
Citation preview
Introduction to Computer Graphics
Illumination modelsPramod Merugu
U91656461
EEL 5771-001
Light sources
• Light source: The object that radiates energy
e.g.Sun, lamp, globe, sky…
Intensity I = (Ired , Igreen , Iblue)
If Ired = Igreen = Iblue : white light
• Point light source• Infinitely distant light sources• Directional light sources
Point light source
• A point source is the simplest model we can use for a light source
• We simply define:– The position of the light– The RGB values for the colour of the light
• Light is emitted in all directions• Useful for small light sources
Infinitely distant light sources
• A large light source, like the sun, can be modelled as a point light source with direction V and intensity I
• However, it will have very little directional effect radial intensity attenuation is not used
Directional light sources
• To turn a point light source into a spotlight we simply add a vector direction and an angular limit θl
Damping: intensity of light decreases with distance
Energy is distributed over area sphere, hence
Il = I / d2,
with d distance to light source.
In practice often too ‘aggressive’,
hence Il = I / (a0 +a1d+a2d2)
If light source at infinity: No damping with distance
Directed light source, spotlight:
Directed light source, spotlight:
Light is primarily send in direction of Vlight .
PQ
d.illuminate is then cos||
If
:Or d.illuminate is then coscos If
llight
l
QVPQ
PQ
Q
l
light cone
a
Vlight
• More subtle: Let I decrease with increasing angle a.
decreases.light hestronger t the,larger The
. cos:usedOften
n
II nl
PQ
la
Vlight
light cone
Lighting and shading
• Those Were the Days……...• “In trying to improve the quality of the synthetic images, we
do not expect to be able to display the object exactly as it would appear in reality, with texture, overcast shadows, etc. We hope only to display an image that approximates the real object closely enough to provide a certain degree of realism.”
– Bui Tuong Phong, 1975• Lighting designates the interaction between materials and light
sources. The process of computing the illuminious intensity at a particular 3D point
• Shading is the process of determining the color of a pixel
Lighting Models
– Lambert.• Purely diffuse surfaces.
– Phong.• Adds perceptually-based specular term.
– Torrance-sparrow:• Provides a physical approximation.
Lambert’s Cosine Law
• The reflected luminous intensity in any direction from a perfectly diffusing surface varies as the cosine of the angle between the direction of incident light and the normal vector of the surface.
• Intuitively: cross-sectional area of the “beam” intersecting an elementof surface area is smaller for greater angles with the normal.
Lambert’s Cosine Law• Lambert's cosine law says that the radiant
intensity or luminous intensity observed from an ideal diffusely reflecting surface or ideal diffuse radiator is directly proportional to the cosine of the angle θ between the direction of the incident light and the surface normal.
• Ideally diffuse surfaces obey cosine law.– Often called Lambertian surfaces.
• Id = kd Iincident cos = kd Iincident (N·L).
– kd is the diffuse reflectanceof the material.
• Wavelength dependent, so usually specified as a color.
IN
Phong Lighting Model
• Phong adds Specular highlights.• His original formula for the Specular term:
– W(i)[cos s ]n
• s is the angle between the view and Specular reflection directions.
• “W(i) is a function which gives the ratio of the Specular reflected light and the incident light as a function of the incident angle i.”
– Ranges from 10 to 80 percent.• “n is a power which models the Specular reflected light
for each material.”– Ranges from 1 to 10
• More recent formulations are slightly different.– Replace W(i) with a constant ks, independent of the incident
direction.• What do we lose when we do this?
– Is= ks Iincident cosn= ks Iincident (V·R)n.
• V is the view direction.• R is the specular reflection direction.
Blinn- Phong Model
• Popular variation of Phong model.• Uses the halfway vector, H.• Is = ks Iincident (N·H)n.
– H = L+V / | L+V |• Popular variation of Phong model.• Uses the halfway vector, H.• Is = ks Iincident (N·H)n.
– H = L+V / | L+V |
• Faster to compute than reflection vector.• Still view-dependent since H depends on V.
LN
HV
Torrance-Sparrow Model• Introduced by Torrance and Sparrow in 1967 as a theoretical
model.Introduced to CG community by Blinn in 1977.– same paper as “Halfway Vector” (Blinn-Phong).
• Attempts to provide a more physical model for specular reflections from real surfaces.– Points out that intensity of specular highlights is dependent
on the incident direction relative to normal.– Phong attempted to model this with w(i) factor?
• Back to micro facets. • Assumptions:
– Diffuse component comes from multiple reflections between facets and from internal scattering.
– Specular component of surface comes from facets oriented in direction of H.
• Is = DGF / (N·V)
– D is the distribution function of the micro facet directions on the surface.
– G is the amount that facets shadow and mask each other.– F is the Fresnel reflection law.
D: Micro Facet Distribution• T-S used simple Gaussian distribution:
– D = e -()2
– = deviation angle from halfway vector, H.– = standard deviation.
• Large values = dull, small values = shiny
Denominator• Intensity proportional to number of facets in H direction.
– So, must account for fact that observer sees more surface area when surface is tilted.
• Change in area proportional to cosine of tilt angle.– Hence, N·V in denominator.
G: Geometrical Attenuation Factor
• Remember micro facet shadowing and masking?
• Blinn derives this factor for symmetrical v-shaped groove facets.
shadow shadowMasked Light
F: Fresnel Reflection
• Fraction of light incident on a facet that is actually reflected rather than absorbed.
• Function of angle of incidence and index of refraction.– F(, ).– For metals (large ), F(, ) nearly constant at 1.– For non-metals (small ), F(, ) has exponential
appearance. Near zero for = 0, to 1 at = / 2.
Rendering• Rendering is the process of generating an image from a 2D or 3D model
by means of computer programs. Also, the results of such a model can be called a rendering. A scene file contains objects in a strictly defined language or data structure it would contain geometry, viewpoint, texture, lighting, and shading information as a description of the virtual scene.
• This makes the scene to look relatively realistic and predictable under virtual lighting.
• Natural processes , different patterns and all the dramatic effects with the overtime can be done by using rendering.
Approaching photorealism
• Pixar-quality cartoon rendering in real-time is also on its way. In 2012, Unity Technologies revealed The Butterfly Effect, a short film running in real-time in the Unity engine with Nvidia GPUs. Using techniques traditionally reserved for offline rendering, its visual quality is hard to distinguish from the work being produced by Hollywood CG studios.
An image created by using POV-Ray3.6
Two components of light source
• Light Source Properties– Color (Wavelength(s) of light)– Shape– Direction
• Object Properties– Material– Geometry– Absorption
Contributions from lights
• Contribution that a light has on the surface, regardless of viewing direction.
• Diffuse surfaces, on a microscopic level, are very rough. This means that a ray of light coming in has an equal chance of being reflected in any direction.
• We will breakdown what a light does to an object into three different components. This APPROXIMATES what a light does. To actually compute the rays is too expensive to do in real-time.– Light at a pixel from a light = Ambient + Diffuse +
Specular contributions.– Ilight = Iambient + Idiffuse + Ispecular
Ambient Term - Background Light
• It represents the approximate contribution of the light to the general scene, regardless of location of light and object
• Indirect reflections that are too complex to completely and accurately compute
• Iambient = color
Attenuation
• Radial intensity attenuation• Angular intensity attenuation
Radial Intensity attenuation
• As light moves from a light source its intensity diminished• At any distance dl away from the light source the intensity
diminishes by a factor of • However, using the factor does not produce very good
results so we use something different• We use instead in inverse quadratic function of the form
• where the coefficients a0, a1, and a2 can be varied to produce optimal results
2210
1)(
ll
lradattendadaa
df
Angular intensity attenuation•We can denote Vlight as the unit vector in the direction of the light and Vobj as the unit vector from the light source to an object. The dot-product of these two vectors gives us the angle between them. If this angle is inside the light’s angular limit then the object is within the spotlight.•As well as light intensity decreasing as we move away from a light source, it also decreases angularly. A commonly used function for calculating angular attenuation is: where the attenuation exponent al is assigned some positive value and angle is measured from the cone axis
laangattenf cos)(
0
Spotlights
• A spotlight is a light source which has a cone of effect, eg. a desk lamp or a torch.
• Like a directional light, it has a basic direction, but it also has a defined conic volume in which its light can fall. The angle of the cone determines how much of the scene is illuminated.
• Spotlights can also have a drop-off rate; this is the degree to which light nearer the edge of the cone becomes less and less bright compared to light at the center.
• Pointlights and spotlights are local light sources, ie. they are usually close to the observer
Multiple lights in a scene
• The image shows the effect of multiple lights in a scene. The landscape now includes:
--a red spotlight, positioned as above but only emitting red light (thus, it does not affect the mainly blue and green low-lying aspects of the scene)
--a green point light, positioned as above
--a blue directional light, aimed towards the far left of the scene.
Flaps and cones
• To restrict lights to a limited area of scene, Warn implemented flaps and cones.
• Flaps are the professional photographic lights confine the lights to a desired range in x, y and Z.
• Each light has six flaps corresponding to min and max value and also has a flag to indicate on or off state.
• If the point coordinates are with in range specified by min and max coordinates of those that are on.
a. Use of X flaps in situation, Y can also restrict the light in a way that has no physical
counterpart
b. Cone with a generating angle Delta to restrict the light sourse effect
Illumination modelsColor of an object
Rendering without global illumination. Areas that lie outside of the ceiling lamp's direct light lack definition. For example, the lamp's housing appears completely uniform. Without the ambient light added into the render, it would appear uniformly black.
Rendering with global illumination. Light is reflected by surfaces, and colored light transfers from one surface to another. Notice how color from the red wall and green wall (not visible) reflects onto other surfaces in the scene. Also notable is the caustic projected onto the red wall from light passing through the glass sphere.
• So…given a 3-D triangle and a 3-D viewpoint, we can set the right pixels But what color should those pixels be? If we’re � �attempting to create a realistic image, we need to simulate the lighting of the surfaces in the scene - Fundamentally simulation of physics and optics.
• Illumination : Global illumination or indirect illumination is a general name for a group of algorithms used in 3D computer graphics that are meant to add more realistic lighting to 3D scenes.
• This illumination makes images more photorealistic.• Illumination of a scene is computed and the information is
stored with the radiocity. That stored data can then be used to generate images from different viewpoints for generating walkthroughs of a scene without having to go through expensive lighting calculations repeatedly
Ambient occlusion Example for global illumination
• Ambient occlusion is a shading and rendering technique used to calculate how exposed each point in a scene is to ambient lighting.
• Ambient occlusion can be seen as an accessibility value that is calculated for each surface point
• Ambient occlusion can be calculated as the occlusion at a point on a surface with normal can be computed by integrating the visibility function over the hemisphere with respect to projected solid angle:
• It is a technique to produce film like lightening quality with real time performance. It calculates the brightness of a pixel in relation to nearby objects in the scene.
With ambient occlusion and with out ambient occlusion
•Using AO the smooth shadows have been added to the image. Unlike standard shadows which appears as a solid region enclosed by blurred edges, AO based shadows have wide and smooth radiations.•Here GI calculates the color of each pixel based on the light contributed fromthe surrounding hemisphere.•The end result after a large number of raytracing operations and the AO makes the images softly lit and shadowy images with a global illumination look and the real time feel
With out ambient occlusion With ambient occlusion
Mechanisms of Refection
• Body reflection-Diffuse reflection• Surface reflection
-Specular reflection
source
surfacereflection
surface
incidentdirection
bodyreflection
Image Intensity = Body Reflection + Surface Reflection
viewingdirection
surfaceelement
normalincidentdirection
in
v
s
d
rriif ),;,(• Lambertian BRDF is simply a constant :
• Surface appears equally bright from ALL directions! (independent of )
• Surface Radiance :
v
• Commonly used in Vision and Graphics!
snIIL di
d .cos
source intensity
source intensity I
Diffuse Reflection
White-out: Snow and Overcast Skies
CAN’T perceive the shape of the snow covered terrain!
CAN perceive shape in regions lit by the street lamp!!
WHY?
Diffuse Reflection from Uniform Sky
• Assume Lambertian Surface with Albedo = 1 (no absorption)
• Assume Sky radiance is constant
• Substituting in above Equation:
Radiance of any patch is the same as Sky radiance !! (white-out condition)
2/
0
sincos),;,(),(),( iiiirriiiisrc
rrsurface ddfLL
skyii
src LL ),(
1
),;,( rriif
skyrr
surface LL ),(
Specular Reflectionsource intensity I
viewingdirectionsurface
element
normal
incidentdirection n
v
s
rspecular/mirror direction
),( ii ),( vv
),( rr
• Mirror BRDF is simply a double-delta function :
• Valid for very smooth surfaces.
• All incident light energy reflected in a SINGLE direction (only when = ).
• Surface Radiance : )()( vivisIL
v r
)()(),;,( vivisvviif
specular albedo
Specular reflection
• Specular reflection is the mirror-like reflection of light from a surface, in which light from a single incoming direction is reflected into a single outgoing direction.
• Specular reflection is a phenomenon in which we see an illuminated shiny surface, we observe a highlight or bright spot at certain viewing directions. Specular reflection is distinct from diffuse reflection, where incoming light is reflected in a broad range of directions.
• This bright spot is view independent as it is related to the surface normal of the object and the lights incoming direction. An ideal mirror is a purely Specular reflector.
• An example of the distinction between Specular and diffuse reflection would be glossy and matte paints. Matte paints have almost exclusively diffuse reflection, while glossy paints have both Specular and diffuse reflection.
Reflections on still water examples of specular reflection
Diffuse and Specular Reflection
diffuse specular diffuse+specular
Ambient light
• A surface that is not exposed to direct light may still be lit up by reflections from other nearby objects – ambient light
• The total reflected light from a surface is the sum of the contributions from light sources and reflected light
• Due to reflections on the other objects even object that are not directly lit by a light source are visible.
• To model indirect illumination a hack of ambient light is used.• No position nor direction • Constant for all surfaces in the scene• Independent on object orientation and position• Surfaces properties are to determine how much ambient light
is reflected.
Here the ambient light is produced by a heavy fog. It’s a neutral diffused light
Color component
• To see color, three essential elements must be present: light, an illuminated object, and an observer.
• We perceive electromagnetic energy having wavelengths in the range 400-700 nm as visible light.
Transparent objects
• Transparency is something which is completely invisible.• One color entry in a single GIF or PNG image's palette can be
defined as "transparent" rather than an actual color.• An image that is not rectangular can be filled to the required
rectangle using transparent surroundings.• Raster file formats that support transparency
include GIF, PNG, BMP, TIFF, and JPEG 2000.
Transparency
Transparent object:- reflected and transmitted
light- refraction- scattering
Snells law
• It is the relationship between angle of incidence and refraction.• Snell's law states that the ratio of the sines of the angles of
incidence and refraction is equivalent to the ratio of phase velocities in the two media, or equivalent to the reciprocal of the ratio of the indices of refraction
Snells law representation
Snell’s law of refraction:
N
qi
L R
T
refraction ofindex : ,sinsin i
r
ir
qi
qr
LNTr
iri
r
i
coscos
and for solve and,
,cos,1.
law, sSnell' Use
:Derivation
LNT
NTTT
r
Transparency 3
Thin surface:- double refraction- shift of light ray
Transparency 3
Very thin surface:- Discard shift
opacity :1
ncy transpara:
10
)1(
:model Simple
transrefl
t
t
t
tt
k
k
k
IkIkI
Poor result for silhouette edges…
Translucent objects
• Light is scattered through the object.• Incident illumination smoothed due to diffuse scattering inside
the media.• Rendering translucent materials using photon diffusion.• Combing photon tracing with diffusion for rendering the
translucent materials.• Light entering the translucent materials (e.g: milk, wax, skin,
marble ) may exit at different location and direction than it entered.
Opacity and multiple objects
• Opacity describes how opaque an object is. It allows you to adjust the transparency of an object.
• An opaque object is completely impervious to light, which means you cannot see through it.
• By sliding the opacity of each layer somewhere in between 0 and 100, you can overlay multiple layers on top of each other, creating a multilayer image mosaic.
Halftoning
• When an Image has to be displayed on a device with a much larger resolution than the original image, resolution may be traded off for dynamic range.
• In printing where dot density is very high this is usually possible.
Half Toning
Digital halftoning
Original
Half Toning
Dithering and Halftoning
Trade spatial for intensity resolution(works well for printing where dot printing is very high)• Thresholding. • Random dither; Robert’s algorithm• Ordered dither• Error diffusionYour eye will average over an area
- Spatial Integration
Dithering
Error Diffusion
Here the error is distributed across the layers.With this method, the average quantization error is reduced by propagating the error from each pixel to some of its neighbours in the scan order
Original Picture
Dithering resultError diffusion result
Set AccErr[] to zero;For each pixel in the image scanning from left to right: value= Pixel_value(x,y) + AccErr[x,y]; if (value > WHITE/2) {
Set_pixel(x,y, WHITE);Error = value - WHITE;}
else { Set_pixel(x,y, BLACK); Error = value - BLACK; }
if scanning from left to right { AccErr[x+1, y] += 3/8 * Error; AccErr[x, y+1] += 3/8 * Error; AccErr[x+1,y+1] += 2/8 * Error; }
Error Diffusion