computer graphics seminar
play

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

Computer Graphics Seminar MTAT.03.305 Spring 2019 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 1 transformations v 0 v w v w v 2 v 2 Vertex shader


  1. Computer Graphics Seminar MTAT.03.305 Spring 2019 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 1 transformations v 0 v w v w 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 .

  11. Directional light ● Ok, we define a light direction

  12. Directional light ● Ok, we define a light direction ● A surface

  13. Directional light ● Ok, we define a light direction ● A surface ● Viewer

  14. Directional light ● Ok, we define a light direction ● A surface ● Viewer Viewer does not see surface point at 4?

  15. Directional light ● Reality – our surfaces are diffusely reflective!

  16. Diffuse Reflection ● Light entering at a specific angle

  17. Diffuse Reflection ● Photon excites an atom

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

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

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

  21. Diffuse Reflection ● Finally photon exits the surface

  22. Diffuse Reflection ● In a quite random direction

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

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

  25. 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.

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

  27. Diffuse Reflection ● Let's assume diffuse light scatters uniformly

  28. Diffuse Reflection ● So all we need now is the angle between the surface normal and the light's direction . More correct is direction towards the light By the way, the scattered light intensities may not be equal in all directions... See glossy reflection . ● Why this angle?

  29. Diffuse Reflection Hint?

  30. Diffuse Reflection ● The actual light energy per surface unit depends on the angle. 1 1 cos ( 80.81 ° )≈ 6.26 cos ( 45 ° )≈ 1.42

  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 going towards the light source .

  32. Diffuse Reflection & Directional Light ● 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. Diffuse Reflection & Directional Light ● 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. Diffuse Reflection & Directional Light ● 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 ● Because we have normalized (unit) vectors, geometric definition simplifies to: v ⋅ u =∣ ∣ v ∣ ∣ ⋅ ∣ ∣ u ∣ ∣ ⋅ cos ( α )= 1 ⋅ ⋅ cos ( α )= cos ( α ) 1

  35. Diffuse surface and directional light ● 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. Diffuse surface and directional light ● The dot product and the cosine between two vectors are used quite often in CG.

  37. Diffuse surface and directional light ● 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 I ∈[ 0,1 ] What is the visual result of that?

  38. Diffuse surface and directional light ● Two missing things: ● Intensity of the light source L ∈[ 0, 1 ] ● Reflectivity of our material M ∈[ 0, 1 ]

  39. Diffuse surface and 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 surface and 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 s t 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 l h 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 ● Sometimes distance attenuation parameters are added. 1 ● In OpenGL: 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 s ● In Three.js: 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. http://threejs.org/docs/#Reference/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 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 specular highlight?

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

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