Presentation is loading. Please wait.

Presentation is loading. Please wait.

© Machiraju/Möller Rendering Equation Various Solutions cis782 Advanced Computer Graphics Raghu Machiraju.

Similar presentations


Presentation on theme: "© Machiraju/Möller Rendering Equation Various Solutions cis782 Advanced Computer Graphics Raghu Machiraju."— Presentation transcript:

1 © Machiraju/Möller Rendering Equation Various Solutions cis782 Advanced Computer Graphics Raghu Machiraju

2 © Machiraju/Möller Reading Chapter 16.5 of “Physically Based Rendering” by Pharr&Humphreys Chapter 19, 20 in “Principles of Digital Image Synthesis,” by A. Glassner “Realistic Image Synthesis Using Photon Mapping,” by H. W. Jensen

3 © Machiraju/Möller Biased vs. Unbiased Algorithm unbiased algorithms: –Noise very apparent OR we need tons of rays –Variance (error) decreases in a predictable way Biased approaches –Irradiance caching + photon mapping –Smooth results –Cheap (only little more computing time than Whitted ray-tracing)

4 © Machiraju/Möller Biased vs. Unbiased Algorithm If we find little noise in the image: –For unbiased methods can be fairly sure that image is correct –For biased methods don’t have this assurance Increasing the sampling rate might not get rid of existing artifacts

5 © Machiraju/Möller Irradiance Caching Introduced by Greg Ward 1988 Implemented in RADIANCE –Public-domain software Exploits smoothness of irradiance –Cache and interpolate irradiance estimates

6 © Machiraju/Möller Irradiance Caching Indirect lighting changes rather slowly Compute indirect light at sparse set of samples Interpolate neighboring values from this set of samples

7 © Machiraju/Möller Irradiance Caching A.How to come up with such a (sparse) set of samples? B.How to store these samples? C.How to interpolate from neighbors?

8 © Machiraju/Möller A) Set of Samples Find them adaptively If there are no good nearby samples then compute a new irradiance sample Store irradiance (radiance is directionally dependent; i.e. expensive to store): we have: Assuming Lambertian-type surfaces (f=const.)

9 © Machiraju/Möller A) Set of Samples More glossy surfaces: hemispherical-directional reflectance

10 © Machiraju/Möller A) Set of Samples Irradiance chaching Path Tracing Same Computation Time

11 © Machiraju/Möller A) Set of Samples Irradiance caching Irradiance samples used

12 © Machiraju/Möller A) Set of Samples High error for specular surface Specular BSDF => Whitted integrator Diffuse BSDF => irradiance caching –Interpolation from known points –A path tracing step for new points –Use cos-weighted distribution:

13 © Machiraju/Möller B) Storing Samples Octree data structure –Each node stores samples that influence this node (each point has a radius of influence!) Radius of influence –determined by harmonic mean –d i is the distance that the i th ray traveled before intersecting an object –Computed during path tracing

14 © Machiraju/Möller C) Interpolation from neighbors Simply weighted sum: With weights: Skip samples –Normals too different –Too far away –If in front N N’ p p’

15 © Machiraju/Möller Images from “Radiance”

16 © Machiraju/Möller Images from “Radiance”

17 © Machiraju/Möller Caching Techniques Irradiance caching: –Compute irradiance at selected points and interpolate. Photon mapping: –Trace “photons” from the lights and store them in a photon map, that can be used during rendering.

18 © Machiraju/Möller Photon Mapping Basic idea : Density estimation with a discrete density of photons 2-step algorithm –Photon trace: Simulates the transport of individual photons Photons emitted from source Photons deposited on surfaces Photons reflected from surfaces to other surfaces –Rendering Photons collected by rendering

19 © Machiraju/Möller First Pass - Photon Trace For 100 photons emitted from 100W source, each photon initially carries 1W. Propagate this radiant flux through scene using MC methods.

20 © Machiraju/Möller Estimating incident flux At any patch of surface, we can estimate the incident flux: Just average the contributions of all the photons that hit the patch.

21 © Machiraju/Möller A Photon For each surface interaction, we store: struct photon { float x,y,z;// position char power[4];// power (RGBE) char phi, theta;// incident direction short flag; }

22 © Machiraju/Möller Photon Storage Store this information about surface interactions in photon map (kd-tree) Photon storage is decoupled from geometry

23 © Machiraju/Möller Second Pass - Rendering Estimate flux incident at a surface point based on nearby photons.

24 © Machiraju/Möller Radiance Estimate Expand ball until it contains some reasonable number of photons. Use intersection with plane to estimate area of surface patch.

25 © Machiraju/Möller Radiance Estimate Recall the reflected radiance equation Convert incident radiance into incident flux Reflected radiance in terms of incident flux Numerically  A =  r 2

26 © Machiraju/Möller Caustic from a Glass Sphere Photon Mapping: 10000 photons / 50 photons in radiance estimate

27 © Machiraju/Möller Caustic from a Glass Sphere Path Tracing: 1000 paths/pixel

28 © Machiraju/Möller Sphereflake Caustic

29 © Machiraju/Möller Reflection Inside A Metal Ring 50000 photons / 50 photons in radiance estimate

30 © Machiraju/Möller Caustics On Glossy Surfaces 340000 photons / 100 photons in radiance estimate

31 © Machiraju/Möller HDR environment illumination Using lightprobe from www.debevec.orgwww.debevec.org

32 © Machiraju/Möller Cognac Glass

33 © Machiraju/Möller Cube Caustic

34 © Machiraju/Möller Global Illumination 100000 photons / 50 photons in radiance estimate

35 © Machiraju/Möller Global Illumination 500000 photons / 500 photons in radiance estimate

36 © Machiraju/Möller Fast estimate 200 photons / 50 photons in radiance estimate

37 © Machiraju/Möller Indirect illumination 10000 photons / 500 photons in radiance estimate

38 © Machiraju/Möller Global Illumination global photon map vs. caustics photon map

39 © Machiraju/Möller Photon tracing Photon emission Photon scattering Photon storing

40 © Machiraju/Möller Photon emission Given  Watt lightbulb. Emit N photons. Each photon has the power  /N Watt Photon power depends on the number of emitted photons. Not on the number of photons in the photon map.

41 © Machiraju/Möller What is a photon? Flux (power) - not radiance! Collection of physical photons – A fraction of the light source power – Several wavelengths combined into one entity

42 © Machiraju/Möller Diffuse point light Generate random direction Emit photon in that direction // Find random direction do { x = 2.0*random()-1.0; y = 2.0*random()-1.0; z = 2.0*random()-1.0; } while ( (x*x + y*y + z*z) > 1.0 );

43 © Machiraju/Möller Example: Diffuse square light Generate random position p on square Generate diffuse direction d Emit photon from p in direction d // Generate diffuse direction u = random(); v = 2*  *random(); d = vector(cos(v),sin(v), );

44 © Machiraju/Möller Other Sources Random directions and importance sampling (e.g., diffuse) within volumes of emission (bounding volumes) Projection Maps – Cells in scene which indicate if photons map or not

45 © Machiraju/Möller Surface interactions The photon is –Stored (at diffuse surfaces) and –Absorbed (A) or –Reflected (R) or –Transmitted (T) A + R + T = 1.0

46 © Machiraju/Möller Photon scattering The simple way: –Given incoming photon with power  p –Reflect photon with the power R*  p –Transmit photon with the power T*  p

47 © Machiraju/Möller Photon scattering The simple way: –Given incoming photon with power  p –Reflect photon with the power R*  p –Transmit photon with the power T*  p Risk: Too many low-powered photons - wasteful! When do we stop (systematic bias)? Photons with similar power is a good thing.

48 © Machiraju/Möller Russian Roulette Probability of termination: q Terminate un-important photons and still get the correct result

49 © Machiraju/Möller Russian Roulette Example Surface reflectance: R = 0.5 Incoming photon:  p = 2W r = random(); if ( r < 0.5 ) reflect photon with power 2 W else photon is absorbed

50 © Machiraju/Möller Russian Roulette Intuition Surface reflectance: R = 0.5 200 incoming photons with power:  p = 2W Reflect 100 photons with power 2W instead of 200 photons with power 1W

51 © Machiraju/Möller Russian Roulette Very important! Use to eliminate un-important photons Gives photons with similar power

52 © Machiraju/Möller Storing Photons data structure for storing and searching For uniform distribution – cubes are best For non-uniform – kd-trees, Voronoi etc. k-d-trees, perhaps best

53 © Machiraju/Möller Storing Photons Use kd-tree – a sequence of axis-aligned partitions –2-D partitions are lines –3-D partitions are planes Axis of partitions alternates with depth of the tree Average access time - O(log n) Worst case O(n) when tree is skewed Need to maintain a balanced tree Balancing O(n log n) k nearest neighbors in O(k + log n)

54 © Machiraju/Möller Balancing kd-tree

55 © Machiraju/Möller Multiple Photon Maps Interpolation from the map causes blurriness For specular interactions Whitted Ray-Tracing Otherwise divide photon map into –direct light map L i,d –Indirect light map L i,i –Caustic map L i,c

56 © Machiraju/Möller Photon Mapping: Rendering Classification of photons in Photon Map

57 © Machiraju/Möller Multiple Photon Maps Direct light map L i,d Indirect light map L i,i Caustic map L i,c

58 © Machiraju/Möller + = Direct Illumination Indirect Illumination + Specular Part = Another example

59 © Machiraju/Möller + = Caustics Another example (cont’d)

60 © Machiraju/Möller Features Photon tracing is unbiased –Radiance estimate is biased but consistent –The reconstruction error is local Illumination representation is decoupled from the geometry

61 © Machiraju/Möller Box 200000 global photons, 50000 caustic photons

62 © Machiraju/Möller Box: Global Photons 200000 global photons

63 © Machiraju/Möller Fractal Box 200000 global photons, 50000 caustic photons

64 © Machiraju/Möller Cornell Box

65 © Machiraju/Möller Indirect Illumination

66 © Machiraju/Möller Little Matterhorn

67 © Machiraju/Möller Mies house (swimmingpool)

68 © Machiraju/Möller Mies house (3pm)

69 © Machiraju/Möller Mies house (6pm)

70 © Machiraju/Möller Final Gathering

71 © Machiraju/Möller Recap Decouple representation of illumination from geometry Photon Map – – Illumination as points in a global data structure –Cache of light paths. Estimate illumination based on density – Error is of low frequency – Not high frequency noise Unbiased method! Average expected value is not correct ! Consistent – technique will converge as more points/photons are added Photon Mapping, Photon Tracing, Photon Map

72 © Machiraju/Möller Monte-Carlo Ray Tracing Advantages –L(D|S)*E – All paths of light –Arbitrary geometry Parametric, subdivisions, implicit Procedural models –Low Memory Find intersections on demand –Arbitrary BRDFs Disadvantages –Noise –Complexity Jensen

73 © Machiraju/Möller L lightsource Pixel contribution rays reflected ray refracted ray LS*[D]E paths Photon Tracing

74 © Machiraju/Möller Photon Tracing –Photon generation stage Emit photons on light sources Random walk (trace photons through scene) Store interactions (position x, power phi, …) Photon Map Data Structure (e.g. kd-tree.)

75 © Machiraju/Möller pp  p xpxp Photon? A photon p is a particle of light that carries flux  p (x p,  p ) –Power:  p – magnitude (in Watts) and color of flux it carries, stored as an RGB triple –Position: x p – location of the photon –Direction:  p – the incident direction  i used to compute irradiance Photons vs. Rays –Photons propagate flux –Rays gather radiance

76 © Machiraju/Möller Scatter use light path tracing packets of flux (photons) distributed photons stored in a spatial data structure (e.g. kd-tree.)

77 © Machiraju/Möller Sources Point source –Photons emitted uniformly in all directions –Or emission is controlled by geometry Power of source (W) distributed evenly among photons Flux of each photon equal to source power divided by total # of photons For example, a 60W light bulb would send out a total of 100K photons, each carrying a flux  of 0.6 mW Photons sent out once per simulation, not continuously as in radiosity

78 © Machiraju/Möller Point Diffuse Sources emit_photons_from_diffuse_point_light() { n e =0 While (not enough photons){ do {// rejection sampling x = 2  1 -1; y =2  2 – 1; z = 2  3 – 1; } while (x^2+Y^2+z2 > 1) d= [x, y, z] T p= light_source_position trace photon from p in direction d n e = n e + 1 } scale power of stored photons with 1/n e }

79 © Machiraju/Möller Photon Scatter – Ray Tracing Redux Shoot(ray, pow, d) IF d > dmax THEN RETURN (object, x) = FirstIntersect(ray) IF no intersection THEN RETURN IF k r > 0 THEN Shoot(k r * pow, reflected ray, d+1) IF k t > 0 THEN Shoot(k t * pow, refracted ray, d+1) IF kd > 0 THEN Shoot(kd* pow, random-direction, d+1) END

80 © Machiraju/Möller ? Russian Roulette Reflected flux only a fraction of incident flux After several reflections, can spend lot of time tracking very little flux Also ensure that photons have approximately same power Absorb some photons and reflect the rest at full power Spend time tracing fewer full power photons Probability of reflectance is the reflectance  Probability of absorption is 1 –  Variance --- It does increase it

81 © Machiraju/Möller Mixed Surfaces Surfaces have specular and diffuse components –  d – diffuse reflectance –  s – specular reflectance –  d +  s < 1 (conservation of energy) Let  be a uniform random value from 0 to 1 If  <  d then reflect diffuse Else if  <  d +  s then reflect specular Otherwise absorb How about RGB ? Use averages across channels

82 © Machiraju/Möller Photon Map Catch the bug in the photon Map

83 © Machiraju/Möller Photon Struct photon{ float x, y, z; char power[4];//four bytes or 3 floats char ,  ;//incident direction short flag;// splitting plane axis } Theta = 256 * atan(dx,dy)/(2*pi) Phi = 256 * acos(dx)/pi

84 © Machiraju/Möller Nearest Neighbor Seacrh

85 © Machiraju/Möller Photon Mapping – Stage 2 Gathering walk to the end of “all” photon traces Le1Le1 Le2Le2 Le3Le3

86 © Machiraju/Möller Rendering Modified distribution ray tracing Gather: for each point to be shaded find k-nearest photons in the hood using K-d tree Query these k nearest photons for energies estimate local radiance using light flux of photons Approximate radiance by density estimation Density estimation: radiance = sumOfEnergies/coveredArea

87 © Machiraju/Möller Rendering

88 © Machiraju/Möller Anomalies Use Convex hull of photons Flatten disk

89 © Machiraju/Möller Need for Filtering

90 © Machiraju/Möller Filtering Too few photons cause blurry results Simple averaging produces a box filtering of photons Photons nearer to the sample should be weighted more heavily Results in a cone filtering of photons

91 © Machiraju/Möller Gaussian Filtering  = 0.918,  =1.953

92 © Machiraju/Möller Photon Numbers 10,000 P 100 Radiance 500,000 P 500 Radiance Compromise: Direct lighting with feelers 10,000 P, 100 Radiance

93 © Machiraju/Möller Photon Numbers 200 P 50 Radiance Really fast

94 © Machiraju/Möller Images caustics dispersion

95 © Machiraju/Möller Images

96 © Machiraju/Möller 4 Components

97 © Machiraju/Möller Components (1) Radiance thro a pixel Direct Lighting Shadow Photons

98 © Machiraju/Möller Caustics & Indirect Diffuse Components (2)

99 © Machiraju/Möller Schlick Caustic  =1.0  =0.1  =0.5  =0.01

100 © Machiraju/Möller Combine All Maps Outgoing radiance at x Reflected light at x BRDF at x Incoming radiance at x Direct illlumIndirect- Caustics Indirect- Diffuse

101 © Machiraju/Möller Combine All Maps Direct illlum No photon Map Caustics MC ray tracing

102 © Machiraju/Möller Issues (1) Memory/Time Costs –The number of photons and the size of spatial data structure, (and hence memory footprint) increase proportionally with quality requirements of image. –K-nearest neighbour search is non-trivial: time- complexity is highly data-structure dependent.

103 © Machiraju/Möller Issues – Generation (2) Poor spectral-space sampling –Restricted to RGB. Original algorithm: Pure forward simulation  Visual importance not taken into account  Photon density is high (only) where illumination is high  Problematic whenever photon density doesn’t match importance distribution –High density (high cost) in unimportant regions –Low density (low quality) in important region

104 © Machiraju/Möller Bad Importance Distribution importance distribution photon distribution


Download ppt "© Machiraju/Möller Rendering Equation Various Solutions cis782 Advanced Computer Graphics Raghu Machiraju."

Similar presentations


Ads by Google