AcademySoftwareFoundation / OpenPBR

Specification and reference implementation for the OpenPBR Surface shading model
Apache License 2.0
474 stars 20 forks source link

Ability to tint specular highlights without affecting grazing angles #77

Open lukasstockner opened 1 year ago

lukasstockner commented 1 year ago

Currently, the only way to affect the color of the dielectric reflection lobe is specular_color, which affects all angles equally.

However, for compatibility with other material models (e.g. the classic Disney BSDF, or glTF's KHR_materials_specular), it would be useful to have a parameter for only affecting normal-incidence angles while leaving the grazing angles as they are.

More specifically, in a Schlick-style Fresnel term, this parameter would only affect F0, not F90. This can be implemented in combination with the proper dielectric Fresnel term by computing real_F0 from the IOR, then computing the Fresnel value using the dielectric term, and then remapping from the real_F0 .. 1.0 range to F0 .. F90.

portsmouth commented 1 year ago

I'm not sure about adding even more ways to specify a non-physical Fresnel factor. If we add these F0, F90 colors for the dielectric Fresnel, I would worry that we're failing to "ensure that the users work within the bounds of what is physically plausible as much as possible", instead we would be allowing/encouraging them to easily step outside those bounds. (It's been suggested that specular_color for dielectric should actually be removed, i.e. fixed at white, for that reason).

There is a genuine physical mechanism for producing a colored dielectric Fresnel factor, i.e. dispersion (wavelength-dependent IOR). Though I think renderers typically only account for the effect of this on the refracted lobe (producing color fringing in glass etc.), technically it should also alter the Fresnel factor of the reflection differently in each channel producing colors in the reflection lobe.

If we introduce this ad-hoc parametrization interpolating between two arbitrary colors, it's then unclear how this should interplay with the dispersion effect (maybe multiply the two Fresnel factors?).

I wonder what are the real uses cases for this tinting. In the spec we say "this can be useful in practice for example, to simulate green or purple anti-reflective coatings on lenses". Presumably those coatings are actually colored due to absorption (and do produce a white highlight as well, just suppressed due to the index matching). So we are effectively faking the presence of a thin absorbing layer, and a similar effect could be achieved with the coat layer itself.

portsmouth commented 1 year ago

On reflection... actually I'm not too bothered about violating the fact that the dielectric Fresnel factor is supposed to 100% reflecting at grazing angles (i.e. specular_color strictly should be always 1 for dielectrics).

The origin of that is at a lower level than relevant to computer graphics, i.e. Maxwell's equations, but I don't think anything important breaks at the level of CG if we relax that requirement, and probably it can be a useful (albeit unrealistic) extra degree of freedom for artistic purposes.

We could add separate tints for the dielectric Fresnel factor at normal and grazing incidence (called say specular_tint replacing specular_color, and a new specular_edge_tint as discussed in #78).

Though I worry that this could be quite confusing for artists, and we should at least try to make it clear that setting the specular_tint/specular_edge_tint of dielectrics to anything non-white is unusual / non-typical / advanced.

(There is the separate question of how the energy balance should work in the case of non-white specular_color, as discussed in #81, i.e. should there be a complementary color).

portsmouth commented 1 year ago

but I don't think anything important breaks at the level of CG if we relax that requirement

Actually, not really.. If we just remap the Fresnel factor of our dielectric/conductor BSDF arbitrarily, some things become physically ill-defined since the Fresnel factor is no longer consistent with the IOR.

So e.g.:

portsmouth commented 8 months ago

Inclined to close this, as changing the Fresnel behaviour is not happening in the near term.