html5-img
1 / 24

CS361

Week 6 - Friday. CS361. Last time. What did we talk about last time? Light Material Sensors Lambertian shading. Questions?. Project 2. Shading. Shading equations. We need a mathematical equation to say what the color (radiance) at a particular pixel is

jirair
Download Presentation

CS361

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. Week 6 - Friday CS361

  2. Last time • What did we talk about last time? • Light • Material • Sensors • Lambertian shading

  3. Questions?

  4. Project 2

  5. Shading

  6. Shading equations • We need a mathematical equation to say what the color (radiance) at a particular pixel is • There are many equations to use and people still do research on how to make them better • Remember, these are all rule of thumb approximations and are only distantly related to physical law

  7. Lambertian shading • Diffuse exitanceMdiff = cdiff ELcosθ • Lambertian (diffuse) shading assumes that outgoing radiance is (linearly) proportional to irradiance • Because diffuse radiance is assumed to be the same in all directions, we divide by π (explained later) • Final Lambertian radiance Ldiff =

  8. Specular shading • Specular shading is dependent on the angles between the surface normal to the light vector and to the view vector • For the calculation, we compute h, the half vector half between v and l

  9. Specular shading equation • The total specularexitance is almost exactly the same as the total diffuse exitance: • Mspec = cspec ELcosθ • What is seen by the viewer is a fraction of Mspec dependent on the half vector h • Final specular radiance • Lspec = • Where does m come from? • It's the smoothness parameter

  10. Implementing the shading equation • Final lighting is: • We want to implement this in shaders • The book goes into detail about how often it is computed • Note that many terms can be precomputed, only the ones with angles in them change

  11. When should it be computed? • Computing the shading equation more often gives better visual results but takes more time • Flat shading • Computes shading equation once per primitive • Gouraud shading • Computes shading equation once per vertex, linearly interpolates color for pixel values • Phong shading • Computes color per pixel

  12. Aliasing

  13. Aliasing • When sampling any continuous thing (image, sound, wave) into a discrete environment (like the computer), multiple samples can end up being indistinguishable from each other • This is called aliasing • We can reduce aliasing by carefully considering how sampling and reconstruction of the signal is done

  14. Aliasing example • Ever seen wheels of a car spinning the wrong way? • Without enough samples, it may be impossible to tell which way it's spinning • You need a sampling frequency twice as high as the maximum frequency of the events to reconstruct the original signal • Called the Nyquist limit

  15. Screen based antialiasing • Jaggies are caused by insufficient sampling • A simple method to increase sampling is full-scene antialiasing, which essentially renders to a higher resolution and then averages neighboring pixels together • The accumulation buffer method is similar, except that the rendering is done with tiny offsets and the pixel values summed together

  16. FSAA schemes A variety of FSAA schemes exist with different tradeoffs between quality and computational cost

  17. A-buffer • For non-interactive render speeds, the A-buffer can be used • The A-buffer generates a coverage mask for each fragment for each pixel • Fragments are thrown away if they have z-buffer values that are higher than fragments with full coverage • Final pixel color is based on fragment merging

  18. Multisampleantialiasing • Supersampling techniques (like FSAA) are very expensive because the full shader has to run multiple times • Multisampleantialiasing (MSAA) attempts to sample the same pixel multiple times but only run the shader once • Expensive angle calculations can be done once while different texture colors can be averaged • Color samples are not averaged if they are off the edge of a pixel

  19. Performance, speed, the future • Active research is still trying to find techniques with good visual output and good computational performance • Stochastic (random) sampling reduces the visual repetition of some artifacts • Sharing samples between pixels can reduce overall cost

  20. XNA Examples

  21. Quiz

  22. Upcoming

  23. Next time… • Alpha effects • Gamma effects

  24. Reminders • Keep working on Project 2, due Friday, March 1 • Keep reading Chapter 5 • Start reading Chapter 6

More Related