0
$\begingroup$

I am implementing fresnel reflections for materials in my renderer.
Does it make sense for metals?

Here my implementation:

float BlinnPhong(const DistributionFunction::SampleInput& input, float shininess)
{
    const float normalizationFactor = (shininess + 8.0f) * Math::InvPi8.getValue();
    return std::pow(input.HoN, shininess) * normalizationFactor;
}

float ComputeFresnel0(float ior)
{
    return std::powf((ior - 1.0f) / (ior + 1.0f), 2.0f);
}

float ComputeFresnel(float F0, float HoV)
{
    return F0 + (1.0f - F0) * pow(1.0f - HoV, 5.0f);
}  

// Here: the sampling function.
RGBFColor SampleMetalBrdf(const DistributionFunction::SampleInput& sampleInput)
{
    static const float ior = 1.5f;
    const float F0 = ComputeFresnel0(ior);
    const float fresnel = ComputeFresnel(F0, sampleInput.HoV);  

    static const float shininess = 120.0f;
    const float specularFactor = BlinnPhong(sampleInput, shininess);

    static const RGBFColor baseColor = RGBFColor(1.0f);

    return baseColor * specularFactor * fresnel * sampleInput.NoL; // Multiply by distSampleInput.NoL here for purpose. 
}
$\endgroup$

1 Answer 1

3
$\begingroup$

I think this question is a bit tricky to answer, since I have some seemingly contradictory knowledge about your implementation. If I recall correctly, you are using Schlick approximation for the Fresnel term, which is:

  • Used for physically based anisotropic surface reflection, like FresnelBlend BRDF, which matches closely with your code (the difference is that Blinn-Phong is replaced by microfacet distribution). This BRDF looks metallic and of course, it is used to model metallic surfaces.
  • Schlick approximation is designed for dieletric materials (glass / water, etc.), since conductor (metal) has different way to compute Fresnel term. The indices of refraction are simply (literally) complex. There are some paper stating that Schlick approximation produces erroneous results and should only be used for non-conductor surfaces.

You see how things contradict here. I guess the answer for your question is:

  • If you want to model metallic (metal-like) surface, Schlick approximation (and hence your code) does make sense.
  • If you want to model metal (exact definition): no, it is not suggested to model metal this way. You can refer to PBR-Book 8.2.1 Specular Reflection and Transmission for the modeling of conductor material.

For the specific implementation (and possible bugs): why do you call this function sample? This looks like evaluation to me since you are not sampling Fresnel term or Blinn-Phong BRDF but evaluating them. This is minor though so you can ignore it.

$\endgroup$
1
  • $\begingroup$ Thank you very much :) $\endgroup$ Sep 25, 2023 at 21:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.