Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ability to tint specular highlights without affecting grazing angles #77

Open
lukasstockner opened this issue Aug 8, 2023 · 4 comments

Comments

@lukasstockner
Copy link

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
Copy link
Contributor

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
Copy link
Contributor

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
Copy link
Contributor

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.:

  • if the IOR is such that exiting rays undergo TIR, do we alter the Fresnel factor from 1? If not, there will be a discontinuity as rays which nearly undergo IOR will get the tinting.
  • how is this taken into account when computing dielectric multiple scattering -- i.e. ignore or apply the tinting to the multiple scattered lobe?

@portsmouth
Copy link
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants