IS 1260 Programmation From Prof Harriet Fell lecture
- Slides: 49
IS 1260 Programmation From Prof. Harriet Fell lecture 21 November 2020 ECP – IS 1260
Today’s Topics Ray Tracing __________ • Basic Light Model • Advanced Light Model • Basic Shadow Model 21 November 2020 ECP – IS 1260
Ray Tracing 21 November 2020 ECP – IS 1260
What is a Sphere A Python class with the following attributes: numpy. array double numpy. array Material 11/21/2020 center; radius; [R, G, B]; mat // 3 doubles // for RGB colors between 0 and 1 ECP – IS 1260
What is a Material A Python class with the following attributes: double (double int pic; 21 November 2020 kd; // diffuse coeficient ks; // specular coefficient ka; // ambient light coefficient) kgr; // global reflection coefficient kt; // transmitting coefficient // > 0 if picture texture is used ECP – IS 1260
-. 01 500 800 // 1 // antialias 1 // numlights 100 500 800 // Lx, Ly, 9 // numspheres //cx cy cz radius R -100 0 40. 9 -100 0 40. 9 0 -100 0 40. 9 0 100 0 40. 9 100 -100 0 40. 9 100 100 0 40. 9 21 November 2020 ECP – IS 1260 transform theta phi mu distance Lz G 0 0 0 0 0 B 0 0 0 0 0 ka. 2. 2. 2 kd. 9. 8. 7. 6. 5. 4. 3. 2. 1 ks spec. Exp kgr kt pic. 0 4 0 0 0. 1 8. 1 0 0. 2 12. 2 0 0. 3 16. 3 0 0. 4 20. 4 0 0. 5 24. 5 0 0. 6 28. 6 0 0. 7 32. 7 0 0. 8 36. 8 0 0
What is a Scene class Scene: def __init__(self): self. objects = [] self. lights = [] def add_object(self, s): self. objects. append(s) def add_light(self, l): self. lights. append(l) 21 November 2020 ECP – IS 1260
Simple Ray Casting for Detecting Visible Surfaces select window on viewplane and center of projection for (each scanline in image) { for (each pixel in the scanline) { determine ray from center of projection through pixel; for (each object in Scene) { if (object is intersected and is closest considered thus far) record intersection and object name; } set pixel’s color to that of closest object intersected; } } 21 November 2020 ECP – IS 1260
Ray Trace 1 Finding Visible Surfaces 21 November 2020 ECP – IS 1260
Ray-Sphere Intersection • Given § Sphere • Center (cx, cy, cz) • Radius, R § Ray from P 0 to P 1 • P 0 = (x 0, y 0, z 0) and P 1 = (x 1, y 1, z 1) § View Point • (Vx, Vy, Vz) • Project to window from (0, 0, 0) to (w, h, 0) 21 November 2020 ECP – IS 1260
Sphere Equation y Center C = (cx, cy, cz) (x, y, z) Radius R R (cx, cy, cz) z 21 November 2020 ECP – IS 1260 x
Ray Equation P 0 = (x 0, y 0, z 0) and P 1 = (x 1, y 1, z 1) P 1 T P 0 The ray from P 0 to P 1 is given by: P(t) = (1 - t)P 0 + t. P 1 = P 0 + t(P 1 - P 0) 21 November 2020 ECP – IS 1260 0 <= t <= 1
Intersection Equation P(t) = P 0 + t(P 1 - P 0) 0 <= t <= 1 is really three equations x(t) = x 0 + t(x 1 - x 0) y(t) = y 0 + t(y 1 - y 0) z(t) = z 0 + t(z 1 - z 0) 0 <= t <= 1 Substitute x(t), y(t), and z(t) for x, y, z, respectively in 21 November 2020 ECP – IS 1260
Solving the Intersection Equation is a quadratic equation in variable t. For a fixed pixel, VP, and sphere, x 0, y 0, z 0, x 1, y 1, z 1, cx, cy, cz, and R eye pixel sphere all constants. We solve for t using the quadratic formula. 21 November 2020 ECP – IS 1260
The Quadratic Coefficients Set dx = x 1 - x 0 dy = y 1 - y 0 dz = z 1 - z 0 Now find the coefficients: 21 November 2020 ECP – IS 1260
Computing Coefficients 21 November 2020 ECP – IS 1260
The Coefficients 21 November 2020 ECP – IS 1260
Solving the Equation 21 November 2020 ECP – IS 1260
The Nearest Intersection The intersection nearest P 0 is given by: To find the coordinates of the intersection point: 21 November 2020 ECP – IS 1260
First Lighting Model • Ambient light is a global constant. Ambient Light = ka (AR, AG, AB) ka is in the “World of Spheres” 0 <= ka <= 1 (AR, AG, AB) = average of the light sources (AR, AG, AB) = (1, 1, 1) for white light • Color of object S = (SR, SG, SB) • Visible Color of an object S with only ambient light CS= ka (AR SR, AG SG, AB SB) • For white light CS= ka (SR, SG, SB) 21 November 2020 ECP – IS 1260
Visible Surfaces Ambient Light 21 November 2020 ECP – IS 1260
Second Lighting Model • Point source light L = (LR, LG, LB) at (Lx, Ly, Lz) • Ambient light is also present. • Color at point p on an object S with ambient & diffuse reflection Cp= ka (AR SR, AG SG, AB SB)+ kd kp(LR SR, LG SG, LB SB) • For white light, L = (1, 1, 1) Cp= ka (SR, SG, SB) + kd kp(SR, SG, SB) • • kp depends on the point p on the object and (Lx, Ly, Lz) kd depends on the object (sphere) ka is global ka + kd <= 1 21 November 2020 ECP – IS 1260
Diffuse Light 21 November 2020 ECP – IS 1260
Lambertian Reflection Model Diffuse Shading • For matte (non-shiny) objects • Examples § Matte paper, newsprint § Unpolished wood § Unpolished stones • Color at a point on a matte object does not change with viewpoint. 21 November 2020 ECP – IS 1260
Physics of Lambertian Reflection • Incoming light is partially absorbed and partially transmitted equally in all directions 21 November 2020 ECP – IS 1260
Geometry of Lambert’s Law N N L θ L d. A 90 - θ θ d. Acos(θ) 90 - θ Surface 1 21 November 2020 ECP – IS 1260 Surface 2
Cos(θ)=N×L N θ L d. A 90 - θ θ d. Acos(θ) 90 - θ Surface 2 Cp= ka (SR, SG, SB) + kd N×L (SR, SG, SB) 21 November 2020 ECP – IS 1260
Finding N N = (x-cx, y-cy, z-cz) |(x-cx, y-cy, z-cz)| normal (x, y, z) radius (cx, cy, cz) 21 November 2020 ECP – IS 1260
Diffuse Light 2 21 November 2020 ECP – IS 1260
Shadows on Spheres 21 November 2020 ECP – IS 1260
More Shadows 21 November 2020 ECP – IS 1260
Sh ad ow R ay Finding Shadows P Pixel gets shadow color 21 November 2020 ECP – IS 1260
Shadow Color • Given Ray from P (point on sphere S) to L (light) P= P 0 = (x 0, y 0, z 0) and L = P 1 = (x 1, y 1, z 1) • Find out whether the ray intersects any other object (sphere). § If it does, P is in shadow. § Use only ambient light for pixel. 21 November 2020 ECP – IS 1260
Shape of Shadows 21 November 2020 ECP – IS 1260
Different Views 21 November 2020 ECP – IS 1260
Planets 21 November 2020 ECP – IS 1260
Starry Skies 21 November 2020 ECP – IS 1260
Shadows on the Plane 21 November 2020 ECP – IS 1260
Finding Shadows on the Back Plane a ay R w do Sh Pixel in Shadow 21 November 2020 ECP – IS 1260 P
Close up 21 November 2020 ECP – IS 1260
On the Table 21 November 2020 ECP – IS 1260
Phong Highlight 21 November 2020 ECP – IS 1260
Phong Lighting Model Light The viewer only sees the light when α is 0. Normal Reflected N L View R V θ θ α Surface 21 November 2020 ECP – IS 1260 We make the highlight maximal when α is 0, but have it fade off gradually.
Phong Lighting Model Cos(α) = R×V We use cosn(α). The higher n is, the faster the drop off. N L R V θ θ α For white light Surface Cp= ka (SR, SG, SB) + kd N�L (SR, SG, SB) + ks (R�V)n(1, 1, 1) 21 November 2020 ECP – IS 1260
Powers of cos(α) Cos 10(α) Cos 20(α) Cos 40(α) Cos 80(α) 21 November 2020 ECP – IS 1260
Computing R L + R = (2 L N) N - L R L N L+R L N 21 November 2020 ECP – IS 1260 L θ θ R
The Halfway Vector H = L+ V |L+ V| Use H�N instead of R�V. H is less expensive to compute than R. From the picture θ+φ=θ-φ+α So φ = α/2. N L H φ θ θ α R V This is not generally true. Why? Surface Cp= ka (SR, SG, SB) + kd N�L (SR, SG, SB) + ks (HN)n (1, 1, 1) 21 November 2020 ECP – IS 1260
Varied Phong Highlights 21 November 2020 ECP – IS 1260
Varying Reflectivity 21 November 2020 ECP – IS 1260
- Harriet fell
- Cs 4300
- The surface area of a jumbo size rubix cube
- How to find the interior angle sum of a polygon
- Feast of trumpets 2028
- 1260
- Programmation agile
- Simbologia ladder
- Programmation lineaire
- Problème de transport en programmation linéaire
- Webavance
- Programmation
- Planification annuelle football
- énuméré synonyme
- Programmation objet php
- Programmation procédurale vs orienté objet
- Problme
- Scheme programmation
- Tableau go
- Theoreme des ecarts complementaire
- Programmation robot abb
- Programmation lineaire
- Programmation orientée aspect
- Programmation
- 01:640:244 lecture notes - lecture 15: plat, idah, farad
- Harriet quimby
- Facts about harriet quimby
- Harriet beecher stowe biografia
- Harriet reich uchtdorf
- Harriet tubman presentation
- Harriet hemings
- Education of harriet tubman
- Underground railroad painting
- Harriet kung
- Anna easter brown
- Important dates for harriet tubman
- Harriet tudmen
- Harriet whiley
- Harriet westbrook
- Harriet tubman comic
- Frederick douglass and harriet jacobs
- Harriet jacobs husband
- John lewis structure
- Harriet kung
- Uncle tom's cabin wikipedia
- Harriet tubman
- Harriet tubman
- Harriet shetler
- Harriet kung doe
- Harriet tubbmen