Skip to content

Specular weight > 1 can cause energy gain in metals, and NaNs in dielectrics #224

@portsmouth

Description

@portsmouth

On testing we noticed that if specular_weight > 1 and the material is metallic, then there is energy gain, e.g.:

specular_weight 1 specular_weight 6
metaLwf_sw1 metaLwf_sw6

This happens because the specular_weight multiplies the metallic lobe as below:

image

We forgot to add a clamp to prevent the Fresnel factor exceeding 1 when the weight exceeds 1 though, which IMO is a mistake in the spec itself. We could either clamp the specular_weight before multiplying, or clamp each component of the final metallic Fresnel factor. The latter is closer to what we do for the dielectric case, so probably best.


Another issue we noted is that the formula below from the spec, for the dielectric Fresnel IOR ratio, produces inf if specular_weight is high, since $\epsilon=1$ then results (due to the clamp) which produces zero in the denominator (and this will later propagate into NaNs). This needs to be checked for and avoided, e.g. by clamping the denominator to be < 1.

image

This is not really an error in the spec (though arguably it is, since an infinite IOR doesn't make physical sense), but it's a rather easy mistake to make in implementing it (and thus generate NaNs in the render), so I suggest we point out the need to clamp explicitly in the spec.

NB, I think this bug is also present in the current MaterialX implementation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions