Report

Definition • Platforms for this talk – Windows / DirectX11 – OpenGL 4 / OpenGL ES 3.0 – PlayStation 4 – Xbox One ALU Budgets • What do you use higher ALU performance for? – Full HD resolution(1920x1080) • 2.25 times larger than half HD resolution(1280x720) – Post-processing • High quality post-processing with existing algorithms – High resolution post-processing – Glare, de-focus blur, motion blur – Screen-space anti-aliasing • New post-processing – Screen-space lighting (reflections), ambient obscurance, subsurface scattering, volume rendering Recent GPU Trend • ALU free – Current GPU performance doesn’t depend on the number of ALU cycles • B/W of cache / texture / render targets • Register / multi-threading • Limitations of render backend resources – Increasing the number of ALU instructions doesn’t tend to decrease performance • ALU is typically used to save B/W by encoding and decoding • It depends on the design of rendering passes How About Shading? • Many texture samples – For both forward and deferred techniques • The only difference is the rendering pass – – – – Albedo, Reflectance Normal / Height, Roughness, AO G-Buffer Light source (IBL / SSL) / accumulation, GI info. – Do we have a budget to use more ALU? More ALU? • Can we use more ALU instructions for shading? – Old normalized Blinn-Phong model uses 20 to 30 instructions Rd 1 F0 (c1 n c2 ) Fspec ( F0 )(n h) n max(n l, n e) – 100 instructions / light are affordable for new generation consoles – Using more instructions for shading is a good candidate to use ALU efficiently The Current Popular Model • A physically based model for specular – Microfacet model • GGX (Trowbridge-Reitz) (D) • Schlick approximation (F) • Smith (G) D(l, e) F (l, e)G(l, e) f r (l, e) 4(n l)(n e) Better Model for Fresnel? • Spherical Gaussian Approximation 5.55473 (eh)6.98316 eh F (e, h) f0 (1 f0 ) 2 – This model approximates the Schlick approximation – Should we approximate the Fresnel equation? – Should we use more a accurate approximation? Evaluation F(q ) Yellow : Fresnel equation (IOR = aluminum at 610nm) Green : Schlick approximation (IOR = aluminum at 610nm) Blue : Fresnel equation (IOR = 1.5) Purple : Schlick approximation (IOR = 1.5) q Need Approximation? • Do we have to approximate Fresnel for new generation consoles? – Fresnel equation w.r.t. reflectance ( f0 ) • It is easier to handle than refractive index ( f 1) cosq ( f 1) 2 ( f 1) cosq ( f 1) 2 0 0 0 0 F 0.5 ( f 0 1) cosq ( f 0 1) ( f 0 1) cosq ( f 0 1) 1 ( f 0 1) 2 (1 cos2 q ) ( f 0 1) 2 Fresnel with Reflectance • This Fresnel equation is inaccurate for large f0 – A large real f0 is calculated F(q ) from a complex refractive index (IOR = 1.3 + 7.48i) – The Fresnel equation Blue : Fresnel equation with the should take complex refractive index numbers Purple : Fresnel equation with the real reflectance – The complex version is more complicated q Improved Spherical Gaussian • Fresnel behavior is complicated – Need a complex approximation to represent the behavior – Try to improve accuracy with most useful value IOR = 1.5 F (q ) f 0 (1 f 0 ) 2 9.60232 cos8 q 8.58092 cosq Improved Spherical Gaussian F(q ) (IOR = 1.5) Schlick Blue : Schlick approximation Purple : Fresnel equation Yellow : Improved Spherical Gaussian Improved Spherical Gaussian q Conclusion for F Term • Schlick is a good enough approximation – It still has a problem with complex refractive indices with a large imaginary part • It can be improved with Fresnel Term Approximations for Metals [WSCG 2005] – It requires a complex refractive index as a parameter – This difference is difficult to distinguish with punctual lights, but is more visible with image based lighting • We use the Schlick approximation in this talk, though you can choose better approximations (including improved Spherical Gaussian) as you like How about Diffuse? • Lambert? – It is not realistic – We use microfacet models for specular, so why not for diffuse? Oren-Nayar? • Use Oren-Nayar [SIGGRAPH 1994] – Diffuse model taking into account the microfacet model and roughness • View dependent component • Matte-look depending on roughness • Retro-reflective effect Problems with Oren-Nayar • NDF is not GGX – NDF of Oren-Nayar is D(l) c e ql2 2 2 • G term is not Smith – Torrance-Sparrow V-cavity model • Oren-Nayar doesn’t conserve energy with specular on each facet – Not a physically based model Our Goal • Better diffuse model – Using the same microfacet model as specular – Physically based diffuse model Microfacet Model for Specular • A reflectance model for specular can be simple – You only take reflection in view direction into account D(l, e) F (l, e)G(l, e) f r (l, e) 4(n l)(n e) Microfacet Model for Diffuse • Since diffuse reflects incident light in all directions, a reflectance model is complex – If we assume all facets are Lambertian – All facets reflect toward view direction f r (n,l,e) 1 (m l)(m e) D(m) Fdiff (m, l, e)G(m, l, e)dm (n l)(n e) : Hemisphere around the geometry normal(n) m : Microfacet normal Try to Improve Oren-Nayar • The first problem is that Oren-Nayar doesn’t take Fresnel into account – See “Improved Diffuse Reflection Models for Computer Vision” [WOLFF et al. 1998] Starting Point Blue : Original Oren-Nayar Purple : Improved one (SIGGRAPH 2012) Lr qe 2 2 n l if E0 (n l )(1.0 0.5 2 ) (0.45 2 )(e l (n e)(n l )) Min(1, ) 0.65 0.09 n e (e l (n e)(n l)) 0 Lr 2 2 E0 (n l)(1.0 0.5 2 ) (0.45 2 )(e l (n e)(n l ))(n l ) 0.65 0.09 otherwise Intuition • When surface gets rougher – Microfacet model behaves like a blur filter – When roughness = 0 • Fresnel effect with Lambertian – When roughness increases • Fresnel effect gets blurrier Oren-Nayar analysis 2 2 n l E0 (n l )(1.0 0.5 2 ) (0.45 2 )(e l (n e)(n l )) Min(1, ) 0.65 0.09 n e Lambertian Blending factor (with roughness) View-dependent factor (microfacet effect) Diffuse Fresnel Term • Using “A Practitioners’ Assesment of Light Reflection Models” [PG 1997] 21 Fdiff (l, e) (1 f 0 ) 1 (1 n l )5 1 (1 n e)5 20 Add Fresnel Term 2 2 n l E0 (1 f 0 ) Fdiff (l, e)(n l )(1.0 0.5 2 ) (0.45 2 )(e l (n e)(n l )) Min(1, ) 0.65 0.09 n e 21 Fdiff (l, e) 1 (1 n l )5 1 (1 n e)5 20 Fdiff (l, e) (1 f 0 ) 21 1 (1 n l )5 1 (1 n e)5 20 Result roughness = 0.7 Lambert Improved Oren-Nayar [SIGGRAPH 2012] Oren-Nayar with Fresnel Analysis n·e 1 (0) cos 1 (0) f0 Lr Blue : Oren-Nayar, roughness = 0.0 Purple: Oren-Nayar w/ Fresnel, roughness = 0.0 Yellow: Oren-Nayar, roughness = 1.0 Green : Oren-Nayar w/ Fresnel, roughness = 1.0 0.04 ql Analysis n·e 0.707 (45) cos 1 (0) f0 Lr Blue : Oren-Nayar, roughness = 0.0 Purple: Oren-Nayar w/ Fresnel, roughness = 0.0 Yellow: Oren-Nayar, roughness = 1.0 Green : Oren-Nayar w/ Fresnel, roughness = 1.0 0.04 ql Analysis n·e 0.174(80) cos 1 (0) f0 Lr Blue : Oren-Nayar, roughness = 0.0 Purple: Oren-Nayar w/ Fresnel, roughness = 0.0 Yellow: Oren-Nayar, roughness = 1.0 Green : Oren-Nayar w/ Fresnel, roughness = 1.0 0.04 ql Is This Physically Based Diffuse? • This is still a compromise – F term • In reality, each facet must follow Fresnel • Integrate Fresnel (with other terms) over facets – D and G terms • Still not GGX and Smith Try to Derive a New Diffuse Model • Simply, integrating the diffuse microfacet model with given D, F and G functions – Not modifying Oren-Nayar f r (n,l,e) 1 (m l)(m e) D(m)(Fdiff (m, l, e))G(m, l, e)dm (n l)(n e) Deriving a New Model • The model doesn’t have a closed form – It is numerically integrated Analysis n·e 1.0 (0) cos 1.0 (0) Lr Blue : Oren-Nayar Purple: Oren-Nayar w/ Fresnel Green : New model roughness 0.0 f0 0.04 ql Analysis n·e 1.0 (0) cos 1.0 (0) Lr Blue : Oren-Nayar Purple: Oren-Nayar w/ Fresnel Green : New model roughness 0.5 f0 0.04 ql Analysis n·e 1.0 (0) cos 1.0 (0) Lr Blue : Oren-Nayar Purple: Oren-Nayar w/ Fresnel Green : New model roughness 1.0 f0 0.04 ql Analysis n·e 0.5 (60) cos 1.0 (0) Lr Blue : Oren-Nayar Purple: Oren-Nayar w/ Fresnel Green : New model roughness 0.8 f0 0.04 ql Analysis n·e 0.342 (70) cos 0.5 (60) Lr Blue : Oren-Nayar Purple: Oren-Nayar w/ Fresnel Green : New model roughness 0.6 f0 0.04 ql Analysis n·l 0.866 (30) cos 1.0 (0) Lr Blue : Oren-Nayar Puprle: Oren-Nayar w/ Fresnel Green : New model roughness 0.0 f0 0.04 qe Analysis n·l 0.866 (30) cos 1.0 (0) Lr Blue : Oren-Nayar Purple: Oren-Nayar w/ Fresnel Green : New model roughness 0.3 f0 0.04 qe Analysis n·l 0.866 (30) cos 1.0 (0) Lr Blue : Oren-Nayar Purple: Oren-Nayar w/ Fresnel Green : New model roughness 0.7 f0 0.04 qe Analysis n·l 0.259 (75) cos 0.985 (10) Lr Blue : Oren-Nayar Purple: Oren-Nayar w/ Fresnel Green : New model roughness 0.8 f0 0.04 qe Implementation of the New Model • Baking the model to a texture is the simplest way – 3 vectors and 2 scalars • f0 can be factored out of texture – It is difficult to bake the model directly f r (n,l,e, f 0 , r ) 1 (m l )(m e) D(m, r ) Fdiff (m, l, e, f 0 )G(m, l, e, r )dm (n l)(n e) ALU implementation • When your shader is texture-bound – Typically, it is texture-bound – Complex fitted model is better than texture reads Fitted Shading Model Lr (e, l, , f 0 ) 21 1 f 0 Fr (e, l, ) Lm (l, ) Vd (e, l, ) B p (e, l) 20 0.542026 2 0.303573 Fr (e, l, ) 1 2 1.36053 1 (1 n e)5 4 0.733996 3 1.50912 2 1.16402 1 n e 39 4 11 1 1 2 1.36053 2 Lm (l, ) Max1 2 ,0 1 1 n l Min2 ,1 1 0.5 n l 0.5 (n l)2 5 10.3726732 ( ne )2 0.188566 0.388410 ne 1 1 n l Vd (e ,l, ) 2 ( 0.09)(1.31072 0.995584(n e)) 2 1.4(n e)(n l)e l (n e)(n l) Bp (e ,l) e l (n e)(n l) if (e l (n e)(n l)) 0 otherwise Complexity • The model is very complicated – Only a slight performance difference between our new model and Oren-Nayar in typical scenes – ALU is free! Fitted Model Analysis n·e 1.0 (0) cos 1.0 (0) roughness 0.0 f0 Lr Blue : Fitted model Orange Dash : Numerically integrated 0.04 ql Fitted Model Analysis n·e 1.0 (0) cos 1.0 (0) roughness 0.5 f0 Lr Blue : Fitted model Orange Dash : Numerically integrated 0.04 ql Fitted Model Analysis n·e 1.0 (0) cos 1.0 (0) roughness 1.0 f0 Lr Blue : Fitted model Orange Dash : Numerically integrated 0.04 ql Fitted Model Analysis n·e 0.5 (60) cos 1.0 (0) roughness 0.8 f0 Lr Blue : Fitted model Orange Dash : Numerically integrated 0.04 n·l Fitted Model Analysis n·e 0.342 (70) cos 0.5 (60) roughness 0.6 f0 Lr Blue : Fitted model Orange Dash : Numerically integrated 0.04 ql Fitted Model Analysis n·l 0.866 (30) cos 1.0 (0) roughness 0.0 f0 Lr Blue : Fitted model Orange Dash : Numerically integrated 0.04 qe Fitted Model Analysis n·l 0.866 (30) cos 1.0 (0) roughness 0.3 f0 Lr Blue : Fitted model Orange Dash : Numerically integrated 0.04 qe Fitted Model Analysis n·l 0.866 (30) cos 1.0 (0) roughness 0.7 f0 Lr Blue : Fitted model Orange Dash : Numerically integrated 0.04 qe Fitted Model Analysis n·l 0.259(75) cos 0.985 (10) roughness 0.8 f0 Lr Blue : Fitted model Orange Dash : Numerically integrated 0.04 qe Limitation • Accuracy at grazing angles for both view and light vectors is not enough with this model – It may be noticeable on the edges • Roughness is assumed to be from 0 to 1 • The fitting model shouldn’t be used to compute AmbientBRDF texture Results Roughness 0.0 Lambert Oren-Nayar w/Fresnel New model Results Roughness 0.05 Lambert Oren-Nayar w/Fresnel New model Results Roughness 0.1 Lambert Oren-Nayar w/Fresnel New model Results Roughness 0.3 Lambert Oren-Nayar w/Fresnel New model Results Roughness 1.0 Lambert Oren-Nayar w/Fresnel New model Results Roughness 1.0 (diffuse only) Lambert Oren-Nayar w/Fresnel New model Lambert Oren-Nayar w/Fresnel New model Lambert Oren-Nayar w/Fresnel New model Lambert Oren-Nayar w/Fresnel New model Conclusion • From a physically based perspective, the same microfacet model should be used for both diffuse and specular – It makes more persuasive visuals – New consoles have enough computational power to implement such complex models Acknowledgements Questions? You can find these slides, including past presentations, at http://research.tri-ace.com/