//////////////////////// //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 ) ) ) );
Spec BRDF ref
12 Trackbacks