Presentation is loading. Please wait.

Presentation is loading. Please wait.

Shading, Surfaces & Textures

Similar presentations


Presentation on theme: "Shading, Surfaces & Textures"— Presentation transcript:

1 Shading, Surfaces & Textures
1

2 Outline Polygon shading models Lighting models Surfaces properties
Constant, interpolated, polygon mesh, Lambert, Gouraud, Phong Lighting models Lambert, Phong, Blinn Surfaces properties Surface mapping Texture Bump Displacement 2

3 Lighting algorithms Most algorithms use the polygon or surface normal (vector that is perpendicular to the polygon) The amount of light reflected depends on the angle of the incident light, e.g. for diffuse reflection: N L 3

4 Constant shading Also known as Lambert, faceted and flat shading
Calculates a single intensity value for each polygon Valid if following assumptions are true: Light source is at infinity (i.e. angle between light and surface is constant) Viewer is at infinity (i.e. angle between viewer and surface is constant) Polygon is not an approximation of a curved surface 4

5 Interpolated shading Shading is linearly interpolated across polygon
Faster than calculating each pixel, better than flat shading Still assumes that polygon represents the true surface 5

6 Polygon mesh shading Many sets of polygons actually are approximations to curved surfaces Shading the polygons to realistically simulate the surface is therefore important Several methods exist to achieve this, the most important of which are Gouraud and Phong shading. 6

7 Gouraud shading This is a form of intensity interpolation shading
(Henri Gouraud, PhD 1971) This is a form of intensity interpolation shading Starts from knowing the normal of the surface at each vertex of the polygon These may be stored with the mesh or may be averaged from the adjacent polygons Next step is to calculate the vertex intensities This will use the vertex normal and the illumination algorithm 7

8 Gouraud shading (2) The polygon is then shaded by:
Interpolating the intensities along each edge Interpolating across the polygon between the edges along each scan line I1 I2 I3 IP 8

9 Gouraud algorithm Compute SA, SB, SC for triangle ABC.
Si = shade of point i. For a scanline XY, compute SX, SY by interpolating e.g. tAB = |AX| / |AB|. SA = tAB* SA + (1-tAB)*SB Compute SP By interpolating between SX and SY B X P Y scanline SX SP SY A C

10 Gouraud example

11 Phong shading This is a form of normal-vector interpolation shading
(Bui-Tong Phong, PhD 1975) This is a form of normal-vector interpolation shading Starts from the normal vector at each vertex again, but interpolates the vector rather than the intensity 9

12 Phong shading (2) In general, this yields much more realistic results, especially for specular surfaces Gouraud shading may miss specular highlights It is several orders of magnitude slower than Gouraud 10

13 Problems with interpolated shading
Polygonal silhouette Perspective distortion Orientation dependence Shared vertices Unrepresentative vertex normals 11

14 Polygonal silhouette Approximation is polygonal, so no matter how good the shading algorithm the silhouette will be faceted Can be improved by increasing the polygon count at expense of processing time 12

15 Perspective distortion
Because the interpolation is based on the scan lines, the number of interpolation increments per polygon depends on the angle of the polygon to the viewer Steep angle = few increments Shallow angle = more increments 13

16 Orientation dependence
Because interpolation occurs between vertices and along scan lines, result depends on orientation of polygon relative to scan lines 14

17 Shared vertices Problems occur when adjacent polygons do not share vertices This can lead to discontinuities in shading 15

18 Unrepresentative vertex normals
Vertices may not adequately represent the surface geometry Usually can be solved by further subdividing surface 16

19 Surfaces Definition of visual characteristics of a surface
Often defined by a ‘shader’ or ‘material’ Specifies colour, how shiny it is, etc.

20 Surface parameters Colour usually defined by RGB values or via GUI
Ambient is a false parameter that defines how ‘ambient’ light is treated Diffuse parameter specifies how much light in total is evenly reflected Specularity defines how shiny a surface is (a high value will have highlights like a billiard ball) May also have controls for highlight size and colour

21 Advanced surface parameters
Reflectivity defines how much of the surrounding environment is reflected by the surface (like a mirror) Transparency defines of the background is visible through the surface Translucency defines how much light is transmitted through the surface Refractivity defines how much light is bent as it enters and leaves the material

22 Surfaces in Maya Basic materials: Special materials: Lambert Phong
Phong E Blinn Special materials: Anisotropic, Layered Shader, Ocean Shader, Ramp Shader, Shading Map, Surface Shader, Use Background

23 Lambert This is the simplest material
It creates a matt surface with diffuse and ambient components but no highlights The shading interpolates between adjacent polygon normals so the surface appears smooth It uses Lambert’s cosine law

24 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” Johann Lambert,

25 Lambert’s Cosine Law Ideal diffuse surfaces obey this cosine law
Often called Lambertian surfaces. Id = kd Iincident cos  = kd Iincident (N·L). where kd is the diffuse reflectance of the material. Wavelength dependent, so usually specified as a colour.

26 Maya Lambert properties

27 Phong This lighting model includes specularity
(Bui-Tong Phong, 1975) This lighting model includes specularity This takes into account that the amount of light you see depends on the viewer’s angle to the surface as well as the light’s angle 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 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.

28 Phong lighting model More recent formulations are slightly different
Replace W(i) with a constant ks, independent of the incident direction Is= ks Iincident cosn = ks Iincident (V·R)n. V is the view direction. R is the specular reflection direction L N R V

29 Variation of n

30 Maya Phong properties

31 Maya’s ‘Phong E’ Uses a simplified model, faster to render than pure Phong

32 Maya’s Blinn Based on Blinn-Phong shading (an adaptation of Phong)
(Jim Blinn, 1977) Based on Blinn-Phong shading (an adaptation of Phong) Offers great control over specularity but in general will not look as ‘shiny’ as a Phong material

33 Maya Blinn properties II

34 2D texture mapping A ‘cheap’ way of enhancing the the surface definition So far, surfaces have been defined with a plain colour In real life, many surfaces are multi-coloured E.g. Wood looks ‘wooden’ because of many different colour variations in the grain 3

35 2D texture mapping (2) 2D texture mapping involves applying a 2D image to the surface of a 3D object In this case the term ‘texture’ applies to the image rather than the more traditional ‘feel’ of the surface Textures may be ‘real’ (e.g. scanned), manually generated (e.g. with a paint program) or procedurally generated (e.g. by a computer program) 4

36 2D texture mapping (3) The process of applying the texture is the ‘mapping’ The two mapping processes: Projecting the image onto the surface Stretching the image to fit on the surface 5

37 Projection mapping In projection mapping the image is projected through space Wherever it ‘hits’ the surface the surface becomes the colour of the texture The purest form of this is planar projection 6

38

39 Cylindrical projection
Image is bent into a cylinder before projection takes place Object is then placed ‘in’ the cylinder 7

40

41 Spherical projection Image bent onto an imaginary sphere before projection Object placed ‘in’ sphere 8

42

43 Limitations Unless mapping on a perfect flat surface, cylinder or sphere, all projection methods will have a tendency to ‘streak’ Parameterised texture mapping offers a solution to this problem 9

44 Parameterised (UV) mapping
Imagine printing the texture image onto thin transparent film Then stretch the film over the surface This is the principle of parameterised texture mapping 10

45 Parameterised mapping (2)
The 2D texture image is (obviously) an array of rectangular pixels These can be referenced by Cartesian coordinates, usually with the lower left pixel being (0,0) (and for a 512 x 512 image the top right being (511,511)) Each pixel rectangle is then mapped to a corresponding area of the 3D surface 11

46 Parameterised mapping (3)
You therefore have to divide the surface into the same number of steps The surface patch is defined to use the coordinate system U and V to specify locations on it The area defined by (0,0) on the surface has the colour applied to it from the image pixel at (0,0) 12

47

48

49

50 Procedural textures Textures can be generated by procedures rather than using predefined images This is good for regular patterns (e.g. brickwork) or (semi-)random patterns (e.g. noise)

51 Maya procedural textures

52 Got to here! Other types of mapping
So far, all examples have used the colour of the image to affect the colour of the surface - this is colour texture mapping Other options are transparency mapping, bump mapping and displacement mapping 14

53 Transparency mapping Use pixel value to define transparency of object
Usually uses grey values, white = opaque & black = transparent 15

54

55 Bump mapping Uses pixel values to ‘perturb’ the surface normals
Used to model tiny variations in surface contour Actual surface doesn’t change geometry, but appears to because normal is shifted Good for ‘orange peel’ like effects, but outline is still smooth 16

56

57

58 Displacement mapping Uses the intensity of the pixel to actually shift part of the surface up (for white) or down (for black) Used to model surface irregularity, but unlike bump mapping the surface geometry actually changes 17

59

60

61 Other image-based mapping
Incandescence mapping Pixel values = ‘glow brightness’ Specularity mapping Pixel values = specularity Reflectivity mapping Pixel values = reflectivity 18

62 3D texture mapping Often, realistic objects require more than just 2D images mapped onto them E.g. Shiny surfaces (such as chrome) should reflect the environment that surrounds them Some of these effects can be achieved by ray tracing, but this is expensive We can use environmental reflection mapping (sometimes called just reflection mapping) 19

63 Reflection mapping Cubic (most common) Spherical
Six views of the surrounding world are generated and mapped on the object using cubic texture mapping Six images may be rendered views Spherical Use a single image that is spherically texture mapped Difficult to generate the single image correctly 20

64 Solid texture mapping Useful for things such as wood grain, marble, etc. Create a volume of texture Object then ‘floats’ in this volume and surface points adopt colours defined in the volume Can also be used to model transparency and other effects 21

65 Summary Shading algorithms Lighting algorithms Surface properties
Flat, Gouraud, Phong Lighting algorithms Lambert, Phong… Surface properties Diffuse, specular… Surface mapping Texture, bump, displacement…


Download ppt "Shading, Surfaces & Textures"

Similar presentations


Ads by Google