Download presentation
Presentation is loading. Please wait.
1
Frame Buffer Applications
Fall 2018 CS480/680
2
Previously, What are frame buffers?
Different types of buffers stored in frame buffer Color buffer Depth buffer Stencil buffer How to create and use multiple frame buffers Use of color buffer to develop post processing shaders
3
Other Buffers in Frame Buffers
Currently, we’ve used color buffers to create post-processing shaders Frame buffers can be used for a lot more than just modifying the screen pixels There are still two other buffers that we can use Depth buffer for storing position Stencil buffer for masking What can we do by using the depth buffer?
4
Shadow Mapping
5
The global lighting problem
Our current lighting algorithm only works with lighting individual objects (even then, it doesn’t do a good job) Other object’s don’t know if they are being occluded or not
6
Solution: shadow mapping
We can tell if a pixel is occluded or not by drawing an imaginary line from the light source to the fragment, and see which surface it hits first We can use a depth map from the light source to the object to get that imaginary line AND the surface that it hits first Only problem is, is that the line is in light space; how do we compare a world space coordinate to a light space coordinate?
7
Solution: shadow mapping
Matrix Transformations! Transform the fragment position into light position, and compare the first hit object to the current fragment If the first hit object is closer than the current fragment, it's in shadow
8
Learning By Example
9
A still imperfect method
While shadow mapping is good, we still make the assumption that the light is an infinitely small point Real lights have a size to them, which causes the soft shadows we see cast by lamps and computer monitors
10
Deferred Rendering
11
Optimizing the Rendering Lights
On the topic of light rendering, you might notice rendering a lot of lights gets slow very fast What we are currently using a technique called Forward Rendering We waste a lot of time calculating lights that are too far to be lit by some lights, or are out of the area of influence (i.e. spotlights) We also do light calculations for pixels that won’t even be seen (overdraw) When doing fragment lighting, we calculate the specular and diffuse products of all objects for all lights in all pixels, even if they are not seen
12
Deferred Rendering Solution: don’t do any lighting calculations until after the whole scene is rendered Wait what We know all the lighting information we need: Texture Normals Fragment Position (for calculating L and V) Material info (specular power, diffuse power, etc.) We pack them into frame buffers, and do the calculation afterwards
13
Optimization 2: light volumes
We solved the issue of overdraw, but we are still calculating all the lighting for all pixels for each scene Solution: we mask out areas we know the light will affect using a model We can exploit the efficiency of the rasterizer to only calculate lighting on the pixels that will be affected by the light We use primitive shapes to mask out these areas: Spheres for point lights Cones for spot lights A fullscreen quad for directional lights (they have no attenuation or area of influence)
14
Learning By Example
15
Example in Industry: Grand Theft Auto V
16
Questions?
17
Additional Resources
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.