INFOMAGR – Advanced Graphics Jacco Bikker - November 2016 - February 2017 Lecture 13 - “BRDFs” Welcome! 𝑱 𝒚, 𝒚 ′ = 𝒉(𝒚, 𝒚 ′ ) 𝝑 𝒚, 𝒚 ′ + 𝝇 𝒚, 𝒚 ′ , 𝒚 ′′ 𝑱 𝒚 ′ , 𝒚 ′′ 𝒆𝒚′′ 𝑻
Today’s Agenda: Phong BRDF Microfacets The Lobe
Advanced Graphics – BRDFs 3 Phong BRDFs, Recap Recall that a BRDF defines the relation between incoming and outgoing radiance for directions and a surface point: 𝑒𝑀 𝑝 (𝑦, 𝜄 𝑝 ) What about materials that are 𝑔 𝑠 𝑦, 𝜄 𝑗 , 𝜄 𝑝 = 𝑀 𝑗 𝑦, 𝜄 𝑗 cos 𝜄 𝑗 𝑒𝜕 𝑗 not purely specular, nor diffuse? 𝑜 𝑜 𝑜 𝜄 𝑗 𝜄 𝑝 𝑦
Advanced Graphics – BRDFs 4 Phong BRDFs, Recap We already know how to do materials that are diffuse and shiny. But that gets us good looking marble floors, not glossy reflections. 50% diffuse, 50% specular, 50% diffuse, 50% glossy (or: 100% glossy)
Advanced Graphics – BRDFs 5 Phong Glossy Reflection Glossy reflections: sending out rays in random directions close to the reflected vector. Simple solution: 𝑆 = 𝑠𝑓𝑔𝑚𝑓𝑑𝑢(𝐹, 𝑂); 𝑄 = 𝐽 + 𝑆 + 𝑡𝑑𝑏𝑚𝑓(𝑠𝑏𝑜𝑒𝑝𝑛𝑄𝑝𝑗𝑜𝑢𝐽𝑜𝑇𝑞ℎ𝑓𝑠𝑓(), 𝑡𝑞𝑓𝑑𝑣𝑚𝑏𝑠𝑗𝑢𝑧) 𝑆 = 𝑜𝑝𝑠𝑛𝑏𝑚𝑗𝑨𝑓(𝑄 − 𝐽); Or: 𝑆 = 𝑠𝑓𝑔𝑚𝑓𝑑𝑢(𝐹, 𝑂); 𝑄 = 𝐽 + 𝑆 + 𝑡𝑑𝑏𝑚𝑓(𝑠𝑏𝑜𝑒𝑝𝑛𝐸𝑗𝑠𝑓𝑑𝑢𝑗𝑝𝑜𝐽𝑜𝐼𝑓𝑛𝑗𝑡𝑞ℎ𝑓𝑠𝑓𝐷𝑝𝑡𝑗𝑜𝑓𝑋𝑓𝑗ℎ𝑢𝑓𝑒(𝑆), 𝑡𝑞𝑓𝑑𝑣𝑚𝑏𝑠𝑗𝑢𝑧) 𝑆 = 𝑜𝑝𝑠𝑛𝑏𝑚𝑗𝑨𝑓(𝑄 − 𝐽);
Advanced Graphics – BRDFs 6 Phong 𝑑𝑝𝑡 𝑓𝑦𝑞 𝜄 =? 𝛻 Glossy Reflection cos 𝜄 = 𝜌 𝛻 In OpenGL, shading is defined as follows*: 𝑓𝑦𝑞𝑝𝑜𝑓𝑜𝑢 𝐽 𝑦 = 𝑙 𝑏𝑛𝑐𝑗𝑓𝑜𝑢 𝑗 𝑏𝑛𝑐𝑗𝑓𝑜𝑢 + 𝑙 𝑒𝑗𝑔𝑔𝑣𝑡𝑓 𝑂 ∙ 𝑀 𝑛 + 𝑙 𝑡𝑞𝑓𝑑𝑣𝑚𝑏𝑠 𝑆 𝑛 ∙ 𝑊 𝐽 𝑛 𝑛∈𝑚𝑗ℎ𝑢𝑡 𝑆 𝑛 𝑀 𝑛 where 𝑙 𝑏𝑛𝑐𝑗𝑓𝑜𝑢 , 𝑙 𝑒𝑗𝑔𝑔𝑣𝑡𝑓 𝑏𝑜𝑒 𝑙 𝑡𝑞𝑓𝑑𝑣𝑚𝑏𝑠 are material properties (typically: rgb); 𝑆 𝑛 is the vector 𝑀 𝑛 reflected in the 𝑊 normal 𝑜 ; 𝐽 𝑛 is the illumination from light 𝑛 . 𝑜 𝑦 *: Bui-Tuong Phong, Illumination for Computer Generated Images, 1975.
Advanced Graphics – BRDFs 7 Phong Blinn-Phong BRDF (images: Disney BRDF Explorer )
Advanced Graphics – BRDFs 8 Phong Modified Phong BRDF
Advanced Graphics – BRDFs 9 Phong The BRDF relates irradiance to Fixing Phong outgoing radiance. Irradiance is measured per unit area; the reflected energy cannot exceed 1 Recall the requirements for a proper BRDF: per unit area , hence the cos: we essentially convert outgoing Should be positive: 𝑔 𝑠 𝜕 𝑝 , 𝜕 𝑗 ≥ 0 radiance into irradiance as well. Helmholtz reciprocity should be obeyed: 𝑔 𝑠 𝜕 𝑝 , 𝜕 𝑗 = 𝑔 𝑠 𝜕 𝑗 , 𝜕 𝑝 Alternatively, this also follows Energy should be conserved: 𝛻 𝑔 𝑠 𝜕 𝑝 , 𝜕 𝑗 cos𝜄 𝑝 𝑒𝜕 𝑝 ≤ 1 from the Helmholtz reciprocity principle: we can exchange 𝜕 𝑝 BRDFs obeying these rules are called physically plausible. and 𝜕 𝑗 . For a path tracer, we have additional requirements: 1. It ‘would be nice’ if we could generate a random direction proportional to the BRDF (IS) 2. We need to be able to calculate the probability density (importance) for a given direction (for MIS).
Advanced Graphics – BRDFs 10 Phong 𝑨 Fixing Phong 1. Sampling the specular lobe proportional to the BRDF: 𝑦 𝑆 ∙ 𝑊 1 𝑆 ∙ 𝑊 2 𝑆 ∙ 𝑊 10 𝑆 ∙ 𝑊 50 𝑧 Sampling proportional to Sampling proportional to 𝑆 ∙ 𝑊 𝛽 , according to the G.I.C. : 𝑂 ∙ 𝑀 , according to the G.I.C. : 2 𝑦 = cos 2𝜌𝑠 1 − 𝑠 2 𝑢 = 𝑠 𝛽+1 , 𝑦 = cos 2𝜌𝑠 1 − 𝑢 1 1 2 𝑧 = sin 2𝜌𝑠 1 − 𝑢 𝑧 = sin 2𝜌𝑠 1 − 𝑠 2 1 1 𝑨 = 𝑢 𝑨 = 𝑠 2
Advanced Graphics – BRDFs 11 Phong 𝑶 𝑨 Tangent / Local Space Setting up a local coordinate system in 2D: First axis is the normal; Second axis is perpendicular to normal. Good choice for 𝑋 : 𝑼 𝑂 = 𝑜 𝑦 𝑋 = (0,1,0) if abs( 𝑜 𝑦 ) > 0.99; 𝑈 = −𝑜. 𝑧 𝑋 = 1,0,0 otherwise. 𝑜. 𝑦 Setting up a local coordinate system in 3D: 𝑧 𝑪 𝑂 = 𝑜 𝑈 = 𝑜𝑝𝑠𝑛𝑏𝑚𝑗𝑨𝑓(𝑂 × 𝑋) 𝐶 = 𝑈 × 𝑂 where 𝑋 is a random unit vector; 𝑋 ≠ 𝑂 .
Advanced Graphics – BRDFs 12 Phong 𝑶 Tangent / Local Space Converting a vector from world space to local space: 𝑄 𝑄 ∙ 𝑈 𝑦 𝑄 = 𝑄 ∙ 𝐶 𝑧 𝑄 𝑄 ∙ 𝑂 𝑨 𝑼 Local space to world space: 𝑄 𝑥𝑝𝑠𝑚𝑒 = 𝑁 × 𝑄 𝑚𝑝𝑑𝑏𝑚 𝑪 = 𝑄 𝑦 𝑈 + 𝑄 𝑧 𝐶 + 𝑄 𝑨 𝑂
Advanced Graphics – BRDFs 13 Phong Normalizing the Lobe A material cannot reflect more energy than it receives: We thus scale the BRDF by the inverse of its integral over the hemisphere. 1 For the Lambertian BRDF: 𝑡𝑑𝑏𝑚𝑓 = 𝜌 (because cos 𝜄 integrates to 𝜌 ) 𝛽+1 For the cosine lobe, the scale is 2𝜌 (*). However, there is a problem: 𝑜 𝑜 𝑜 *: Physically Based Rendering, page 969; also see: http://www.farbrausch.de/~fg/stuff/phong.pdf
Advanced Graphics – BRDFs 14 1 𝛽+2 2𝜌 𝑑𝑝𝑡 𝛽 𝜒 : 𝑔 𝑠 𝑦, 𝜄 𝑗 , 𝜄 𝑝 = 𝑙 𝑒 𝜌 + 𝑙 𝑡 Phong Total hemispherical reflection (note: integrating over outgoing directions, since these cannot exceed 1): 𝜍 𝑦, 𝜄 𝑝 = 𝑔 𝑠 𝑦, 𝜄 𝑗 , 𝜄 𝑝 cos θ 𝑝 𝑒𝜕 𝑝 The Modified Phong BRDF Ω 1 𝛽 + 2 𝑑𝑝𝑡 𝛽 𝜒) cos θ 𝑝 𝑒𝜕 𝑝 = (𝑙 𝑒 𝜌 + 𝑙 𝑡 2𝜌 The Phong BRDF has problems: Ω 𝛽 + 2 𝑑𝑝𝑡 𝛽 𝜒 cos θ 𝑝 𝑒𝜕 𝑝 = 𝑙 𝑒 + 𝑙 𝑡 2𝜌 1. it does not doesn’t obey the Helmholtz reciprocity rule . Ω The last integral is maximal when the incoming light 2. We can only estimate the integral of the lobe, since it arrives along the normal; in this case 𝜒 = 𝜄 𝑝 , and the intersects the surface. integral is 2𝜌 / (𝑜 + 2) . Therefore, in this case: 𝜍 𝑦, 𝜄 𝑝 = 𝑙 𝑒 + 𝑙 𝑡 Compensating for the intersection: Modified Phong BRDF. and conservation of energy is guaranteed iff: 1 𝛽 + 2 2𝜌 𝑑𝑝𝑡 𝛽 𝜒 𝑔 𝑠 𝑦, 𝜄 𝑗 , 𝜄 𝑝 = 𝑙 𝑒 𝜌 + 𝑙 𝑡 𝑙 𝑒 + 𝑙_𝑡 ≤ 1. where 𝜒 is the angle between the view vector and the reflected light vector. For 𝑙 𝑒 + 𝑙 𝑡 < 1 , this guarantees energy preservation*. *: Lafortune & Willems, Using the Modified Phong Reflectance Model for Physically Based Rendering, 1994.
Advanced Graphics – BRDFs 15 Phong The Modified Phong BRDF Despite the kludges, we now have a decent BRDF for glossy materials. We can sample it: 2 𝑢 = 𝑠 𝛽+1 , 𝑦 = cos 2𝜌𝑠 1 − 𝑢 1 2 𝑧 = sin 2𝜌𝑠 1 − 𝑢 1 𝑨 = 𝑢 Normalize it: And finally, we can blend it with the Lambertian BRDF: 𝛽 + 2 2𝜌 𝑑𝑝𝑡 𝛽 𝜒 Define a probability 𝑞 of sampling Phong; Draw a random number 𝑠 0 ; Sample Phong if 𝑠 0 < 𝑞 , Lambert otherwise; 𝛽 + 2 2𝜌 𝑑𝑝𝑡 𝛽 𝜒 We have a PDF: Combine PDFs: 𝑄𝐸𝐺 = 𝑞 𝑄𝐸𝐺 𝑞ℎ𝑝𝑜 + 1 − 𝑞 𝑄𝐸𝐺 𝑒𝑗𝑔𝑔
Today’s Agenda: Phong BRDF Microfacets The Lobe
Advanced Graphics – BRDFs 17 Microfacet BRDFs Without Issues We now have two BRDFs without problems: 1. The Lambertian BRDF 2. The pure specular BRDF These are plausible and can be sampled. The PDF is also clear. And, we have the somewhat kludged modified Phong BRDF.
Advanced Graphics – BRDFs 18 Microfacet Microfacet BRDFs* We can simulate a broad range of materials if we assume: at a microscopic level, the material consists of tiny specular fragments. If the fragment orientations are chaotic, the material appears diffuse. If the fragment orientations are all the same, the material appears specular. Different but similar orientations yield glossy materials. *: Torrance & Sparrow, Theory for Off-Specular Reflection from Roughened Surfaces. 1967.
Advanced Graphics – BRDFs 19 Microfacet Microfacet BRDFs* The Microfacet BRDF: Ingredients: 1. Normal distribution D 𝑠 𝑀, 𝑊 = 𝐺 𝑀, 𝑊 𝐻 𝑀, 𝑊, 𝐼 𝐸 𝐼 𝑔 2. Geometry term G 4 𝑂 ∙ 𝑀 𝑂 ∙ 𝑊 3. Fresnel term F 4. Normalization
Advanced Graphics – BRDFs 20 Microfacet 𝑒𝑀 𝑝 (𝑦, 𝜄 𝑝 ) 𝑔 𝑠 𝑦, 𝜄 𝑗 , 𝜄 𝑝 = 𝑀 𝑗 𝑦, 𝜄 𝑗 cos 𝜄 𝑗 𝑒𝜕 𝑗 Normal Distribution Microfacet BRDF, ingredient 1: 𝐸(𝐼) the normal distribution function. Parameter 𝐼 : the halfway vector: A microfacet that reflects 𝑔 𝑠 𝑊, 𝑀 = ⋯ 𝑰 𝑀 towards 𝑊 must have a normal halfway 𝑊 and 𝑀 : 𝑴 H = normalize(V + L) . 𝑾
Recommend
More recommend