Day 12 - Shaders 2

Demo GPU Programs

World Space Lighting - https://shaderfrog.com/app/view/3154

Dynamic Shaders - https://shaderfrog.com/app/view/3155

UVs in shaders - https://shaderfrog.com/app/view/3156

Checkerboard UVs - https://shaderfrog.com/app/view/3158

Moving vertices - https://shaderfrog.com/app/view/3157

Distorted Vertices - http://shaderfrog.com/view/3159

Spiked Vertices - http://shaderfrog.com/view/3219

Christmas Ornament - http://shaderfrog.com/view/3219

Baking textures

  • Ambient Occlusion
  • Global illumination
  • Normal maps (bump Maps)
  • Displacement maps

Shadows on the GPU

  • "N64" style shadows - a circle below each object on perfectly flat ground.

  • Shadow maps

    • Place a camera at the position of each point light
    • Save the depth map and pass it as a parameter to each fragment shader
    • Compare each fragment's distance to the light with the store distance to the light
    • If the distance matches the stored distance, the point is illuminated, otherwise it is in shadow
  • Shadow maps pros/cons

    • Can run very quickly
    • Can produced "jagged" shadows
    • Simple smoothing can remove "jaggies"
    • Pixelated nature will produce some artifacts