890 likes | 1.1k Views
Surfaces & Illumination. Refresh. 2D and 3D viewing and clipping. Hidden surface removal. Projections. Texture mapping. Rasterisation. Converts the vertex information output by the geometry pipeline into pixel information needed by the video display Anti-aliasing Z-buffer
E N D
Refresh • 2D and 3D viewing and clipping Hidden surface removal Projections Texture mapping
Rasterisation • Converts the vertex information output by the geometry pipeline into pixel information needed by the video display • Anti-aliasing • Z-buffer • Transparent objects • Drawing lines • Texture mapping • Bump mapping
Today • Texture mapping • Common texture coordinates mapping • Texture coordinates • Illumination
Texture mapping. • Method of improving surface appearance by adding details on surface.
y v v u u x Texture mapping. • Image is ‘pasted’ onto a polygon. • Image is called a Texture map, it’s pixels are often referred as a Texels and have coordinates (u,v) • Texture coordinates aredefined for each vertex of the polygon and interpolated across the polygon.
Three Types of Mapping • Texture Mapping • Uses images to fill inside of polygons • Environment (reflection mapping) • Uses a picture of the environment for texture maps • Allows simulation of highly specular surfaces • Bump mapping • Emulates altering normal vectors during the rendering process
Texture Mapping, environment map and bump map geometric model texture mapped Environment map Bump map
Where does mapping take place? • Mapping techniques are implemented at the end of the rendering pipeline • Very efficient because few polygons make it past the clipper
For each triangle in the model establish a corresponding region in the texture Photo-textures During rasterization interpolate the coordinate indices into the texturemap
Is it simple? • Although the idea is simple---map an image to a surface---there are 3 or 4 coordinate systems involved 2D image 3D surface
Coordinate Systems • Parametric coordinates • May be used to model curves and surfaces • Texture coordinates • Used to identify points in the image to be mapped • Object or World Coordinates • Conceptually, where the mapping takes place • Window Coordinates • Where the final image is really produced
Texture Mapping parametric coordinates texture coordinates window coordinates world coordinates
Common Texture Coordinate Mappings • Orthogonal • Cylindrical • Spherical
Mapping Functions • Basic problem is how to find the maps • Consider mapping from texture coordinates to a point a surface • Appear to need three functions x = x(s,t) y = y(s,t) z = z(s,t) • But we really want to go the other way (x,y,z) t s
Backward Mapping • We really want to go backwards • Given a pixel, we want to know to which point on an object it corresponds • Given a point on an object, we want to know to which point in the texture it corresponds • Need a map of the form s = s(x,y,z) t = t(x,y,z) • Such functions are difficult to find in general
Two-part mapping • One solution to the mapping problem is to first map the texture to a simple intermediate surface • Example: map to cylinder
Cylindrical Mapping parametric cylinder x = r cos 2p u y = r sin 2pu z = v/h maps rectangle in u,v space to cylinder of radius r and height h in world coordinates s = u t = v maps from texture space
Spherical Map We can use a parametric sphere x = r cos 2pu y = r sin 2pu cos 2pv z = r sin 2pu sin 2pv in a similar manner to the cylinder but have to decide where to put the distortion Spheres are used in environmental maps
Second Mapping • Map from intermediate object to actual object • Normals from intermediate to actual • Normals from actual to intermediate • Vectors from center of intermediate actual intermediate
Aliasing • Point sampling of the texture can lead to aliasing errors point samples in u,v (or x,y,z) space miss blue stripes point samples in texture space
Surface Lighting Effects • The amount of incident light reflected by a surface depends on the type of material • Shiny materials reflect more of the incident light and dull surfaces absorb more of the incident light • For transparent surfaces some of the light is also transmitted through the material
Why lightning? • Q: why? • A: nothing looks three dimensional!
Light and surface interaction • (a): Specular surfaces appears shiny due to reflection of light. Mirrors are perfectly specular surfaces. • (b): Diffuse surfaces scatter reflected light in all directions. • (c): Translucent surfaces allow some of the light to penetrate through the surface. Light is refracted but reflection can also occur.
Point Light Sources • 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 • However, it will have very little directional effect • Radial intensity attenuation is not used
Directional Light Sources & Spotlights • To turn a point light source into a spotlight we simply add a vector direction and an angular limit θl
Directional Light Sources & Spotlights • Vlight is a unit vector • Vobj is a 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
Angular Intensity Attenuation • 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
Light and surface interaction • Specularsurfaces appears shiny due to reflection of light. Mirrors are perfectly specular surfaces. • Diffuse surfaces scatter reflected light in all directions. • Translucent surfaces allow some of the light to penetrate through the surface. Light is refracted but reflection can also occur.
Point Light Sources • Light is emitted in all directions • Defined by: • The position of the light • The RGB values for the colour of the light • Useful for small light sources
Infinitely Distant Light Sources • A large light source, like the sun, can be modelled as a point light source • No directional effect
Directional Light Sources & Spotlights • To turn a point light source into a spotlight we simply add a vector direction and an angular limit θl
Directional Light Sources & Spotlights • Vlight is a unit vector • Vobj is a 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
Angular Intensity Attenuation • 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
Light reflection • The colors that we perceive are determined by the nature of the light reflected from an object White Light Colors Absorbed Green Light
Surface Lighting Effects • The amount of incident light reflected by a surface depends on the type of material • Shiny materials reflect more of the incident light and dull surfaces absorb more of the incident light • For transparent surfaces some of the light is also transmitted through the material
Diffuse Reflection • Surfaces that are rough or grainy tend to reflect light in all directions • This scattered light is called diffuse reflection
Specular Reflection • Additionally to diffuse reflection some of the reflected light is concentrated into a highlight or bright spot • This is called specular reflection
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
Example from the net Ambient Diffuse FinalImage Specular
Illumination models: Preliminaries • n is the normal to the surface at the point p. • v is the direction to the viewer or COP. • l is the direction to the light source. • r is the direction of the perfect reflection of the light coming from direction l. • When we move the point p on the surface the vectors will change. • However, the normal n will only change if the surface is curved.
Illumination models: Ambient and Lambertian Self-illuminating objects: Intrinsic intensity/reflection coefficient Background light: Ambient light Equally bright from all directions e.g. by matte surfaces: Lambertian surface with Ambient light Lambertian: light falling on it is scattered such that the apparent brightness of the surface to an observer is the same regardless of the observer's angle of view.
Illumination models: Distance attenuation • Distance from light source to object reduce energy (light-source attenuation)
Specular points and the Phong illumination model • Shiny surfaces have specular points. Color at specular points appear to be white. Phong illumination model useful for non-perfect reflectors: • αis the shininess parameter. How spread out is the high light around the perfect reflection vector r.