vMF Diffuse

A unified rough diffuse BRDF

Eugene d’Eon and Andrea Weidlich
EGSR 2024

https://diglib.eg.org/handle/10.1111/cgf15149

Implementation

Cross section of the vMF NDF for u = cos(θ), m = Beckmann roughness α

sigmaBeckmannExpanded[u_,m_]:=(1/2) (u (1+Erf[(u/(m (Sqrt[1-(u^2)])))])+((m (Sqrt[1-(u^2)]) (E^((u^2)/((m^2) ((u^2)-1)))))/(Sqrt[π])))+(1/4) (Tanh[(1/(m^2))] (u-(m^2) Abs[u])+(-(m^2)-2) u+u Coth[(1/(m^2))])

sigmaBeckmannExpanded[1,m_]:=(1/4) ((m^2)-(E^(2/(m^2))) (-2+(m^2))) Csch[(2/(m^2))]

sigmaBeckmannExpanded[u_,0]:=(1/2) (u+Abs[u])

sigmaVMF[1,m_]:=(1/4) ((m^2)-(E^(2/(m^2))) (-2+(m^2))) Csch[(2/(m^2))]

sigmaVMF[0,m_]:=(1/2) BesselI[1,(2/(m^2))] Csch[(2/(m^2))]

sigmaVMF[-1,m_]:=(1/4) ((m^2)-(E^(-(2/(m^2)))) (2+(m^2))) Csch[(2/(m^2))]

sigmaVMFSH2[u_,m_]:=(1/4)-(1/4) u ((m^2)-2 Coth[(2/(m^2))])+(5/128) (-1+3 (u^2)) (4+3 (m^4)-6 (m^2) Coth[(2/(m^2))])

sigmaVMFSH12[u_,m_]:=(1/4)-(1/4) u ((m^2)-2 Coth[(2/(m^2))])+(5/128) (-1+3 (u^2)) (4+3 (m^4)-6 (m^2) Coth[(2/(m^2))])-((3 (3-30 (u^2)+35 (u^4)) (16+180 (m^4)+105 (m^8)-10 (m^2) (8+21 (m^4)) Coth[(2/(m^2))]))/4096)+(1/262144)13 (-5+105 (u^2)-315 (u^4)+231 (u^6)) (64+105 (m^4) (32+180 (m^4)+99 (m^8))-42 (m^2) (16+240 (m^4)+495 (m^8)) Coth[(2/(m^2))])+(1/16777216)17 (E^(-(2/(m^2)))) (35-1260 (u^2)+6930 (u^4)-12012 (u^6)+6435 (u^8)) (1+Coth[(2/(m^2))]) (-256-315 (m^4) (128+33 (m^4) (80+364 (m^4)+195 (m^8)))+18 (m^2) (256+385 (m^4) (32+312 (m^4)+585 (m^8))) Coth[(2/(m^2))]) Sinh[(2/(m^2))]-(1/536870912)49 (E^(-(2/(m^2)))) (-63+3465 (u^2)-30030 (u^4)+90090 (u^6)-109395 (u^8)+46189 (u^10)) (1+Coth[(2/(m^2))]) (-1024-495 (m^4) (768+91 (m^4) (448+15 (m^4) (448+1836 (m^4)+969 (m^8))))+110 (m^2) (256+117 (m^4) (256+21 (m^4) (336+85 (m^4) (32+57 (m^4))))) Coth[(2/(m^2))]) Sinh[(2/(m^2))]+(1/17179869184)75 (E^(-(2/(m^2)))) (231-18018 (u^2)+225225 (u^4)-1021020 (u^6)+2078505 (u^8)-1939938 (u^10)+676039 (u^12)) (1+Coth[(2/(m^2))]) (-4096-3003 (m^4) (1024+45 (m^4) (2560+51 (m^4) (1792+285 (m^4) (80+308 (m^4)+161 (m^8)))))+78 (m^2) (2048+385 (m^4) (1280+153 (m^4) (512+57 (m^4) (192+35 (m^4) (40+69 (m^4)))))) Coth[(2/(m^2))]) Sinh[(2/(m^2))]

sigmaVMF[u_,Infinity]:=(1/4)

sigmaVMF[u_,m_]:=If[m<0.25,sigmaBeckmannExpanded[u,m],If[m>0.9,sigmaVMFSH2[u,m],sigmaVMFSH12[u,m]]]

Fourier coefficients of the BRDF

f10[ui_,uo_,r_]:=Module[{Beckmannα,C100,C101,C102,C103},
Beckmannα=-Log[1-(Sqrt[r])];
C100=1+((-0.1 r+0.84 (r^4))/(1+9 (r^3)));C101=((0.0173 r+20.4 (r^2)-9.47 (r^3))/(1+7.46 r));C102=((-0.927 r+2.37 (r^2))/(1.24 +(r^2)));C103=((-0.11 r-1.54 (r^2))/(1-1.05 r+7.1 (r^2)));
(1/Pi)(((sigmaVMF[ui,Beckmannα]  sigmaVMF[uo,Beckmannα] ))/(ui sigmaVMF[-uo,Beckmannα]+uo sigmaVMF[ui,Beckmannα])) (C100+C101 (ui uo)+C102((ui^2)(uo^2))+C103((ui^2)+(uo^2)))
]

f11[ui_,uo_,r_]:=Module[{Beckmannα,C110,C111,C112},
Beckmannα=-Log[1-(Sqrt[r])];
C110=((0.54 r-0.182 (r^3))/(1+1.32 (r^2)));C111=((-0.097 r+0.62 (r^2)-0.375 (r^3))/(1+0.4 (r^3)));C112=0.283+0.862 r-0.681 (r^2);
(1/Pi)((((sigmaVMF[ui,Beckmannα]  sigmaVMF[uo,Beckmannα] ))^C112)/(ui sigmaVMF[-uo,Beckmannα]+uo sigmaVMF[ui,Beckmannα]))((Sqrt[(-1+(ui^2)) (-1+(uo^2))])(C110+C111 (ui uo)))
]

f12[ui_,uo_,r_]:=Module[{C120,C121},
C120=((2.25 r+5.1 (r^2))/(1+9.8 r+32.4 (r^2)));C121=((-4.32r+6  (r^3))/(1+9.7 r+287 (r^3)));
(1/Pi)(1/(ui+uo))(1-(ui^2))(1-(uo^2))(C120+C121 ui)(C120+C121 uo)
]

f20[ui_,uo_,r_]:=Module[{C200,C201,C202,C203,C204},
C200=((0.00056r+0.226 (r^2))/(1+7.07 (r^2)));C201=((-0.268 r+4.57 (r^2)-12.04 (r^3))/(1+36.7 (r^3)));
C202=((0.418 r+2.52 (r^2)-0.97 (r^3))/(1+10 (r^2)));C203=((0.068 r-2.25 (r^2)+2.65 (r^3))/(1+21.4 (r^3)));C204=((0.05 r-4.22(r^3))/(1+17.6 (r^2)+43.1 (r^3)));
(1/Pi)(1/(ui+uo))((C200+C201 (ui uo)+C202(ui+uo)+C203(ui uo ui uo)+C204((ui^2)+(uo^2))))
]

f21[ui_,uo_,r_]:=Module[{C210,C211,C212},
C210=((-0.049r-0.027 (r^3))/(1+3.36 (r^2)));C211=((2.77 (r^2)-8.332 (r^(2.5`))+6.073(r^3))/(1+50 (r^4)));C212=((-0.431 (r^2)-0.295 (r^3))/(1+23.9 (r^3)));
(1/Pi)(1/(ui+uo))(Sqrt[1-(ui^2)])(Sqrt[1-(uo^2)])((C210+C211 (ui uo)+C212(ui+uo)))
]

f30[ui_,uo_,r_]:=Module[{C300,C301,C302,C303,C304},
C300=((-0.083 (r^3)+0.262 (r^4))/(1-1.9 (r^2)+38.6 (r^4)));C301=((-0.627 (r^2)+4.95 (r^(2.5`))-2.44 (r^3))/(1+31.5 (r^4)));
C302=((0.33 (r^2)+0.31 (r^(2.5`))+1.4 (r^3))/(1+20(r^3)));C303=((-0.74 (r^2)+1.77 (r^(2.5`))-4.06 (r^3))/(1+215 (r^5)));C304=-((1.026 (r^3))/(1+5.81 (r^2)+13.2 (r^3)));
(1/Pi)(1/(ui+uo))((C300+C301 (ui uo)+C302(ui+uo)+C303(ui uo ui uo)+C304((ui^2)+(uo^2))))
]

f31[ui_,uo_,r_]:=Module[{C310,C311,C312},
C310=((0.028(r^2)-0.0132 (r^3))/(1+7.46 (r^2)-3.315 (r^4)));C311=((-0.134 (r^2)+0.162 (r^(2.5`))+0.302 (r^3))/(1+57.5 (r^(4.5`))));C312=((-0.119 (r^2)+0.5(r^(2.5`))-0.207 (r^3))/(1+18.7 (r^3)));
(1/Pi)(1/(ui+uo))(Sqrt[1-(ui^2)])(Sqrt[1-(uo^2)])((C310+C311 (ui uo)+C312(ui+uo)))
]

Multiple (4+) scattering approximation

fm[ui_,uo_,r_,c_]:=Module[{Ck,Ca},
Ck=((1-0.5441615108674713 (Sqrt[1-c])-0.45302863761693374 (1-c))/(1+1.4293127703064865 (Sqrt[1-c])));
Ca=c/Power[1.16942*(Sqrt[1-c])+1.0075,ArcTan[(r*(-0.264641+r)+0.0225272)*Erf[(Sqrt[1-c])]]];
Max[0, 0.384016*Ck*((Abs[Tanh[r]-0.0898863]-(0.0578978/(0.287663+ui uo)))*Ca)*(-0.341969+Ca)]
]

Full BRDF

vMFdiffuseBRDF[ui_,uo_,phi_,r_,c_]:=Max[0,c(f10[ui,uo,r]+2Cos[phi]f11[ui,uo,r]+2Cos[2phi]f12[ui,uo,r])]+Max[0,(c^2)(f20[ui,uo,r]+2Cos[phi]f21[ui,uo,r])]+Max[0,(c^3)(f30[ui,uo,r]+2Cos[phi]f31[ui,uo,r])]+fm[ui,uo,r,c]

vMFdiffuseBRDF[.1,.2,.3,.4,.97]