Presentation is loading. Please wait.

Presentation is loading. Please wait.

Lecture 10--- Cameras and lights 1Elias Holmlid.  First part  Cameras  Lights ▪ Light types ▪ Light models ▪ How light is computed  Second part 

Similar presentations


Presentation on theme: "Lecture 10--- Cameras and lights 1Elias Holmlid.  First part  Cameras  Lights ▪ Light types ▪ Light models ▪ How light is computed  Second part "— Presentation transcript:

1 Lecture 10--- Cameras and lights 1Elias Holmlid

2  First part  Cameras  Lights ▪ Light types ▪ Light models ▪ How light is computed  Second part  We’ll implement an effect for phong shading & cel shading Elias Holmlid2

3  Fixed perspective  First person  Third person Elias Holmlid3

4  Example: Alone in the Dark (1992) Elias Holmlid4

5  Example: Bioshock (2007) Elias Holmlid5

6  Example: Tomb Raider something Elias Holmlid6

7  Problems with geometry hiding the players  Might be solved with transparency Elias Holmlid7

8  Dizziness... Elias Holmlid8

9  Different follow behavior + giving the player some camera control Elias Holmlid9

10 10

11  A game might use several different cameras  Use a manager for handling all the cameras Elias Holmlid11

12  Directional  Sunlight (on Earth)  Spotlight  Point light (ominidirectional)  Emitting light from one point in all directions  Sunlight (on a deadly distance) Elias Holmlid12

13 Elias Holmlid13

14  Global illumination model Elias Holmlid14

15  Local illumination model Elias Holmlid15

16  Light may be precomputed and stored  Global illumination models might be used (!) Elias Holmlid16

17 Elias Holmlid17 Gouraud: Per vertex Phong: Per pixel Color interpolated during rasterization Normal interpolated during rasterization

18  Can be accomplished in different ways; one technique is called hard shading Elias Holmlid18

19 Elias Holmlid19 LightMaterial (object) (Ambient) Diffuse: i d Diffuse: m d Specular: i s Specular: m s SpecularPower: s (Emissive)

20  In the real world, light bounces around:  Therefore, all points are hit by light in some way  Ambient light makes up for our non-global illumination model  Ambient component might be just a global color (and not part of each light/object) Elias Holmlid20

21  Simulates how light bounces off a rough surface (it scatters in all directions) Elias Holmlid21

22 Elias Holmlid22  We want to find a scaling factor depending on how a point is hit by the light...

23 Elias Holmlid23 ...the dot product is ideal for this if clamped to the interval [0..1]. HLSL has a dot() function and [0..1] clamping can be done with s aturate()

24  Takes the viewpoint into consideration  Light bounces off in a specific direction and might hit the eye (camera) Elias Holmlid24

25  If objects are only rotated and translated, normals can be transformed with the same matix  If the above applies, but the object is also uniformely scaled, normals will have to be renormalized  However, if non-uniform scaling or shearing is applied, normals will no longer be normal to the surface  Then, the inverse-transpose of the transformation matrix does the job:  B = (A 1 ) t  In XNA: B = Matrix.Invert(A); B = Matrix.Transpose(B);  This is done automatically for you if you use BasicEffect! Elias Holmlid25

26  BasicEffect supports a maximum of three directional lights  If you want point/spot-lights, more lights, or do stuff like toon-shading you have to implement your own effects Elias Holmlid26

27  Stores all the lights  Might contain methods for finding the closest light to a point etc Elias Holmlid27


Download ppt "Lecture 10--- Cameras and lights 1Elias Holmlid.  First part  Cameras  Lights ▪ Light types ▪ Light models ▪ How light is computed  Second part "

Similar presentations


Ads by Google