Presentation is loading. Please wait.

Presentation is loading. Please wait.

SI23 Introduction to Computer Graphics

Similar presentations


Presentation on theme: "SI23 Introduction to Computer Graphics"— Presentation transcript:

1 SI23 Introduction to Computer Graphics
Lecture 13 – Simple Reflection Model

2 What is a Reflection Model?
A reflection model (also called lighting or illumination model) describes the interaction between light and a surface, in terms of: surface properties nature of incident light Computer graphics uses a simplification of accurate physical models objective is to mimic reality to an acceptable degree 11 11

3 Phong Reflection Model
The most common reflection model in computer graphics is due to Phong Bui-tuong - in 1975 Has proved an acceptable compromise between simplicity and accuracy Largely empirical It is a local reflection model – does not handle global effects of light reflecting between surfaces Ray tracing and radiosity methods will handle this 12 12

4 Diffuse Reflection and Specular Reflection - Phong Approach
white light specular reflection (white) Some light reflected directly from surface. Other light passes into material. Particles of pigment absorb certain wavelengths from the incident light, but also scatter the light through multiple reflections - some light emerges back through surface as diffuse reflection. diffuse reflection (yellow) yellow pigment particles microscopic view 13 13

5 Ambient Reflection In addition to diffuse and specular reflection, a scene will also include ambient reflection This is caused by light falling on an object after reflection off other surfaces eg in a room with a light above a table, the floor below the table will not be totally black, despite having no direct illumination - this is reflection of ambient light 14 14

6 Reflection Model - Ambient Light
hemisphere of ambient light surface P Ia = Intensity of ambient light Ka = Ambient-reflection coefficient I = Reflected intensity = wavelength of light I ( )= Ka ( )Ia() 15 15

7 Ambient Lighting

8 Reflection Model - Diffuse Reflection
light source light source P P Light reflected equally in all directions - intensity dependent on angle  between light source and surface normal Lambert’s cosine law: I = I* cos  where I* is intensity of light source light source N L surface 16 16

9 Reflection Model - Diffuse Reflection
light source N L surface Light reflected equally in all directions, with intensity depending on angle  between light and surface normal: I* = Intensity of light source N = Surface normal L = Direction of light source Kd = Diffuse-reflection coefficient I = Reflected intensity I = Kd ( cos ) I* 17 17

10 Reflection Model - Diffuse Reflection
light source The angle between two vectors is given by their dot product: cos  = L . N (assume L, N are unit length) The coefficient Kd depends on the wavelength of the incoming light N L surface I (  ) = Kd() ( L . N ) I*() 18 18

11 Ambient and Diffuse

12 Reflection Model - Specular Reflection
light source R P In perfect specular reflection, light is only reflected along the unique direction symmetric to the incoming light 19 19

13 Reflection Model - Specular Reflection
light source R P In practice, light is reflected within a small angle of the perfect reflection direction - the intensity of the reflection tails off at the outside of the cone. This gives a narrow highlight for shiny surfaces, and a broad highlight for dull surfaces. 20 20

14 Reflection Model - Specular Reflection
Thus we want to model intensity, I, as a function of angle between viewer and R, say , like this: I with a sharper peak for shinier surfaces, and broader peak for dull surfaces.

15 Reflection Model - Specular Reflection
Phong realised this effect can be modelled by: (cos  )n with a sharper peak for larger n I n=1 n=10

16 Reflection Model - Specular Reflection
light source N R eye L V surface Intensity depends on angle between eye and reflected light ray: I* = Intensity of light source V = View direction R = Direction of perfect reflected light Ks = Specular-reflection coefficient I = Reflected intensity I = Ks( cos )n I* n varies with material large n : shiny small n : dull 21 23

17 Reflection Model - Specular Reflection
light source N R eye L Note: intensity forms ‘ellipse’ shape V surface Using cos = R . V (R, V unit vectors), we have: I () = Ks ( R . V )n I()* Note: Ks does not depend on the wavelength  - hence colour of highlight is same as source 22 24

18 Ambient, Diffuse and Specular

19 Ambient, Diffuse and Specular
Reflection Model - Ambient, Diffuse and Specular light source N R eye L V surface I() = Ka()Ia() + ( Kd()( L . N ) + Ks( R . V )n ) I*() 23 25

20 Example - Ambient Reflection

21 Example - Ambient and Diffuse

22 Ambient, Diffuse and Specular

23 Reflection Model - Effect of Distance
light source d surface The intensity of light reaching a surface decreases with distance - so we use typically: I* K1, K2, K3 constant - often K2=1, K3=0 K1 + K2*d + K3*d2 24 26

24 Final Reflection Model
light source N R eye L V d surface I() = Ka()Ia() + ( Kd()( L . N ) + Ks( R . V )n ) I*() K1 + K2*d + K3*d2 This needs to be applied for every light source in the scene 27

25 Phong illumination model: Ks 0.0 to 1.0, Kd 0.0 to 1.0
(Ka = 0.7, n = 10.0) Ks Kd

26 Phong Illumination Model: Ks 0.0 to 1.0; n = 10.0 to 810.0
(Ka = 0.7, Kd = 1.0) n Ks

27 Practicalities - Effect of Colour
The Phong reflection model gives reflection for each wavelength  in visible spectrum In practice, we assume light to be composed as a mixture of RGB (red, green, blue) components - and reflection model is applied for each component Coefficients of ambient-reflection (Ka) and diffuse-reflection (Kd) have separate components for RGB Coefficient of specular-reflection (Ks) is independent of colour in Phong model but …. 30 32

28 Specular Reflection in Reality
Really… specular reflection depends a little bit on: Angle of incidence of light Material proerties of surface Thus OpenGL for example will allow different specular reflection coefficients in R,G, B channels

29 Practicalities - Effect of Distance
There are advantages in assuming light source and viewer are at infinity L and V are then fixed for whole scene and calculations become simpler Lights at infinity are called directional lights Lights at a specified position are called positional, or point, lights 27 29

30 Programming Reflection in OpenGL
Light sources Read pp13-14 of guide To set position glLightfv(GL_LIGHT1, GL_POSITION, ptCoords) To set colour glLightfv(GL_LIGHT1, GL_DIFFUSE, rgba_colour) Remember to activate lights (glEnable) Surface Reflection Read p15 of guide To set material property – ie reflection coeffs (at each vertex of model) glMaterialfv (GL_FRONT, GL_DIFFUSE, myDiffuse) where Glfloat myDiffuse[] = {0.8, 0.3, 0.4, 1.0}

31 Coursework 3 London Eye

32 Acknowledgements Thanks to Alan Watt for the images


Download ppt "SI23 Introduction to Computer Graphics"

Similar presentations


Ads by Google