practical 3 introduction
play

Practical 3 Introduction Paul Scharf Tom Rijnbeek Practical 3 - PowerPoint PPT Presentation

Practical 3 Introduction Paul Scharf Tom Rijnbeek Practical 3 Advanced Shader Programming 18 tasks: 6 easy; 7 medium; 5 hard Easy exercises: choose 4 out of 6 Maximum grade: 8 Two more points by doing either: Two medium tasks


  1. Practical 3 Introduction Paul Scharf Tom Rijnbeek

  2. Practical 3 Advanced Shader Programming • 18 tasks: 6 easy; 7 medium; 5 hard • Easy exercises: choose 4 out of 6 – Maximum grade: 8 • Two more points by doing either: – Two medium tasks – One hard task • Deadline: Thursday June 26, 23:59

  3. EASY TASKS

  4. [E1] Multiple light sources • Repeat light calculations for every source

  5. [E2] Spotlight

  6. [E3] Cel shading • Discretised shading smooth

  7. [E3] Cel shading • Easy solution: use texture for spectrum • More complicated: – Discretise mathematically – Use gradients for smoothing

  8. [E4] Frustrum culling • Only draw visible models • Calculated on the CPU

  9. [E4] Frustrum culling • Frustrum bounded by six planes • Don’t draw models on the wrong side of planes • Or use XNA’s BoundingFrustrum class...

  10. Post-processing basics 1. Render scene to texture (rendertarget) 2. Render screen-filling quad sampling from texture in pixel shader • XNA: draw texture with Spritebatch using pixel shader

  11. [E5] Simple colour filter • Apply grey-scale filter to every pixel • Use weighted sum: 𝑍 = 0.3𝑆 + 0.59𝐻 + 0.11𝐶

  12. [E6] Gaussian blur • Box blur : average pixels in a square area around target pixel • Calculate by applying a convolution kernel on the image 1/9 1/9 1/9 1/9 1/9 1/9 1/9 1/9 1/9

  13. [E6] Gaussian blur • Gaussian blur: average pixels in a (roughly) circular area around target pixel • Use normal distribution to build kernel

  14. [E6] Gaussian blur 0.00000067 0.00002292 0.00019117 0.00038771 0.00019117 0.00002292 0.00000067 0.00002292 0.00078633 0.00655965 0.01330373 0.00655965 0.00078633 0.00002292 0.00019117 0.00655965 0.05472157 0.11098164 0.05472157 0.00655965 0.00019117 0.00038771 0.01330373 0.11098164 0.22508352 0.11098164 0.01330373 0.00038771 0.00019117 0.00655965 0.05472157 0.11098164 0.05472157 0.00655965 0.00019117 0.00002292 0.00078633 0.00655965 0.01330373 0.00655965 0.00078633 0.00002292 0.00000067 0.00002292 0.00019117 0.00038771 0.00019117 0.00002292 0.00000067

  15. [E6] Gaussian blur • Convolution can be heavily optimised • Split in vertical and horizontal pass 1 3 1 9 1 9 1 9 1 3 ∗ 1 3 1 3 1 3 1 9 1 9 1 9 = 1 3 1 9 1 9 1 9

  16. MEDIUM TASKS

  17. [M1] Textured light • Create view & projection matrix for light • Transform vertex position twice

  18. [M2] Shadow mapping • Render depth texture from light • Render scene normally – Compare pixel’s distance to light with value from depth texture

  19. [M2] Shadow mapping depth from light from camera distance compare to light pictures from: http://en.wikipedia.org/wiki/Shadow_mapping

  20. [M3] Reflection • Render scene from reflected camera • Render to texture – Render mirror with texture • Or: use stencil buffer – Mask mirror pixels, to only render reflection there

  21. [M4] Cube mapping • Cube map: texture represting lighting from all directions

  22. [M4] Cube mapping • Calculate reflection vector • Use cube texture lookup to find reflected colour

  23. [H5] Advanced cube mapping • Precomputed diffuse light map • Stronger reflections at shallow reflection angles

  24. [M5] Transparency • Render transparent objects after opaque ones • Sort transparent objects back-to-front

  25. [M6] Post-processing: Bloom • Render scene • Threshold bright pixels • Downscale and blur repeatedly • Add up all scales

  26. [M6] Post-processing: Bloom threshold all added up scale down and blur

  27. [M7] Post-processing: God rays • Volumetric light scattering through dust/mist • Approximate in screen-space

  28. HARD TASKS

  29. [H1] HDR Lighting & Tone Mapping • Simulate adaption of human eye to changing brightness • LDR vs. HDR – LDR [0, 1] – HDR [0, ∞) • Tone Mapping: HDR  LDR

  30. [H2] Deferred Shading • Earlier lighting methods inefficient with many lights • Render geometry information to multiple rendertargets (G-buffers) • Calculate lighting per light for affected pixels

  31. [H2] Deferred Shading Diffuse Colour Depth/Position Normal Tons of lights

  32. [H3] Parallax Mapping • Use height map to displace diffuse texture

  33. [H4] Post-processing: SSAO

  34. [H4] Post-processing: SSAO • Crude approximation of full global illumination • Calculate in screen- space • First real-time implementation: Crysis

  35. Final words • Try focusing on doing few tasks well rather than lots of exercises poorly • Finish the easy tasks first • Start in time!

  36. Recap • Finish 4 easy tasks for an 8 • Finish 2 medium tasks or 1 hard task for 2 points • Additional tasks don’t improve grade • Start in time!

  37. Questions?

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend