// Ref: Geometry into Shading - http://graphics.pixar.com/library/BumpRoughness/paper.pdf - equation (3)
float squaredRoughness = saturate(roughness * roughness + min(2.0 * variance, threshold * threshold)); // threshold can be really low, square the value for easier control
EnableDualSpecularLobe=newProperty(this,k_EnableDualSpecularLobe,"Enable Dual Specular Lobe","Enable a second specular lobe, aim to simulate a mix of a narrow and a haze lobe that better match measured material",true);
EnableIridescence=newProperty(this,k_EnableIridescence,"Enable Iridescence","Enable physically based iridescence layer",true);
EnableTextureNormalFiltering=newProperty(this,k_TextureNormalFilteringEnabled,"Enable Texture filtering","Require normal map to use _NA or _OSNA suffix for normal map name",true);
// All material properties
// All GroupPropery below need to define a
newProperty(this,k_AlbedoAffectEmissive,"Albedo Affect Emissive","Specifies whether or not the emissive color is multiplied by the albedo.",false),
newProperty(this,"_SpecularAntiAliasingScreenSpaceVariance","Screen Space Variance","Screen Space Variance (should be less than 0.25)",false,_=>EnableSpecularAA.BoolValue==true),
newProperty(this,"_SpecularAntiAliasingScreenSpaceVariance","Screen Space Variance","Screen Space Variance (should be less than 0.25)",false,_=>EnableGeometricNormalFiltering.BoolValue==true),
float averageNormalLength = packedNormal.w; // If we used a object space normal map that store average normal, the formap is RGB (normal xyz) and A (average normal length)
float averageNormalLength = packedNormal.z; // If we used a tangent space normal map that store average normal, the formap is RG (normal xy) and B (average normal length)