Spec BRDF ref

////////////////////////
//LD - Light direction//
//VD - View direction //
//N  - Normal         //
//a  - Roughness      //	
////////////////////////
float pi				= 3.14159265358979323;
float a 				= roughness * roughness;
float3 H				= normalize(LD + VD);
float HdotN	  			= dot( N, H );
float VdotH				= dot( VD, H );
float VdotN				= saturate(dot( N, VD ));
float LdotN				= saturate( dot( LD, N ));
float LdotH				= saturate(dot( N, H ));

//Normal Distribution Function//
////////////BECKMANN////////////
float NDF_Beckmann = 1.0 / ( pi * a * a ( pow( NdotH, 4.0f ) ) ) * exp ( ( pow( NdotH, 2.0f) - 1.0f ) / a * a * ( pow( NdotH, 2.0f ) ) );

////////////////////////////////
//////////BLINN_PHONG///////////
float NDF_BlinnPhong = ( 1.0f / ( pi * a * a ) ) * ( pow( NdotH, 2.0 / ( a * a ) - 2.0f ) );

////////////////////////////////
////GGX(TROWBRIDGE-REITZ)///////
float NDF_TrowReitz = ( a * a ) / pi * ( pow( (pow( NdotH, 2.0f ) * ( a * a - 1.0f ) + 1.0f ), 2.0) );


////////////////////////////////
////////////G-TERM//////////////
//////SIMPLE(Implicit)//////////
float G_Simple = LdotN * VdotN;

////////////////////////////////
//////////KELEMEN///////////////
float G_Kelemen = ( LdotN * VdotN ) / ( pow( VdotH, 2.0f ) );

////////////////////////////////
////////////NEUMANN/////////////
float G_Neumann = ( LdotN * VdotN ) / max( LdotN, VdotN );

////////////////////////////////
////////BECKMANN////////////////
float G_Beckmann = 0.0;
float c = VdotN / ( a * sqrt( 1.0f - ( pow( VdotN, 2.0f ) ) ) );
if ( c < 1.6) {
	G_Beckmann = ( 3.535f * c + 2.181 * pow(c, 2.0f ) ) / ( 1.0f + 2.276 * c + 2.577 * pow(c, 2.0f ) );
}
else {
	G_Beckmann = 1.0f;
}

//////////////////////////////// 
////////COOK-TORRANCE///////////
float G_CookTorr = min( 1.0f, min( ( 2.0f * HdotN * VdotH ) / VdotH, ( 2.0f * HdotN * LdotN ) / VdotH ) );

////////////////////////////////
/////////GGX(SMITH-WALTER)////////////
float G_GGXL = ( 2.0f * LdotN ) / ( LdotN + sqrt(a * a + ( 1.0f - a * a ) * ( pow(LdotN, 2.0f ) ) ) );
float G_GGXV = ( 2.0f * VdotN ) / ( VdotN + sqrt(a * a + ( 1.0f - a * a ) * ( pow(VdotN, 2.0f ) ) ) );
float G_GGX_SmithWalter = G_GGXV * G_GGXL; 

////////////////////////////////
/////GGX(SMITH-BECKMANN)////////
float G_GGXL = LdotN / ( a * sqrt(1.0f - ( pow(LdotN, 2.0f ) ) ) );
float G_GGXV = VdotN / ( a * sqrt(1.0f - ( pow(VdotN, 2.0f ) ) ) );
float G_GGX_SmithBeckmann = G_GGXV * G_GGXL; 

////////////////////////////////
/////GGX(SMITH-SCHLICK)/////////
float k = a * sqrt( 2.0f / pi );
float G_GGXL = LdotN / ( LdotN * ( 1.0f - k ) + k );
float G_GGXV = VdotN / ( VdotN * ( 1.0f - k ) + k );
float G_GGX_SmithSchlick = G_GGXV * G_GGXL; 

////////////////////////////////
///////////FRESNEL//////////////
//////////SHLICK////////////////
float F0 = FRESNEL; //Reflectance at normal incidence
float F_Schlick = F0 + ( 1.0f - F0) * pow(1.0f - VdotH, 5.0f );

////////////////////////////////
/////////COOK-TORRANCE//////////
float Eta = ( 1.0f + sqrt(F0 ) ) / ( 1.0f - sqrt(F0 ) );
float c = VdotH;
float g = sqrt(pow(Eta, 2.0f ) + pow(c, 2.0f ) - 1.0f );
float F = 0.5f * (pow( ( g - c ) / ( g + c ) , 2.0f ) * ( 1.0f + (pow( ( ( g + c ) * c - 1.0f ) / ( ( g - c ) * c + 1.0f ), 2.0f ) ) ) );

BRDF

Common Cook-Torrance microfacet specular BRDF (0)

$$ f(l, v) = \frac{D(h) F(v, h) G(l, v, h)}{4(n\cdot l)(n\cdot v)} $$

  • l – light direction
  • v – view direction
  • f (l,v)– brdf
  • D(h) – normal distribution function
  • F(v,h) – fresnel function
  • G(l,v,h) – geometric shadowing term

For D I like Trowbridge-Reitz GGX

$$ D_{GGX}(v) = \frac{\alpha^2}{\pi((n \cdot m)^2 (\alpha^2 – 1) + 1)^2} $$

$$ \alpha = roughness^2 $$ Unreal alpha, matches Burley’s remapping(1) $$ \alpha = (1 – smoothness * 0.7)^6 $$ Ryse alpha, matches (2) $$(1-smoothness)^4$$

Ff

For G best Smith-Schlick

$$ G(l, v, h) = G_{1}(l) G_{1}(v) $$

$$ G_{Schlick}(v) = \frac{n\cdot v}{(n\cdot v)(1 – k) + k } $$

$$ G_{Schlick}(l) = \frac{n\cdot l}{(n\cdot l)(1 – k) + k } $$

$$ k = \frac{(0.8 + 0.5*\alpha)^2}{2} $$

Crytek Ryse – avoid highlights getting too hot on smooth surfaces and reduce gain on rough materials at grazing angles

$$ k = 0.5*\alpha \text{ – fit for me} $$

Fresnel function Schlick (3)

$$ F_{Schlick}(\mathbf{v}, \mathbf{h}) = F_0 + (1 – F_0) ( 1 – (v \cdot h) )^5 $$

ff2