1 / 29

Lighting

Lighting. Z-Buffering. Or depth-buffering Store depth of each pixel Start with all pixels = inf. Only overwrite if depth is less than current. Z-Buffering. Lights. BasicEffect in XNA. BasicEffect is the only “out of the box” effect in XNA. You’ll likely never use it in a real game!

Download Presentation

Lighting

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Lighting

  2. Z-Buffering • Or depth-buffering • Store depth of each pixel • Start with all pixels = inf. • Only overwrite if depth is less than current

  3. Z-Buffering

  4. Lights

  5. BasicEffect in XNA BasicEffect is the only “out of the box” effect in XNA You’ll likely never use it in a real game! We nearly always need more functionality than BasicEffect provides However, BasicEffect is a common starting point!

  6. BasicEffect supports Material properties Diffuse and Specular colors Emissive color Texture Three directional lights Diffuse Color Specular Color Direction (vector) Plus some misc stuff like fog and vertex lighting

  7. Elements of Illumination at a point N – The surface normal L – Vector to the light V – Vector to the eye R – Reflection direction We’ll be working in “view space” in XNA, so V is always (0, 0, 1)

  8. Reflection What we need is the amount of light reflected to the eye Objects the same “color” may reflect light very differently This consists of several components…

  9. Types of Light • Ambient • Diffuse • Specular • Emissive

  10. Ambient Illumination Small amount of light that is assumed to hit all surfaces. Simulates the idea of light bouncing around the room. Used as sunlight, or “general light”

  11. Diffuse Reflection • Light diffuses over space • Lambert’s law: The smaller the angle of reflection, the more intense the reflected light is. • i = N·L Ө N L

  12. Diffuse Reflection • Diffuse reflection - light reflected in all directions equally (or close to equally) • Most objects have a component of diffuse reflection (other than pure specular reflection objects like mirrors) Diffuse reflection is what makes the blue ball blue!

  13. Specular Reflection • Specular reflection - If the light hits the surface and is reflected off mostly in a reflection direction, we have specular reflection. • A perfect specular object (no diffusion at all) is a mirror. • Most objects have some specular characteristics Specular reflection makes bright highlights on objects.

  14. Specular Illumination Diffuse Only Materials are assumed to have two colors: a diffuse color and a specular color. Specular Contribution

  15. Diffuse and Specular colors • Typically the colors reflected for diffuse and specular reflection are different • Diffuse – Generally the surface appearance • Specular – The color of bright highlights, often more white then the surface color Diffuse illumination is view independent. Specular illumination is view dependent.

  16. Light Source Intensity • Intensity of light source (60W bulb vs 100W bulb) • This is a multiplicative factor for the diffused light. • i = a + l(N·L)

  17. Distance Falloff • Light gets less intense with distance • Falloff distance: distance at which light is no longer visible (f) • Changes the light intensity factor (l) • l’ = l(f-d)/(f+d) • i = a+l’(N·L) d f

  18. Shade Maps • Way to shade textures or polygons non-uniformly • Calculate a shade map: Rectangle that covers the polygon. • Calculate blocks of shading • Draw shade on top of texture

  19. Tricks • Depth cueing: Further surfaces = fog or some other effect besides just getting dark • Fake shadows: Draw a dark circle under an object so it doesn’t look like it’s floating • MIP Mapping: Keep small versions of polygons for far-away objects

  20. Forward Mapping • Forward mapping is what we are used to.

  21. Forward Mapping • Take each primitive • Figure out where on the screen it should appear • Also known is feed-forward

  22. Ray Tracing • Ray tracing is the “inverse” of the “forward” mapping we are used to.

  23. Ray Tracing • Also known as inverse mapping or feed-backward

  24. Feed-Forward vs. Feed-Backward • Pros and Cons of each

  25. Ray-Tracing • Attempts to trace the paths of light that contribute to each pixel that make up a scene • Instead of computing visible surfaces, determine intensity contributions • Compute global illumination • Allows for: • Reflection • Refraction • Atmospheric effects • Shadows • Results in very realistic scenes • Used in movies, animations, cut-scenes

More Related