cs 488 more shading and illumination
play

CS 488 More Shading and Illumination Luc R ENAMBOT 1 Illumination - PowerPoint PPT Presentation

CS 488 More Shading and Illumination Luc R ENAMBOT 1 Illumination No Lighting Ambient model Light sources Diffuse reflection Specular reflection Model: ambient + specular + diffuse Shading: flat, gouraud, phong, ...


  1. CS 488 More Shading and Illumination Luc R ENAMBOT 1

  2. Illumination • No Lighting • Ambient model • Light sources • Diffuse reflection • Specular reflection • Model: ambient + specular + diffuse • Shading: flat, gouraud, phong, ... 2

  3. Texture Mapping • Texture mapping is the process of taking a 2D image and mapping onto a polygon in the scene • This texture acts like a painting, adding 2D detail to the 2D polygon • Instead of filling a polygon with a color in the scan conversion process with fill the pixels of the polygon with the pixels of the texture (texels) 3

  4. Mapping • Various spaces involved: The texture map is a 2D image • It is mapped onto a 2D polygon (or set of 2D polygons • The texture, the polygon(s) and the screen all have their own coordinate systems: • Texture in (u,w) coordinates • u = j(s,t) • w = k(s,t) • Polygon in (s,t) coordinates • s = f(u,w) • t = g(u,w) • Polygon in (x,y,z) coordinates • Screen in (x,y) coordinates 4

  5. Texture Coordinates 5

  6. Mapping • What we want are linear equations of the form: • s = A * u + B • t = C * w + D • to make s and t functions of the texture space. • By mapping the four corners of the texture space to the four corners of the object we get the values for A, B,C, and D in these equations • The inverse of these equations gives the mapping from object space to texture space. 6

  7. Mapping • When doing the scan conversion of the polygon onto the screen the pixels at the corners of the polygon are mapped onto the corners of the texture • Each pixel (in the screen space) can now be related to one or more texels (in the texture space.) • This allows the pixel value to be determined by averaging one or more texel values 7

  8. Algorithms • Several algorithms, including: • Catmull: continue to subdivide the object until the subdivided component is within a single pixel. Object decides what pixel is going to be - can cause problems • Blinn & Newell: maps each pixel from screen space to object space to texture space 8

  9. Examples 9

  10. Borders • Textures can usually be defined to either repeat or clamp at the edges to determine what happens if the texture is not 'big enough' to cover the object (that is if the pixel coordinates transformed into (u,w) coordinates falls outside the space occupied by the texture • If the texture repeats then the same texture pattern repeats itself over and over again on the polygon (useful for wood floors or brick walls or stucco walls) where a very small texture can be used to cover a very large space, or the texture can be told to clamp at the edges 10

  11. Clamp and Repeat 11

  12. Example 12

  13. Shadows • The lighting algorithms discussed last time worked on each object separately • Objects were not able to affect the illumination of other objects. This is not terribly realistic. In the 'real world' objects can cast shadows on other objects. • We have used visible surface algorithms to determine which polygonal surfaces are visible to the viewer. We can use similar algorithms to determine which surfaces are 'visible' to a light source - and are therefor lit • Ambient light will still affect all polygons in the scene but the diffuse and specular components will depend on whether the polygon is visible to the light 13

  14. Transparency • We have assumed that objects are all opaque, but many objects in the 'real world' are transparent or translucent • These surfaces also tend to refract the light coming through them • Dealing with refraction is quite difficult, while transparency is relatively easy 14

  15. Interpolated Transparency I lambda = (1 − K t 1 ) I lambda 1 + K t 1 I lambda 2 • Kti is the transparency of (nearer) object 1 (0 - totally opaque, 1 - totally transparent) • if Kti is 0 then the nearer object is totally opaque and the far object contributes nothing where they overlap • if Kti is 1 then the nearer object is totally transparent and the near object contributes nothing where they overlap • in between 0 and 1 the intensity is the interpolation of the intensities of the two objects • each pixel is linearly interpolated 15

  16. Screen-door transparency • This is the same idea as interpolated transparency except that each individual pixel is either given the value of the near object or the value of the far object • The ratio of pixels given to the far versus the near is Kti. This is faster to compute but gives a much less pleasing effect. • Basically it is using dithering to generate transparency 16

  17. Filtered Transparency I lambda = I lambda 1 + K t 1 O tlambda I lambda 2 • Otlambda is the transparency color of (nearer) object 1 • In all of these cases, the value of Ilambda2 may itself be the result of a transparency calculation. 17

  18. Transparency • Screen-door transparency is easy to implement along with the z-buffer since the order that polygons are drawn does not affect screen-door transparency • For the others, the order of drawing is important: One of the advantages of using a z-buffer is that the order in which the polygons are drawn became irrelevant. Here it is again necessary to draw the polygons back to front so that transparency can be correctly calculated • Solution: draw all opaque polygons first and sort the transparent ones 18

  19. Raytracing • Traces the path for reflected and transmitted rays through an environment • Recursive processing • A ray is traced for each pixel from the viewer's eye into the scene • The ray is infinitely thin • The ray is infinitely long • Surfaces are perfectly smooth 19

  20. Features • Hidden surfaces • Shadows • Reflection • Refraction • Global specular interaction • Orthographic and perspective views 20

  21. Raytracing • The power of this kind of system is that instead of just having one ray (as in visible surface determination, or shadows) that one ray can generate other rays which continue through the scene • Recursive algorithm 21

  22. Raytracing • Given: • Polygon vertices • V - input vector • Light sources • Want to find: • R' - reflected vector • P' - transmitted vector 22

  23. Raytracing • Reflected • R' = N' + ( N' + V') where V' = V / | V * N | • Transmitted • P' = Kp x (N' + V') - N' • where Kp determines the amount of refraction 23

  24. Illumination • For Li: • I = Ka Ia + sum for all lights (Kd Ip (N' * L') + Ks Ip (R' * V')^n) + Kr Ir + Kt It • Most of this we talked about last week but now there are two new terms • Kr Ir deals with the reflected light • Kt It deals with transmitted light 24

  25. Algorithm • So if we follow V from the eye through a given pixel on the screen and into the scene we can see its interaction as shown here: 25

  26. shade(object, ray, point, normal, depth) { color = ambient term for (each light) { sRay = ray from light to point if (dot product of normal and direction to light is positive) { compute how much light is blocked by opaque and transparent surfaces scale diffuse and specular terms before adding them to color } } if (depth < maxDepth) { if (object is reflective) { rRay = ray in reflection direction from point rColor = trace (rRay, depth+1) scale rColor by specular coefficient and add to color } if (object is transparent) { tRay = ray in refraction direction from point if (total internal reflection does not occur) { tColor = trace (tRay, depth+1) scale tColor by transmission coefficient and add to color } } } shade = color } 26

  27. //------------------------------------------------------------------- trace(ray, depth) { determine closest intersection of the ray with an object if (object is hit by ray) { compute normal at intersection return( shade (closest object hit, ray, intersection, normal, depth)) } else return(BACKGROUND_VALUE) } //------------------------------------------------------------------- main () { for each scan line in the image for each pixel in the scan line { determine ray from center of projection through that pixel pixel = trace (ray, 1) } } 27

  28. Examples 28

  29. Radiosity • Radiosity is a method of trying to simulate lighting effects using much more realistic models than were used previously: lighting simulation • Closed environment: so light energy is conserved. All of the light energy is accounted for • No need for an ambient light term anymore as what the ambient term simulated will now be specifically computed 29

  30. Radiosity • Radiosity is the rate at which energy leaves a surface (via emittance, reflectance or transmittance) • Light interactions are computed first for the entire scene without regard for the viewpoint: diffuse reflection • Generate images from any viewpoint 30

  31. Radiosity • Light sources are not treated as separate from the objects in the scene • All objects emit light which can give more realistic effects when areas are giving off light rather than several discrete sources • Space divided into n discrete finite sized patches which emit and reflect light uniformly over their area 31

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend