1 / 35

Shading

Shading. Shading : determining light reflection from objects at each pixel. Basic Reflection Model: Phong Reflection Model (most commonly used). I= k a I a + k d I d (l · n) + k s I s (v · r ) α I : reflected-light intensity. Ambient Reflection : Direction independent k a I a

sheera
Download Presentation

Shading

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Shading Shading: determining light reflection from objects at each pixel. Basic Reflection Model: Phong Reflection Model (most commonly used) I= kaIa + kd Id (l · n) + ksIs(v · r )α I : reflected-light intensity

  2. Ambient Reflection: Direction independent kaIa Ia : incident ambient-light intensity ka : object ambient-reflection coefficient part of the object material properties

  3. Lambertian / Diffusive Reflection: Lighting-direction dependent Idkd(ln) = Idkdcos() Id : incident difussive-light intensity kd : object diffusive-reflection coefficient  : angle between light direction (l) and surface normal (n). Both l and n are unit vectors.

  4. Specular Reflection: Viewing-direction dependent Isks(vr)α = Iskscos α (Ф). Is : incident specular-light intensity ks : object specular-reflection coefficient Ф : angle between reflection direction (r) and viewing direction (v).  : specular-reflection exponent, shaniness coefficient. 1/: roughness.

  5. The effects of ambient, diffusive and specular reflection.

  6. The effects of ambient, diffusive and specular reflection. (http://en.wikipedia.org/wiki/Utah_teapot) Teapots shaded with different parameters.

  7. Attenuation: Distance dependent, no impact on ambient light fatt = 1/(a + bd + cd2) d : distance from the light to the surface point. a,b,c: constant, linear, quadratic attenuation coefficients. I = kaIa + fattkd Id (l · n) + fattksIs(v · r )α I = kaIa + Idkdcos() / (a + bd + cd2) + Iskscos α (Ф) / (a + bd + cd2)

  8. Summary: I = kaIa + fattkd Id (l · n) + fattksIs(v · r )α I = kaIa + Idkdcos() / (a + bd + cd2) + Iskscos α (Ф) / (a + bd + cd2)

  9. Colored Lights and Surfaces : I = (Ir, Ig, Ib) = { I,= r, g, b} : color channel ->Colored lights: Ia, Id, Is, ->Colored objects: ka, kd, ks, I = Ia ka+ fatt Idkd(ln) + fatt Isks(vr) α with = r, g, b.  Ir = Iar kar + fatt Idr kdr(ln) + fatt Isr ksr(vr)α Ig = Iagkag+ fattIdgkdg(ln) + fattIsgksg(vr) α Ib = Iabkab+ fattIdbkdb(ln) + fattIsbksb(vr) α

  10. Multiple Lights: I = Ia ka+ fatti [Idikd(lin) + Isiks(vri) α] with = r, g, b. m: number of lights. OpenGL support ambient component for individual light. I = [ Iai ka+ fatti [Idikd(lin) + Isiks(vri) α]]

  11. Many more things consider: Shadow, Reflection, Transparency, Refraction, … • http://www.codeproject.com/KB/graphics/RayTracerNet.aspx • Figure 2. Shading effects: a) Ambient, b) Diffuse, c) Highlights, d) Shadows and e) Reflection (notice the reflection on the floor also) 

  12. Object Order Shading: Geometrically approximate objects as patched (triangled) surfaces.Appearance-wise use three shading methods to approximate: Flat, Gouraud, Phong

  13. How to get to each pixel? Two approaches: object order and image order • Frame Buffer: a buffer of memory to store the colors of the screen, one memory cell per pixel. • http://www.webopedia.com/TERM/F/frame_buffer.html • http://en.wikipedia.org/wiki/Framebuffer • http://en.wikipedia.org/wiki/Linux_framebuffer

  14. line of sight Z buff Frame buff • Z Buffer (depth buffer): a buffer of memory to store the z values of the screen, one memory cell per pixel. http://en.wikipedia.org/wiki/Z-buffering

  15. Flat/Constant Shading:http://www.yourdictionary.com/computer/flat-shading for (each object) for(each triangle of the object) compute its reflection using color and normal of the triangle for(each pixel in the triangle) if(closer to the viewer than the current z buffer value) { update z buffer with the new z update pixel color with the triangle reflection }

  16. Gouraud/Smooth Shading http://en.wikipedia.org/wiki/Gouraud_shading for (each object) for(each triangle of the object) { for(each vertex of in the triangle) compute the vertex reflection using the color and the normal of the vertex for(each pixel in the triangle) if(closer to the viewer than the current z buffer value) { update z buffer with the new z interpolate the pixel color from the vertex reflections. } }

  17. PhongShading:http://www.yourdictionary.com/computer/phong-shadinghttp://en.wikipedia.org/wiki/Phong_shadingPhongShading:http://www.yourdictionary.com/computer/phong-shadinghttp://en.wikipedia.org/wiki/Phong_shading for (each object) for(each triangle of the object) for(each pixel in the triangle) if(closer to the viewer than the current z buffer value) { update z buffer with the new z interpolate the pixel normal from the vertex normals compute the pixel color/relection using Phong reflection model using pixel normals and the properties of the object. }

  18. Comparaison of ShadingMethods:http://en.wikipedia.org/wiki/Gouraud_shading

  19. Comparaison of ShadingMethods:http://en.wikipedia.org/wiki/Gouraud_shadinghttp://en.wikipedia.org/wiki/Phong_shading

  20. Comparaison of ShadingMethods: Gouraud Shadinghttp://en.wikipedia.org/wiki/Gouraud_shadinghttp://en.wikipedia.org/wiki/Phong_shading

  21. Comparaison of ShadingMethods: Gouraus vs. Phonghttp://en.wikipedia.org/wiki/Gouraud_shadinghttp://en.wikipedia.org/wiki/Phong_shading GOURAUD SHADING

  22. Comparaison of ShadingMethods: High Resolution Gouraudhttp://en.wikipedia.org/wiki/Gouraud_shadinghttp://en.wikipedia.org/wiki/Phong_shading

  23. Image-order Shading

  24. Ray-tracing (Image created by Russell Yuncker) (Image created by Jian He)

  25. Simple Ray Tracing: for (each scan line in image ) { for (each pixel in scan line ) { determine ray from eye through pixel; for(each object in scene) { if(object is intersected and is closest considered thus far) record intersection point and object id. } set pixel’s color to that at closest object intersection point (using the I formula given above.) } }

  26. Recursive Ray Tracing: Set pixel’s color to that at closest object intersection point using the I formular given below. I= (1- kr - kt )Iregular+ krIr+ kt It Iregular: regular reflection of lights from light source. Computed by the formula above. kr : reflection coefficient. Ir: illumination from other objects (to be reflected). kt : transmission coefficient. It: illumination from other objects (to be transmitted).

  27. Programming Image-order Shading Ray Tracing using Povray (Image created by Russell Yuncker) (Image created by Jian He)

  28. http://www.iss.rwth-aachen.de/Projekte/grace/raytracing.html • Figure: mirror + shadow • Free ray tracing software: • POV-Ray (http://www.povray.org/) • Start->Program Files->Pov Ray for Windows • Run the examples in the “scenes” directory: • C:\Program Files\Pov Ray for Windows\scenes. • The resulting image is stored in the same directory as the source file.

  29. // Shading Demonstration • // Using POV-Ray's SDL (Scene Description Language) #include "colors.inc" #include "stdcam.inc" sphere { <-1.5, 0.4, -2.5>, 0.4 // center & radius pigment { rgb <0.0, 0.5, 0.5> } //color finish { ambient .2 // ka diffuse .6 //kd specular .75 //ks roughness .01 // 1/ } } text { ttf "cyrvetic.ttf" // font type "Color Sphere", 0.1, 0 // string, thickness, gap scale <1.25, 1.25, 4> translate <-3.75, 0, 0> pigment { rgb <1, 0.5, 0.2> } }

  30. Note: • Rotation and scaling are about the origin. Need to move the object to the origin, rotate/scale there and then move it back. (Box example) #declare Box_Lid = box {<-3.75, 0.0, -2.75> <3.75, 0.25, 2.75> translate -2.75*z // put "hinge" at origin rotate x*25 // open the lid translate 2.75*z // move "hinge" back translate y*2 // lift to top texture {T3} }

  31. By default, POV-Ray has the positive y-axis pointing up, the positive x-axis pointing to the right, and the positive z-axis pointing into the screen. But this will change depending on the camera settings. (Help: camera, placing) • You place the camera in the world coordinate system. But the images are displayed from the camera’s point of view.

  32. More Info on Ray Tracing Povray Community (Hall of Fame, Contests, …) http://www.povray.org/community/ UNC Ray Tracing Tutorial http://www.cs.unc.edu/~rademach/xroads-RT/RTarticle.html • Ray Tracing Contests: http://www.irtc.org:7777/irtc/irtc

  33. Ray Traced Images and Videos • Images for raytracing • http://www.google.com/images?hl=en&rlz=&q=Raytracing&um=1&ie=UTF-8&source=univ&ei=Z4VxTN6RGIG0lQei3_C0Dw&sa=X&oi=image_result_group&ct=title&resnum=4&ved=0CD4QsAQwAw&biw=1280&bih=621 • Videos for raytracing • http://www.google.com/search?source=ig&hl=en&rlz=&=&q=raytracing&aq=f&aqi=g-s7g1g-s2&aql=&oq=&gs_rfai=Ch7LQko1xTLWPBZG6hATSztjlDwAAAKoEBU_Q5UWV#q=raytracing&hl=en&prmd=ivb&source=univ&tbs=vid:1&tbo=u&ei=ko1xTMeSE4TGlQePy_mhDg&sa=X&oi=video_result_group&ct=title&resnum=8&ved=0CEkQqwQwBw&fp=fff49bcb8f5e5b8c

  34. Hardware Assisted Ray Tracing Nvidia GF100 Ray-tracing http://www.youtube.com/watch?v=Cbnv_z6VDj8 • Writing a Ray Tracer http://www.siggraph.org/education/materials/HyperGraph/raytrace/rtrace0.htm • A raytracer in C++ http://www.codermind.com/articles/Raytracer-in-C++-Introduction-What-is-ray-tracing.html • Povray Source Code http://www.povray.org/download/

  35. Graphics Packages using Object-order Shading: • Animation: Alice Panda3D XNA / XNA Game Studio Express Processing 3DS Max Maya Flash • Rendering APIs: OpenGL ActiveX Renderman Pixie - Open Source RenderMan • Web Graphics: VRML X3D SecondLife Flash Microsoft Silverlight Google SketchUp HTML5.0

More Related