Presentation is loading. Please wait.

Presentation is loading. Please wait.

COMP 175: Computer Graphics April 2nd, 2018

Similar presentations


Presentation on theme: "COMP 175: Computer Graphics April 2nd, 2018"— Presentation transcript:

1 COMP 175: Computer Graphics April 2nd, 2018
Illumination COMP 175: Computer Graphics April 2nd, 2018

2 Scaling the Perspective View Volume
To find 𝑤 2 , we need to use a bit of trig: 𝑤 2 =tan 𝜃 𝑤 2 ∗𝑓𝑎𝑟 Now, scale to send the X-Coordinates of the far plane to [-1, 1]: 1 tan 𝜃 𝑤 2 ∗𝑓𝑎𝑟 Repeat for the Y-Coordinates, replace 𝜃 𝑤 with 𝜃 ℎ , and scale in the Y-dimension, and we have: 1 tan 𝜃 ℎ 2 ∗𝑓𝑎𝑟 𝜃 𝑤 /2 𝑓𝑎𝑟 𝑤 2 𝜃 ℎ /2 𝑓𝑎𝑟 ℎ 2

3 Camera Angles 𝑤 2 =tan 𝜃 𝑤 2 ∗𝑓𝑎𝑟 1 2 =tan 𝜃 𝑤 2 ∗𝑓𝑎𝑟 ∗ 1 𝑤
We don’t have both 𝜃 𝑤 and 𝜃 ℎ , we are just given a single “camera angle” and the aspect ratio of w and h. So we need to infer one from the other. For example, let’s say that you let camera angle = 𝜃 𝑤 . Then: 𝑤 2 =tan 𝜃 𝑤 2 ∗𝑓𝑎𝑟 Divide w on both sides and multiply h on both sides: 1 2 =tan 𝜃 𝑤 2 ∗𝑓𝑎𝑟 ∗ 1 𝑤 ℎ 2 =tan 𝜃 𝑤 2 ∗𝑓𝑎𝑟 ∗ ℎ 𝑤 Note that you can map camera angle to either 𝜃 𝑤 or 𝜃 ℎ . In my implementation of Camera, my camera angle is mapped to 𝜃 ℎ

4 Summary: Pseudocode for a non-recursive ray tracer: P = eyePoint
for each pixel d = Compute Ray in World Coordinate for each object intersect P+td with object, record t and object Select object with smallest non-negative t value Find intersection point in Object Coordinate Compute normal of the point in Object Coordinate Transform normal to World Coordinate Solve lighting equation in World Coordinate Set Pixel Color

5 Note about Ray An important point about transforming Ray from World space to Object space: Normalize the Ray after it’s created in World space. However, do NOT normalize Ray after the transform into Object Space!! Reason: If you normalize, then the value t you find will be in the object space. When there are many objects, it’s hard to figure out how to compare all the different t values across different object spaces If you do not normalize, then the value t will apply in the world space. That means that you can compare the t values derived from the different objects in the same coordinate. Think about it a little bit… This is the only time in this class where you should not normalize a vector.

6 Overview of Lighting Different types of lighting (diffuse, specular, ambient, etc.) In almost all cases, we need to know about how light bounces off of a surface This means knowing about the normal at the intersection point

7 Normal Vectors at the Intersection Points
We discussed all three steps of Ray Casting The key to Ray Casting is to do geometric computation in object coordinate space, but covert the results to world coordinate space. One mathematical issue involves transforming the normal of a surface point from object coordinate space to world coordinate space…

8 Computing Surface Normal (in Object Coordinate)
As an example, recall the equation for a sphere is: 𝑓(𝑥, 𝑦, 𝑧) = 𝑥 2 + 𝑦 2 + 𝑧 2 – 𝑅 2 If R = 1, then 𝑓(𝑥, 𝑦, 𝑧) = 𝑥 2 + 𝑦 2 + 𝑧 2 –1 Finding the normal of a point can be thought of as finding the gradient which can be done by taking the partial derivative of he equation: 𝜕𝑓 𝜕𝑥 𝑥, 𝑦, 𝑧 =2𝑥, 𝜕𝑓 𝜕𝑦 𝑥, 𝑦, 𝑧 =2𝑦, 𝜕𝑓 𝜕𝑧 𝑥, 𝑦, 𝑧 =2𝑧 So the gradient is: 𝑛=𝛻𝑓 𝑥, 𝑦, 𝑧 =(2𝑥, 2𝑦, 2𝑧) After normalization, 𝑛 = (𝑥, 𝑦, 𝑧)

9 Normal Vector Transformed
We have a normal vector in object coordinate We need a world-coordinate normal vector to compute the illumination model How do we transform a point or a vector from the object coordinate to the world coordinate? We apply the object’s transformation matrix M Can we treat the normal the same way? Answer: no…

10 Normal Vector Transformed
Can we treat the normal the same way? Answer: no… 𝒏 𝒘𝒐𝒓𝒍𝒅 ≠ 𝑴 𝒕 𝒏 𝒐𝒃𝒋𝒆𝒄𝒕 Here’s an example of why that is: Say that M scales in x by ½, and y by 2 Wrong! Normal must be perpendicular Mnobject nobject

11 What Happened? Why doesn’t this work?
Well, actually it does work for translation, rotation, and uniform scaling Let’s test it out… Non-uniform scale causes a problem: The normal is distorted in exactly the opposite of what we want. Example below: Scale by 2 in x, 1 in y nobject <0.5, 0.5> <0.25, 0.5> <1.0, 0.5>

12 So How Do I Do This? If we can’t use 𝑀, but some kind of inverse of it, then what does it look like, (𝑀 −1 ) −1 ? Nope, the answer is 𝑀 −1 𝑇 , because: we need to invert the non-uniform scale, but not disturb the rotation component (same as in as M) we don’t care about translation because vectors can’t be translated Recall that 𝑅 −1 = 𝑅 𝑇 , so we can invert the matrix 𝑀 to 𝑀 −1 , but then “un-apply” the rotation component by adding in the transpose. The addition of the transpose does not affect the scale matrix because the scale matrix is a diagonal matrix whose transpose remains the same as the original 𝑆 𝑥, 𝑦, 𝑧 𝑇 = 𝑆(𝑥, 𝑦, 𝑧) 𝑆 𝑥, 𝑦, 𝑧 −1 𝑇 = 𝑆 𝑥, 𝑦, 𝑧 −1 = 𝑆(1/𝑥, 1/𝑦, 1/𝑧)

13 A More Rigorous Proof 𝒏 𝑤𝑜𝑟𝑙𝑑 ∙ 𝑀 3 𝒗 𝑜𝑏𝑗 =0 𝒏 𝑤𝑜𝑟𝑙𝑑 ∙ 𝒗 𝑤𝑜𝑟𝑙𝑑 =0
Let’s compute the relationship between object-space normal 𝒏 𝑜𝑏𝑗 to polygon H and world-space normal 𝒏 𝑤𝑜𝑟𝑙𝑑 to transformed version of H, called MH For a vector 𝒗 in the world space that lies in the polygon (e.g., one of its edge vectors), the normal is perpendicular to 𝒗: 𝒏 𝑤𝑜𝑟𝑙𝑑 ∙ 𝒗 𝑤𝑜𝑟𝑙𝑑 =0 But 𝒗 𝑤𝑜𝑟𝑙𝑑 is just a transformed version of some vector in object space, 𝒗 𝑜𝑏𝑗 , so we could write: 𝒏 𝑤𝑜𝑟𝑙𝑑 ∙𝑀 𝒗 𝑜𝑏𝑗 =0 Recall that since vectors have no position, they are unaffected by translations (w = 0) So we need to only consider: 𝑀 3 =upper left 3x3 of 𝑀 (the rotation / scaling components) 𝒏 𝑤𝑜𝑟𝑙𝑑 ∙ 𝑀 3 𝒗 𝑜𝑏𝑗 =0

14 A More Rigorous Proof 𝒏 𝑤𝑜𝑟𝑙𝑑 𝑡 𝑀 3 𝒗 𝑜𝑏𝑗 =0 𝒏 𝑤𝑜𝑟𝑙𝑑 ∙( 𝑀 3 𝒗 𝑜𝑏𝑗 )=0
The next step is to write this: 𝒏 𝑤𝑜𝑟𝑙𝑑 ∙( 𝑀 3 𝒗 𝑜𝑏𝑗 )=0 As this: ( 𝑀 3 𝑡 𝒏 𝑤𝑜𝑟𝑙𝑑 )∙ 𝒗 𝑜𝑏𝑗 =0 Recall that if we think of vector as 𝑛𝑥1 matrix, then switching notation, 𝒂∙𝒃= 𝒂 𝒕 𝒃 Rewriting our original formula, we thus have: 𝒏 𝑤𝑜𝑟𝑙𝑑 𝑡 𝑀 3 𝒗 𝑜𝑏𝑗 =0 Writing 𝑀= 𝑀 𝑡 𝑡 , we get: 𝒏 𝑤𝑜𝑟𝑙𝑑 𝑡 𝑀 3 𝑡𝑡 𝒗 𝑜𝑏𝑗 =0 Recall that 𝐵 𝑡 𝐴 𝑡 = 𝐴𝐵 𝑡 , we can re-write this as: 𝑀 3 𝑡 𝒏 𝑤𝑜𝑟𝑙𝑑 𝑡 𝒗 𝑜𝑏𝑗 =0 Switching back to dot product notation, our result:

15 A More Rigorous Proof 𝒏 𝑜𝑏𝑗 ∙ 𝒗 𝑜𝑏𝑗 =0 So, we have:
𝑀 3 𝑡 𝒏 𝑤𝑜𝑟𝑙𝑑 ∙ 𝒗 𝑜𝑏𝑗 =0 We also already have: 𝒏 𝑜𝑏𝑗 ∙ 𝒗 𝑜𝑏𝑗 =0 Therefore: 𝑀 3 𝑡 𝒏 𝑤𝑜𝑟𝑙𝑑 = 𝒏 𝑜𝑏𝑗 Left-multiplying by 𝑀 3 𝑡 −1 : 𝑀 3 𝑡 −1 𝑀 3 𝑡 𝒏 𝑤𝑜𝑟𝑙𝑑 = 𝑀 3 𝑡 −1 𝒏 𝑜𝑏𝑗 𝒏 𝑤𝑜𝑟𝑙𝑑 = 𝑀 3 𝑡 −1 𝒏 𝑜𝑏𝑗 𝒏 𝑤𝑜𝑟𝑙𝑑 = 𝑀 3 −1 t 𝒏 𝑜𝑏𝑗

16 Questions?

17 What is Light? Can be thought of as small packets of photons
When an electron drops from a higher level orbit to a lower orbit, energy is emitted as photons Different energy levels of electrons allow for different wavelengths of light to be reflected Metals have “loose” electrons, which can move relatively freely and occupy many different levels, which is why they are more reflective Insulators have more constrained electrons which cannot change energy levels as easily, so they convert more absorbed light into heat instead of reflecting it

18 What is Light? Another way to think of light is to treat it as a continuous wave (as opposed to discrete photons) The wavelength (𝜆) of a wave is measured as the distance from one peak of wave to the next Different colors correspond to different wavelengths Visible light has a wavelength between 400nm – 700nm Different ways of thinking about light (photons vs. waves) can result in different rendering styles

19 Illumination Problem:
In ray casting, we have generated a ray (from the eye through a pixel), found the point in which the ray intersects with an object Now we want to determine the color and brightness of that point so that we can color in the pixel Solution: we model the interactions between light sources and the surface

20 Illumination Models An “illumination model” describes inputs, assumptions, and outputs used to calculate illumination (color / brightness) of surface elements Usually includes Light attributes (intensity, color, position, direction, shape) Object surface properties (color, reflectivity, transparency, etc.) Interaction between lights and objects

21 Physically-based Illumination Models
Some models of illumination are based on real physics Require accurate input data and make few assumptions Rarely have enough information to specify all inputs Takes a long time to compute Non-Physically-Based Illumination Models Just need a model that looks good enough for a specific application Emphasis on speed and efficiency (use of resources like memory, CPU, etc.)

22 Light Attenuation: Inverse Square Law
The amount that a light illuminates an object decreases with the square of the distance between them. This is known as Light Attenuation. Inverse square law: for a given 3D angle (solid angle), the area it covers grows with the square of the distance Intensity of light per unit area falls off with the inverse square Conversely, for a fixed area, the angle it covers decreases with the square of the distance

23 Basic Light Sources As part of illumination models, one can specify whether the light intensity varies with the distance between the object and the light source

24 Illumination Models Local Illumination Global Illumination
Takes only direct lighting information Is an approximation of global illumination Usually involves the use of an “ambient” term to simulate indirect lighting Global Illumination Most light striking a surface element comes directly from a light emitting source (direct illumination) Sometimes light from a source is blocked by another object, resulting in shadows However, objects in the shadow can still receive light from light bouncing off other objects (indirect illumination)

25 Example 1: Local Illumination
Only considers the light, the observer position, and the object’s material properties OpenGL does this.

26 Example 2: Global Illumination
Takes into account of the interaction of light from all the surfaces in the scene Recursive ray tracing is an example. It models light rays bouncing between objects

27 Example 3: Global Illumination, Radiosity
Models energy moving from emitters (light sources) into the scene as patches Is view independent

28 Examples of Global Illumination
Direct illumination + specular reflection Ray trace + soft shadows and caustics Ray trace + caustic photon map + diffuse reflection (color bleeding) Ray trace + caustic and diffuse photon maps

29 Questions?

30 Simple Local Illumination (Phong)
The model used by OpenGL Reduce the light model to 3 simple components: Ambient Diffuse Specular Illumination (color intensity) of a point is equal to: Intensity = ambient + diffuse + specular Materials reflect each component differently Specified as material reflection coefficients: 𝐾 𝑎 , 𝐾 𝑑 , 𝐾 𝑠

31 Ambient Light Contribution
Ambient light = background light As noted before, it is used to simulate indirect lighting Ambient component Independent of Object’s position Viewer’s position Light source’s position Dependent of A constant factor (in each of the R, G, B channels)

32 Diffuse Light Contribution
Diffuse light = illumination that a surface receives from a light source that reflects equally in all directions Independent of: Viewer’s position Dependent of: Light’s position Surface property (normal, reflectance property)

33 Diffuse Light Calculation
Need to know how much light a point on the object receives from the light source Solution based on Lambert’s Law Point receives more light Point receives less light

34 Diffuse Light Calculation
Lambert’s Law: The radiant energy D that a small surface patch (or a point) receives from a light source is: Diffuse = 𝐾 𝑑 𝑥 𝐼 𝑥 cos⁡(𝜃) 𝐾 𝑑 = diffuse reflection constant I = light intensity 𝜃 = angle between the light vector and the surface normal How do we compute cos⁡(𝜃)? 𝑁∙𝐿 (dot product between N and L) As the angle between the light and the normal increases, the light’s energy spreads across a larger area The hemisphere represents equal magnitude of the reflected intensity for any outgoing vector.

35 Diffuse Light Examples
Diffuse = 𝐾 𝑑 𝑥 𝐼 𝑥 cos⁡(𝜃) For I = 1.0

36 Specular Light Contribution
Specular light = light reflection from shiny surfaces Color depends on material and how it scatters light Shiny surfaces (metal, mirror, etc.) reflect more light Specular light depends on both light source position and view position

37 Specular Light Calculation
𝜙 is the angle between the view direction and the reflective vector When 𝜙 is small, the viewer sees more specular light

38 Specular Light Calculation
The Phong lighting model (not the Phong shading model) Specular = 𝐾 𝑠 𝑥 𝐼 𝑥 cos 𝑓 (𝜙) 𝐾 𝑠 = specular reflection constant 𝐼 = light intensity 𝜙 = angle between reflective ray and view vector 𝑓 = surface property for specular highlight

39 Specular Light Calculation
Specular = 𝐾 𝑠 𝑥 𝐼 𝑥 cos 𝑓 (𝜙) Shape of the Gaussian Diffuse hemisphere with specular Gaussian surface

40 Specular Light Examples
Specular = 𝐾 𝑠 𝑥 𝐼 𝑥 cos 𝑓 (𝜙) For I = 1.0

41 Variation in Diffuse and Specular
Putting Diffuse and Specular together in our local illumination model

42 Direct Illumination = ambient + diffuse + specular
Lighting Equation Direct Illumination = ambient + diffuse + specular color = 𝐾 𝑎 𝑥 𝐼 + 𝐾 𝑑 𝑥 𝐼 𝑥 (𝑁∙𝐿) + 𝐾 𝑠 𝑥 𝐼 𝑥 𝑅∙𝑉 𝑓 If there are m lights, we sum over each light color = 𝐾 𝑎 𝑥 𝐼 + 𝑚 ( 𝐾 𝑑 𝑥 𝐼 𝑚 𝑥 (𝑁∙ 𝐿 𝑚 ) + 𝐾 𝑠 𝑥 𝐼 𝑚 𝑥 𝑅 𝑚 ∙𝑉 𝑓 ) color = 𝐾 𝑎 𝑥 𝐼 + 𝑚 𝐼 𝑚 𝑥 ( 𝐾 𝑑 𝑥 (𝑁∙ 𝐿 𝑚 ) + 𝐾 𝑠 𝑥 𝑅 𝑚 ∙𝑉 𝑓 )

43 Finding the Reflective Ray
𝑟 =𝑑−2( 𝑑 ∙ 𝑛 ) 𝑛 Rationale: think about it, r is very much similar to d: r_horizontal = d_horizontal r_vertical = -d_vertical So we just have to find d_horizontal and d_vertical: 𝑑 𝑣𝑒𝑟𝑡 = 𝑑 ∙ 𝑛 𝑛 𝑑 ℎ𝑜𝑟𝑖𝑧 = 𝑑 − 𝑑 ∙ 𝑛 𝑛 r = r_vertical + r_horizontal r = -d_vertical + d_horizontal

44 Adding in Object Color Since the color we perceive is based on the color of the light and the color of the object, we need to model both terms: color = 𝐾 𝑎 𝑥 𝐼 𝑥 𝑶 𝒂 + 𝐾 𝑑 𝑥 𝐼 𝑥 𝑶 𝒅 𝑥 (𝑁∙𝐿) + 𝐾 𝑠 𝑥 𝐼 𝑥 𝑶 𝒔 𝑥 𝐻∙𝑁 𝑓 For multiple lights: color = 𝐾 𝑎 𝑥 𝐼 𝑥 𝑂 𝑎 + 𝑚 𝐼 𝑚 𝑥 ( 𝐾 𝑑 𝑥 𝑂 𝑑 𝑥 (𝑁∙ 𝐿 𝑚 ) + 𝐾 𝑠 𝑥 𝑂 𝑠 𝑥 𝐻 𝑚 ∙𝑁 𝑓 ) Adding in light attenuation (how quickly light falls off as distance increases): color = 𝐾 𝑎 𝑥 𝐼 𝑥 𝑂 𝑎 + 𝑚 𝒇 𝒂𝒕 𝒕 𝒎 𝑥 𝐼 𝑚 𝑥 ( 𝐾 𝑑 𝑥 𝑂 𝑑 𝑥 (𝑁∙ 𝐿 𝑚 ) + 𝐾 𝑠 𝑥 𝑂 𝑠 𝑥 𝐻 𝑚 ∙𝑁 𝑓 )

45 Make sure that you normalize your normals!!
Debug Lighting Issues Make sure that you normalize your normals!! Since all calculations are based on surface normals (e.g. dot product with normals), if your normals are bad, you’re stuck.

46 Summary: Pseudocode for a non-recursive ray tracer: P = eyePoint
for each pixel d = Compute Ray in World Coordinate for each object intersect P+td with object, record t and object Select object with smallest non-negative t value Find intersection point in Object Coordinate Compute normal of the point in Object Coordinate Transform normal to World Coordinate for each light Solve lighting equation in World Coordinate Set Pixel Color

47 Questions?

48 Shading vs. Lighting How is Shading different from Lighting?
Lighting evaluates the lighting equation at each point on the surface of an object Shading is kind of a “hack” that computes only lighting equations on the vertices, and interpolates the pixels in between

49 Shading Models – Flat/Constant
We define a normal at each polygon (not at each vertex) Lighting: Evaluate the lighting equation at the center of each polygon using the associated normal Shading: Each sample point on the polygon is given the interpolated lighting value at the vertices (i.e. a total hack)

50 Shading Models – Gouraud
We define a normal vector at each vertex Lighting: Evaluate the lighting equation at each vertex using the associated normal vector Shading: Each sample point’s color on the polygon is interpolated from the color values at the polygon’s vertices which were found in the lighting step

51 Shading Models – Phong Each vertex has an associated normal vector
Lighting: Evaluate the lighting equation at each vertex using the associated normal vector Shading: For every sample point on the polygon we interpolate the normals at vertices of the polygon and compute the color using the lighting equation with the interpolated normal at each interior pixel

52 Shading Models Compared
Constant shading:  no interpolation, pick a single representative intensity and propagate it over entire object.  Loses almost all depth cues. Pixar “Shutterbug” images from: /scanline/shade_models/shading.htm

53 Shading Models Compared
Flat or Faceted Shading: constant intensity over each face Constant Shading

54 Shading Models Compared
Gouraud Shading: Linear Interpolation of intensity across triangles to eliminate edge discontinuity Flat Shading

55 Shading Models Compared
Phong Shading: Interpolation of vertex surface normals Note: specular highlights but no shadows. Still a pure local illumination model Gouraud Shading

56 Shading Models Compared
Global Illumination: Objects enhanced using shadow, texture, bump, and reflection mapping (see S20) Phong Shading

57 Shading Models Explained (1/6: Faceted)
Faceted Shading: Single illumination value per polygon (GL_FLAT) With many polygons approximating a curved surface, this creates an undesirable faceted look. Facets exaggerated by “Mach banding” effect

58 Shading Models Explained (2/6: Gouraud)
Illumination intensity interpolation (GL_SMOOTH) Illumination values are computed at vertices, linearly interpolated across the pixels of the polygon Eliminates intensity discontinuities at polygon edges; still have gradient discontinuities, Mach banding is largely ameliorated, not eliminated Must differentiate desired creases from tesselation artifacts (edges of cube vs. edges on tesselated sphere) Step 1: Compute vertex normals by averaging surrounding polygon normals 𝑁 2 𝑁 𝑣 𝑁 3 𝑁 1 𝑁 𝑣 = 𝑖=1 𝑛 𝑁 𝑖 𝑖=1 𝑛 𝑁 𝑖 𝑁 4

59 Shading Models Explained (3/6: Gouraud cont.)
Step 2: Evaluate illumination at each vertex using lighting model ( 𝐼 1 , 𝐼 2 , 𝐼 3 ) Step 3: Interpolate illumination along polygon edges ( 𝐼 𝑎 , 𝐼 𝑏 ) Step 4: Interpolate illumination along scan lines ( 𝐼 𝑝 ) scan line November 13, 2018

60 Shading Models Explained (4/6: Gouraud cont.)
Takes advantage of scan line algorithm for efficiency ∆𝐼 ∆𝑦 is constant along polygon edge, ∆𝐼 ∆𝑥 is constant along scan line Gouraud vs. Faceted shading:

61 Shading Models Explained (5/6: Gouraud cont.)
Gouraud shading can miss specular highlights because it interpolates vertex colors instead of calculating intensity directly at each point, or interpolating vertex normals Na and Nb would cause no appreciable specular component, whereas Nc would. Interpolating between Ia and Ib misses the highlight that evaluating I at c would catch Phong shading: Interpolated normal comes close to the actual normal of the true curved surface at a given point Reduces temporal “jumping” affect of highlight, e.g., when rotating sphere during animation (example on next slide)

62 Shading Models Explained (6/6: Phong Shading)
Phong Model: normal vector interpolation Interpolate N rather than I Always captures specular highlights, but computationally expensive At each pixel, N is recomputed and normalized (requires sq. root operation) Then I is computed at each pixel (lighting model is more expensive than interpolation algorithms) This is now implemented in hardware, very fast Looks much better than Gouraud, but still no global effects Gouraud Phong Gouraud Phong

63 Gouraud vs. Phong Shading

64 Additional Material

65 Using Halfway Vector for Speed (Blinn-Phong)
Calculating reflection vector is expensive As an approximation (don’t do this for your assignments), graphics people will use the halfway vector: h = s + v Don’t forget to normalize!! Instead of using 𝜙, we would use 𝛽 as an approximation The results will be incorrect (note when h = n), but it is possible to achieve “good enough” results by playing with the parameter f.

66 Lighting Equation Using Halfway Vector
Direct Illumination = ambient + diffuse + specular color = 𝐾 𝑎 𝑥 𝐼 + 𝐾 𝑑 𝑥 𝐼 𝑥 (𝑁∙𝐿) + 𝐾 𝑠 𝑥 𝐼 𝑥 𝐻∙𝑁 𝑓 If there are m lights, we sum over each light color = 𝐾 𝑎 𝑥 𝐼 + 𝑚 𝐼 𝑚 𝑥 ( 𝐾 𝑑 𝑥 (𝑁∙ 𝐿 𝑚 ) + 𝐾 𝑠 𝑥 𝐻 𝑚 ∙𝑁 𝑓 )

67 Choosing the Constants
Here are some examples for the constants used in the previous equation. Note that since objects might have different properties for different color channels (R, G, B)

68 Lights in OpenGL This would have been useful for your SceneView assignment… Defining lights:

69 Enable lighting, you need to do both:
Lights in OpenGL Setting the light position as (0, 0, 1, 1) means that the light is a point light. Setting the light position as (0, 0, 1, 0) means that the light is a directional light (infinite light) Enable lighting, you need to do both: glEnable (GL_LIGHTING); glEnable (GL_LIGHT0); // for light 0. Light1 for light 1, etc.

70 Materials in OpenGL Material Example:

71 Birectional Reflectance Distribution Function (BRDF)
We have looked at a simple model of how light scatters as a function: Direction of scattering is determined by the material Intensity at a given outgoing direction is dependent on incoming direction and material properties This type of function that measures reflectance is called the “Birectional Reflectance Distribution Function (BRDF)”, denoted 𝜌 (rho) diffuse reflections reflected scatter distribution BRDF incident light beam Image credit: © Ben Herila, 2010 specular reflection (big) surface

72 with BSSRDF scattering
The BRDF can be generalized to model transmission through an object (i.e., Refraction) and sub-surface scattering by defining other terms, such as the Bidirectional scattering surface reflectance distribution function (BSSRDF) No scattering with BSSRDF scattering

73 Modeling Reflectance There are many more complex and more accurate BRDFs Researchers collect tables of data for B*DFs of specific materials using devices like the one pictured Image credit: Chuck Moidel

74 Rendering Equation (Kajiya, 1986)
fr is the BRDF function L is light toward position x Subscript i is for (inward), o for (outward), e for (emission) Rendering Equation (Kajiya, 1986) 𝐿 𝑜 𝑥, 𝜔 𝑜 , 𝜆, 𝑡 = 𝐿 𝑒 𝑥, 𝜔 𝑜 ,𝜆, 𝑡 + Ω 𝑓 𝑟 𝑥, 𝜔 𝑖 , 𝜔 𝑜 ,𝜆, 𝑡 𝐿 𝑖 𝑥, 𝜔 𝑖 , 𝜆, 𝑡 𝜔 𝑖 ∙𝑛 𝑑 𝜔 𝑖

75 Rendering Equation (Kajiya, 1986)
𝐿 𝑜 𝑥, 𝜔 𝑜 , 𝜆, 𝑡 = 𝐿 𝑒 𝑥, 𝜔 𝑜 ,𝜆, 𝑡 + Ω 𝑓 𝑟 𝑥, 𝜔 𝑖 , 𝜔 𝑜 ,𝜆, 𝑡 𝐿 𝑖 𝑥, 𝜔 𝑖 , 𝜆, 𝑡 𝜔 𝑖 ∙𝑛 𝑑 𝜔 𝑖 Sometimes you see this written as (without lambda (wavelength)and time) 𝐿 𝑜 𝑥, 𝜔 𝑜 = 𝐿 𝑒 𝑥, 𝜔 𝑜 + Ω 𝑓 𝑟 𝑥, 𝜔 𝑖 , 𝜔 𝑜 𝐿 𝑖 𝑥, 𝜔 𝑖 𝜔 𝑖 ∙𝑛 𝑑 𝜔 𝑖 𝐿 𝑜 𝑥, 𝜔 𝑜 = 𝐿 𝑒 𝑥, 𝜔 𝑜 + 𝑡 𝜆 Ω 𝑓 𝑟 𝑥, 𝜔 𝑖 , 𝜔 𝑜 𝐿 𝑖 𝑥, 𝜔 𝑖 𝜔 𝑖 ∙𝑛 𝑑 𝜔 𝑖 𝑑𝜆 𝑑𝑡

76 Questions?


Download ppt "COMP 175: Computer Graphics April 2nd, 2018"

Similar presentations


Ads by Google