computer graphics seminar
play

Computer Graphics Seminar MTAT.03.305 Spring 2020 Raimond Tunnel - PowerPoint PPT Presentation

Computer Graphics Seminar MTAT.03.305 Spring 2020 Raimond Tunnel Previously... v 2 M = M 1 M 2 M 3 ... Data v 0 v 1 v 2 ( v w ) v x , v y , v z P V M v Vertex v w v w v 0 v 1 transformations v 2 v 2 Vertex shader


  1. Computer Graphics Seminar MTAT.03.305 Spring 2020 Raimond Tunnel

  2. Previously... v 2 M = M 1 ⋅ M 2 ⋅ M 3 ⋅ ... Data v 0 v 1 v 2 ( v w ) v x , v y , v z P ⋅ V ⋅ M ⋅ v Vertex v w v w v 0 v 1 transformations v 2 v 2 Vertex shader Culling & Clipping vs v 0 v 1 v 1 v 0 Rasterization Fragment shading Visibility tests & Blending

  3. Previously... ● We define our geometry (points, lines, triangles) ● We apply transformations (matrices) ( cos ( 45 ° ) ) cos ( 45 ° ) − sin ( 45 ° ) = sin ( 45 ° ) When is this true?

  4. Now We Add Color? What exactly is here? Adding color... ?

  5. Material Properties ● We want GPU to take into account a color property when rendering some geometry. What is depicted here? http://cgdemos.tume-maailm.pri.ee/

  6. Material Properties ● We want GPU to take into account a color property when rendering some geometry. Red cube? Two red trapezoids? Flat red polygon? http://cgdemos.tume-maailm.pri.ee/

  7. What is color?

  8. What Is Color? ● Spectrum of the light reflected off a surface.

  9. What Is Color? ● Spectrum of the light reflected off a surface. ● In 3D it is not enough to just say that a thing is red .

  10. What Is Color? ● Spectrum of the light reflected off a surface. ● In 3D it is not enough to just say that a thing is red . ● We need to say that somewhere we have a some kind of light source . *not to scale

  11. Directional Light ● Ok, we define a light direction and our surface

  12. Directional Light ● Light reflects by the incident angle, right?

  13. Directional Light ● The viewer does not see the surface at x=5?

  14. Diffuse Reflection ● Reality – our surfaces are diffusely reflective!

  15. Diffuse Reflection ● Light entering at a specific angle

  16. Diffuse Reflection ● Photon excites an atom

  17. Diffuse Reflection ● The energy is transferred to the next atom

  18. Diffuse Reflection ● The energy is transferred to the next atom ● Some energy is absorbed

  19. Diffuse Reflection ● Excited atoms vibrate, giving off heat

  20. Diffuse Reflection ● Finally photon exits the surface

  21. Diffuse Reflection ● In a quite random direction

  22. Diffuse Reflection ● This is generally how pigments work Nice post: https://physics.stackexchange.com/a/240848

  23. Diffuse Reflection ● Can be caused by other reasons too!

  24. Diffuse Reflection ● Can be caused by other reasons too! ● For example structural coloration in nature. https://en.wikipedia.org/wiki/Pollia_condensata All of these feathers are actually brown.

  25. Diffuse Reflection ● Can be caused by other reasons too! ● For example structural coloration in nature.

  26. Diffuse Reflection ● We assume diffuse light scatters uniformly

  27. Diffuse Reflection ● So all we need now is the angle between the surface normal and the Light Direction . More correct is: direction towards the light ● Why this angle?

  28. Diffuse Reflection Hint?

  29. Diffuse Reflection ● The actual light energy per surface unit depends on the angle. 1 1 cos ( 26.57 ° )≈ 1.12 cos ( 55.82 ° )≈ 1.72

  30. Diffuse Reflection ● In CG we are interested in how much light reaches 1 surface unit (pixel). cos ( 26.57 ° )≈ 0.89 cos ( 55.82 ° )≈ 1.72 Pixel

  31. Diffuse Reflection & Directional Light ● Given a surface point and a light source, we can calculate the color of that surface point. ● We use a cosine between the surface normal and a vector l going towards the light source .

  32. The Dot Product ● To find the cosine of the angle, we can use a scalar / dot product operation. v ⋅ u =∣ ∣ v ∣ ∣ ⋅ ∣ ∣ u ∣ ∣ ⋅ cos ( angle ( u , v )) Geometric definition

  33. The Dot Product ● To find the cosine of the angle, we can use a scalar / dot product operation. v ⋅ u =∣ ∣ v ∣ ∣ ⋅ ∣ ∣ u ∣ ∣ ⋅ cos ( angle ( u , v )) v ⋅ u = v 1 ⋅ u 1 + v 2 ⋅ u 2 + v 3 ⋅ u 3 Algebraic definition

  34. The Dot Product ● To find the cosine of the angle, we can use a scalar / dot product operation. v ⋅ u =∣ ∣ v ∣ ∣ ⋅ ∣ ∣ u ∣ ∣ ⋅ cos ( angle ( u , v )) Geometric definition v ⋅ u = v 1 ⋅ u 1 + v 2 ⋅ u 2 + v 3 ⋅ u 3 Algebraic definition ● When we have normalized (unit) vectors, geometric definition simplifies to: v ⋅ u =∣ ∣ v ∣ ∣ ⋅ ∣ ∣ u ∣ ∣ ⋅ cos ( α )= 1 ⋅ ⋅ cos ( α )= cos ( α ) 1

  35. The Dot Product ● So if we put those two definitions together: v ⋅ u = v 1 ⋅ u 1 + v 2 ⋅ u 2 + v 3 ⋅ u 3 = cos ( α ) This should be quite easy for the computer to calculate...

  36. The Dot Product ● The dot product and the cosine between two vectors are used quite often in CG.

  37. The Dot Product ● Dot product of two vectors u and v is the same as vector multiplication. v 3 ) ⋅ ( u 3 ) u 1 = v T u v ⋅ u = v 1 ⋅ u 1 + v 2 ⋅ u 2 + v 3 ⋅ u 3 = ( v 1 v 2 u 2 ● So for our surface point we get: T ⋅ surfaceNormal Intensity = directionTowardsLight T ⋅ n I = l What is the visual result of that? I ∈[ 0,1 ]

  38. Diffuse Reflection & Directional Light ● Two missing things: ● Intensity of the light source L ∈[ 0, 1 ] ● Reflectivity of our material M ∈[ 0, 1 ]

  39. Diffuse Reflection & Directional Light ● Also the color! ● We apply to each of 3 RGB channels. T ⋅ I R = n l ⋅ L R ⋅ M R Light that light source emits T ⋅ l ⋅ L G ⋅ M G I G = n T ⋅ l ⋅ L B ⋅ M B I B = n Light that material reflects

  40. Diffuse Reflection & Directional Light f i s e l p p a e ? h m t e e r h a t r n o o l p o c u t s a e h n W i h s t h g i l d e r W h a t i s t h w i r s o e n x g a m w ( 2 i + p t h l e t h ? i n g s )

  41. Point Light ● Point lights work the same way, but the light source is a point.

  42. Point Light ● Sometimes distance attenuation parameters are added. Far away Close

  43. Point Light ● Distance attenuation parameters: ● In OpenGL: 1 attenuation = 2 k c + k l ⋅ d + k q ⋅ d U s u a l l y 1 ( w h y y ? l l ) a c i s y h p s i ● In Three.js: s i h T t c e r r o c PointLight(hex, intensity, distance) Distance - If non-zero, light will attenuate linearly from maximum intensity at light position down to zero at distance. https://threejs.org/docs/#api/en/lights/PointLight

  44. Ambient Light ● So, now we have 2 lights and a diffuse surface. ● Are we OK?

  45. Ambient Light ● World contains much more than 1 cube and a light source. ● Do you know what scene this is? ● Calculating every reflection from every other object is time- consuming. ● What can we do?

  46. Ambient Light ● Ambient light source – estimates the light reflected off of other objects in the scene

  47. Ambient Light ● Ambient light source – estimates the light reflected off of other objects in the scene ● Ambient material property – how much object reflects that light (usually same as diffuse)

  48. Ambient Light ● Ambient light source – estimates the light reflected off of other objects in the scene ● Ambient material property – how much object reflects that light (usually same as diffuse)

  49. Lambert Material ● So together with diffuse lighting we get: T ⋅ l ⋅ L D R ⋅ M D R I R = L A R ⋅ M A R + n Red channel T ⋅ l ⋅ L D G ⋅ M D G I G = L A G ⋅ M A G + n Green channel T ⋅ l ⋅ L D B ⋅ M D B I B = L A B ⋅ M A B + n Blue channel What could go wrong? Ambient term Diffuse term

  50. Is this it? ● Well, we have already made a very rough approximation of reality with the ambient term. ● Is there anything else that we have forgotten?

  51. Specular Reflection ● Materials also do reflect light specularly.

  52. Specular Reflection ● Materials also reflect light specularly. ● Especially varnished materials and metals!

  53. Specular Reflection ● Materials also reflect light specularly. ● Especially varnished materials and metals! ● Specular reflection is the direct reflection of the light from the environment.

  54. Specular Reflection ● Materials also reflect light specularly. ● Especially varnished materials and metals! ● Specular reflection is the direct reflection of the light from the environment. ● Often we want just a specular highlight – – that is the reflection of the light source !

  55. Specular Highlight ● Depends on the viewer's position.

  56. Specular Highlight ● At point 4, which viewer direction should produce more intense specular highlight?

  57. Specular Highlight ● How to calculate that based on β?

  58. Specular Highlights ● Ok, so add a specular term based on the actual reflection direction ( r ) and viewer direction ( v ). T ⋅ T ⋅ v ⋅ L S R I R = L A R ⋅ M A R + n l ⋅ L D R ⋅ M D R + r ⋅ M S R I G = L A G ⋅ M A G + n T ⋅ ⋅ M D G + r T ⋅ v ⋅ L S G ⋅ M S G l ⋅ L D G T ⋅ T ⋅ I B = L A B ⋅ M A B + n l ⋅ L D B ⋅ M D B + v r ⋅ L S B ⋅ M S B

Recommend


More recommend