140 likes | 276 Views
Real Time Shaders. CS 319 Advanced Topics in Computer Graphics John C. Hart. Real Time Shaders. Moore’s law: CPU power doubles every 18 months Advances in materials Advances in methods Advances in marketing Graphics version: GPU power doubles every 6 months
E N D
Real Time Shaders CS 319 Advanced Topics in Computer Graphics John C. Hart
Real Time Shaders • Moore’s law: CPU power doubles every 18 months • Advances in materials • Advances in methods • Advances in marketing • Graphics version: GPU power doubles every 6 months • Supports more sophisticated shading, though in unexpected ways (e.g. strange uses of the texture maps)
AvailableTechnology • Texture Shading • Render shading expressionsusing texture mapping • Multipass • Combine shading components using image processing combinations • E.g. Render texture diffuse then render highlight • Multitexturing • Store multiple texture coordinates at each vertex • Textures are combined on the fly • Fragment lighting • Compute complex shading per pixel Slide #22 from Hanrahan’s “Real-Time Shading Languages”
Texture Shading • Heidrich & Seidel, SIGGRAPH 99 • Implements shading models using texture maps • Disables hardware lighting • Evaluate shading expressions, store in texture coordinates • Precompute remaining expression in texture map
Example: PhongTexture Shader • Express model as combination of colors C = kaCa + kd (NL) Cd + ks (VR)nCs • Plot vertices using texture coordinates • s = NL • t = VR • Precompute texture by evaluating • C(s,t) = kaCa + kdsCd + kstnCs • for 0 s,t 1 t = VR s = NL
Example: Cook-Torrance c = VH and g2=h2+c2-1
Sampling • Problem • “Gouraud” interpolation of highlights • Interpolation of NL and VR which are proportional or power-proportional to intensity • Solution • Interpolate vectors instead • How?
EnvironmentMaps • Spheremap • reflection into hemisphere • Singular at silhouette • Biased samples • Cubemap • projection onto cube faces • Awkward to store
Radiance v. Irradiance Maps • Environment map • Panoramic picture of surroundings • Radiance map • Reflectance equation • Environment map is an irradiance map Li(wi) • Radiance map Lr(wr) computed by integrating BRDF with irradiance
PhongRadiance Map • Spheremap is reflection of scene on sphere • Render phong highlight on sphere • Use rendered sphere as an environment map • Texture coordinate interpolation interpolates wr
MeasuredRadiance Maps • Peercy, Olano, Airey , Ungar, "Interactive Multi-Pass Programmable Shading", SIGGRAPH 2000
Real-Time Bump Mapping • Embossing • Multipass difference betweentexture and shifted copy • Environment-mapped bump mapping • Perturb environment map index with bump map (map of height field differentials) • Register combiners • Store vectors in texture map • Compute per-pixel dot product B B B