Real Shading in Unreal Engine 4 Brian Karis (
[email protected]) Goals • More realistic image • Material layering – Better workflow – Blended in shader • Timely inspiration from Disney – Presented in this course last year Overview • Shading model • Material model • Lighting model Shading Model Diffuse BRDF • Lambert – Saw little effect of more sophisticated models Lambert Burley Specular BRDF • Generalized microfacet model – Compared many options for each term – Use same input parameters 퐷 h 퐹(l, h)퐺 l, v, h 푓 l, v = 4(n ⋅ l)(n ⋅ v) 퐷 h 퐹(l, h)퐺 l, v, h 푓 l, v = Specular distribution 4(n ⋅ l)(n ⋅ v) • Trowbridge-Reitz (GGX) – Fairly cheap – Longer tail looks much more natural GGX Blinn-Phong 퐷 h 퐹(l, h)퐺 l, v, h 푓 l, v = Geometric shadowing 4(n ⋅ l)(n ⋅ v) • Schlick – Matched to Smith – Cheaper, difference is minor – Uses Disney’s roughness remapping* n ⋅ v 퐺푆푐ℎ푙푐푘(v) n ⋅ v 퐺푆푚푡ℎ(v) 훼 = 0.1 훼 = 0.5 훼 = 0.9 퐷 h 퐹(l, h)퐺 l, v, h 푓 l, v = Fresnel 4(n ⋅ l)(n ⋅ v) • Schlick – Approximate the power Identical for all practical purposes Image-based lighting : Problem • Only use single sample per environment map • Match importance-sampled reference 푁 1 퐿 l푘 푓 l푘, v 푐표푠 휃l푘 퐿 l 푓 l, v 푐표푠 휃l 푑l ≈ 푁 푝 l푘, v 퐻 푘=1 Image-based lighting : Solution • Same as Dimitar’s: split the sum • Pre-calculate both parts 푁 푁 푁 1 퐿 l푘 푓 l푘, v cos 휃l푘 1 1 푓(l푘, v) cos 휃l푘 ≈ 퐿 l 푘 푁 푝 l푘, 푣 푁 푁 푝(l푘, v) 푘=1 푘=1 푘=1 Pre-filtered environment map • 1st sum stored in cubemap mips – Pre-filter for specific roughness’s – Fixed distribution, assume n = v – Loses stretched highlights 푁 1 퐿 l ≈ Cubemap.