Advanced Graphics Path Tracing and Photon Mapping Part 2 Path Tracing and Photon Mapping
Importance Sampling Combine importance sampling techniques Reflectance function (diffuse + specular) Light source What if a path for diffuse reflectance (unimportant) accidentally hits a light source? Unimportant path turns out to be important Variance! Path Tracing and Photon Mapping 2
Multiple Importance Sampling Look at all importance sampling techniques when determining the weight Not only at the technique used to select the sample Requires the weights of all used importance sampling techniques p ω = w 1 p 1 ω + w 2 p 2 (ω ) L o x, ω = L e x, ω + f r x, ω, ω L i x, ω p ω Path Tracing and Photon Mapping 3
Bidirectional Path Tracing Can be very unlikely to find a path to a light source Also construct the path from the light source Try to connect all path vertices Path Tracing and Photon Mapping 4
Bidirectional Path Tracing Can find multiple functional paths at once Create path weight similar to multiple importance sampling Still unbiased Path is still fully random Weights correct for bias Path Tracing and Photon Mapping 5
Stratified Sampling Randomize samples within intervals Normal sampling Stratified sampling Path Tracing and Photon Mapping 6
Stratified Sampling Can vary region size Add weight to correct bias Discretized importance sampling Path Tracing and Photon Mapping 7
Ray tracing Path tracing Variance reduction Photon mapping Subsurface scattering PHOTON MAPPING Path Tracing and Photon Mapping 8
Photon Mapping Different acceleration approach Caching Overview First phase: shoot photons from light source and store their intersections Second phase: ray trace and collect photons Path Tracing and Photon Mapping
Photon Mapping For indirect lighting and caustics Distributed ray tracing for direct lighting and perfect specular reflections Very high quality caustics can be obtained Strong point of photon mapping Path Tracing and Photon Mapping 10
First Phase Shoot photons from light sources Similar to path tracing Store photon at each intersection Photon contains Position Intensity (red, green and blue) Incident angle Path Tracing and Photon Mapping 11
First Phase Shoot more photons towards refracting objects Creates more detailed caustics Number of photons commonly in the order of ~300.000 Path Tracing and Photon Mapping 12
Photon Storage Store in a texture? Hard to determine resolution Incident angle information lost Correct texture mapping can be difficult Store in a spatial (3D) structure, the photon map Kd-tree Additional kd-tree for caustics Path Tracing and Photon Mapping 13
Second Phase Based on distributed ray tracing Calculate direct lighting Gather indirect lighting from the photon map Caustics Retrieve all refracted direct light from the caustics photon map Path Tracing and Photon Mapping 14
Second Phase Retrieve light from the photon map Nearest neighbor search in the kd-tree Find nearest N photons Normalize for photon density Divide intensity by the disk surrounding the photons Apply reflectance function Photon map part of the lighting: L o x, ω = 1 πr 2 N p=1 f r(x, ω p, ω)l p (Original rendering equation: L o x, ω = L e x, ω + f r x, ω, ω L i x, ω dω ) Ω Path Tracing and Photon Mapping 15
Final Gather Too few photons results in artifacts Can add a final gather step Do one non-recursive integration for indirect light Very expensive Path Tracing and Photon Mapping 16
Unbiased Is photon mapping unbiased? No But it is consistent Converges to the correct result when increasing the number of photons Depends on the implementation Is this a disadvantage? Less elegant from mathematical point of view No noise! Better from a practical perspective Path Tracing and Photon Mapping 17
Optimization Common optimization are shadow photons Stored at non-first intersections (for direct light) Photon Shadow photon Optimizes distributed ray tracing phase Can estimate if the point is (partially) shadowed Faster direct lighting computation Path Tracing and Photon Mapping 18
Recap First phase Shoot rays from the light source which bounce around in the scene Store a photon for each intersection in the photon map (kd-tree) Second phase Render an image from the camera using distributed ray tracing Gather the indirect light from nearby photons in the photon map Path Tracing and Photon Mapping 19
Comparison Difference with path tracing No high-frequency noise Photon map can be re-used when changing the view But not when objects move Requires storage between phases (photon map) Construct and query the kd-tree Path tracer requires no intermediate storage Path Tracing and Photon Mapping 20
Ray tracing Path tracing Variance reduction Photon mapping Subsurface scattering SUBSURFACE SCATTERING Path Tracing and Photon Mapping 21
Again? Previously discussed Partial translucency and texture-space diffusion Simulation on a macro scale Real-time performance Ray based simulation Simulation on a micro scale Physically correct, but slow Path Tracing and Photon Mapping
Monte Carlo Scattering Simulate a photon through a scattering medium Repeatedly, after a distance interval: The photon is scattered A part of the energy of the photon is absorbed Can be used with path tracing and photon mapping Path Tracing and Photon Mapping 23
Monte Carlo Scattering Vary scattering and absorption parameters Path Tracing and Photon Mapping 24
Overview Topics (Distributed) ray tracing Path tracing Variance reduction techniques Photon mapping Monte Carlo subsurface scattering Path Tracing and Photon Mapping 25
Next time Radiosity Different solution to the same problem Path Tracing and Photon Mapping 26