Presentation is loading. Please wait.

Presentation is loading. Please wait.

Shading (introduction to rendering). Rendering  We know how to specify the geometry but how is the color calculated.

Similar presentations


Presentation on theme: "Shading (introduction to rendering). Rendering  We know how to specify the geometry but how is the color calculated."— Presentation transcript:

1 Shading (introduction to rendering)

2 Rendering  We know how to specify the geometry but how is the color calculated

3 Rendering  We know how to specify the geometry but how is the color calculated

4 Rendering  We know how to specify the geometry but how is the color calculated

5 Rendering: simulation of light transport  What makes up the final color of an object?

6 Rendering: simulation of light transport  Diffuse scattering o matt surfaces  Specular reflection o shiny surfaces o highlight  Transparency o glass, water o penetrate the surface

7 Rendering: simulation of light transport  How do we represent these observations in a mathematical framework

8 Rendering: simulation of light transport  Real time rendering is generally not concerned with using a "correct" lighting equation, just a series of hacks to make things look right with as little computational effort as possible

9 Illumination Models  Local o Direct illumination of surfaces by light sources  Global o all light/surface interactions for entire environment

10 Global illumination

11

12 Local illumination  Input: o a 3D object o Material and color of the object o Position and structure of the light source o “Intensity” of the light source  Output: o Color and intensity of points of the given object A (modest) example of shading

13 Representing 3D Objects  Collection of triangles or mesh

14 Dealing with color  Three component intensity (red, green, blue)  Luminance (intensity) of the source o Red component of source red component of image o Green component of source green component of image o Blue component of source blue component of image  Three similar but independent calculations  We focus on one scalar value only

15 Diffuse reflection  A perfect diffuse reflector (Lambertian surface) scatters the light equally in all directions  Same appearance to all viewers  Depends on o Material of the surface o The position of the light

16 Normals o What direction is the surface facing?

17 CrossProduct o n.x = a.y * b.z - a.z * b.y o n.y = a.z * b.x - a.x * b.z o n.z = a.x * b.y - a.y * b.x

18 Normals o A = V2 – V1 o B = V0 – V1 o N = A x B

19 Normals o For each triangle we can define a normal for the face o For each vertex we an define a normal by interpolating normals of attached faces

20 Diffuse: Two important vectors  To compute the intensity at P, we need o The unit normal vector N, o The unit vector L, from P to the light L N P θ

21 Diffuse: Two important vectors  To compute the intensity at P, we need o The unit normal vector N, o The unit vector L, from P to the light L N P θ What is the diffuse color at P?

22 Lambert’s cosine law  I : diffuse reflection at P   I d : intensity of the light from source  coefficient of diffuse reflection

23 Coefficient of diffuse reflection  k d is usually determined by a trial and error approach  Examples: Component Gold Black plastic Silver Red 0.75 0.01 0.5 Green 0.6 0.01 0.5 Blue 0.22 0.01 0.5 k d =0.05 k d =0.25 k d =0.5 k d =0.75 k d =1

24 Specular reflection  Diffusive reflection: no highlights, rough surface  Specular reflection: highlights, shiny and smooth surfaces  View dependent reflection

25 Three important vectors  To compute the intensity at P, we need o The unit normal vector N, o The unit vector L, from P to the light o The unit vector V, from P to the viewer L N V P

26 Three important vectors  To compute the intensity at P, we need o The unit normal vector N, o The unit vector L, from P to the light o The unit vector V, from P to the viewer L N V P What is the specular illumination at P?

27 The shininess coefficient 0 90 o -90 o increasing n

28  I : specular reflection at P   I d : intensity of the light from source  coefficient of specular reflection  n: controls shininess The Phong model for specular reflection P N L R P N L R V

29 Ambient light  “Physical rules” are too simplified  No indirect or global interaction of light  A hack to overcome the problem: use “ambient light”

30 Ambient light specification  Not situated at any particular point  Spreads uniformly in all directions   I a : intensity of ambient light in the environment  I : ambient light at a given point  : coefficient of ambient light reflection k a =0 k a =0.5 k a =1

31 A combined model (The Phong local illumination model)  The final model = diffuse + specular + ambient 

32 How does it work in OpenGL

33 Flat Shading  Individual faces are visualized  Same color for any point in the face

34 Smooth Shading  Visualize the underlying surface  Each point on the face has its own color  Two techniques Gouraud and Phong shading

35 Shading GouraudPhongFlat Normal Per VertexInterpolated normal for each point across face Normal per face Color per vertex, interpolated across face Color calculated per pixel Color calculated per face Faster then phong Bad specular Costly (not really any more) Fast, good for distant objects N

36 Clarification  Phong reflection model or phong lighting refers to  Phong Shading refers to filling a triangle by interpolating the normal and calculating the color at each point

37 Gouraud Shading  Specular highlight quality tied to detail of mesh  Specular highlights can even be missed

38 Incorporating a distance term a,b,c are control parameters Empirical formula:

39

40

41

42 Multiple light sources  The total reflection at p is the sum of all contributed intensities from all sources  OpenGL allows us to define several light sources

43 OpenGL 2.0 (programmable) pipeline

44 More advanced rendering

45

46

47

48

49

50

51 Questions?

52


Download ppt "Shading (introduction to rendering). Rendering  We know how to specify the geometry but how is the color calculated."

Similar presentations


Ads by Google