Constant-time energy-normalization for the Phong specular BRDFs

Abstract

The Phong and Modified Phong specular BRDFs, although of limited physical basis, are nevertheless some of the simplest BRDFs exhibiting glossy and specular qualities to understand and to implement, making them useful for validation and teaching. Unfortunately, although it is well-known how to make these BRDFs conserve energy (that is, never gain energy), making them energy-normalized (that is, never lose nor gain energy) is far more difficult. Lesser-known algorithms exist, but require the specular exponent n to be integer-valued, and have O(n) runtime cost. We express these algorithms as mathematical formulae and generalize to the real-valued specular exponent case. We then simplify and optimize to finally attain an algorithm that is O(1). Energy normalization makes the Phong BRDFs more physically plausible and therefore both more practically and theoretically useful—and our improvements allow for this energy normalization to be done efficiently and without arbitrary limitations.

This is a preview of subscription content, access via your institution.

Fig. 1
Fig. 2
Fig. 3
Fig. 4
Fig. 5

Notes

  1. 1.

    As in other multi-layer composite-BRDF models, one would typically weight the specular term by the Fresnel reflection and the diffuse term by the Fresnel transmission.

  2. 2.

    The double-factorial function \(n!!=n(n-2)(n-4)\cdots (1)\) must not be confused with the factorial function \(n!=n(n-1)(n-2)\cdots (1)\) applied twice.

  3. 3.

    The gamma function \(\Gamma {\left( \cdots \right) }\) generalizes the factorial function from the non-negative integers to most complex numbers. For any positive integer n, we have \(\Gamma {\left( n\right) }=(n-1)!\), but in particular \(\Gamma {\left( \cdots \right) }\) also works for floating-point values.

  4. 4.

    Profiling small sections of code is theoretically problematic (e.g. pipelining, caching, context-switching and reordering issues), but we report on our best effort on an Intel i7-6850K.

References

  1. 1.

    Arvo, J.: Applications of irradiance tensors to the simulation of non-lambertian phenomena. In: Proceedings of the 22nd Annual Conference on Computer Graphics and Interactive Techniques, SIGGRAPH ’95, pp. 335–342. ACM, New York, NY, USA (1995). http://doi.acm.org/10.1145/218380.218467

  2. 2.

    Beckmann, P., Spizzichino, A.: The scattering of electromagnetic waves from rough surfaces. Norwood, MA, Artech House, Inc., 1987, 511 p. (1987)

  3. 3.

    Boost: Boost C++ Libraries. http://www.boost.org/ (1999)

  4. 4.

    Dutré, P.: Global illumination compendium. Tech. rep., Katholieke Universiteit Leuven (2003). https://people.cs.kuleuven.be/~philip.dutre/GI/

  5. 5.

    Heitz, E., Hanika, J., d’Eon, E., Dachsbacher, C.: Multiple-scattering microfacet bsdfs with the smith model. ACM Trans Graph 35(4), 1–14 (2016)

    Google Scholar 

  6. 6.

    Kajiya, J.T.: The rendering equation. In: Proceedings of the 13th Annual Conference on Computer Graphics and Interactive Techniques, SIGGRAPH ’86, pp. 143–150. ACM, New York, NY, USA (1986). http://doi.acm.org/10.1145/15922.15902

  7. 7.

    Kulla, C., Conty, A.: Revisiting physically based shading at imageworks. SIGGRAPH Course, Physically Based Shading (2017)

  8. 8.

    Lecocq, P., Dufay, A., Sourimant, G., Marvie, J.E.: Analytic approximations for real-time area light shading. IEEE Trans Visual Comput Graph 23(5), 1428–1441 (2017)

    Article  Google Scholar 

  9. 9.

    Lee, J.H., Jarabo, A., Jeon, D.S., Gutierrez, D., Kim, M.H.: Practical multiple scattering for rough surfaces. ACM TOG 37(6), 1–12 (2018)

    Google Scholar 

  10. 10.

    Lewis, R.R.: Making shaders more physically plausible. Computer Graph Forum 13(2), 109–120 (1994). https://doi.org/10.1111/1467-8659.1320109

    Article  Google Scholar 

  11. 11.

    Meta.Numerics: Meta.numerics. http://www.meta-numerics.net/ (2009)

  12. 12.

    Nicodemus, F.E.: Directional reflectance and emissivity of an opaque surface. Appl Opt 4(7), 767–775 (1965)

    Article  Google Scholar 

  13. 13.

    Parker, S.G., Bigler, J., Dietrich, A., Friedrich, H., Hoberock, J., Luebke, D., McAllister, D., McGuire, M., Morley, K., Robison, A., Stich, M.: Optix: A general purpose ray tracing engine. In: ACM SIGGRAPH 2010 Papers, SIGGRAPH ’10, pp. 66:1–66:13. ACM, New York, NY, USA (2010). http://doi.acm.org/10.1145/1833349.1778803

  14. 14.

    Phong, B.T.: Illumination for computer generated pictures. Commun. ACM 18(6), 311–317. https://doi.org/10.1145/360825.360839

  15. 15.

    Torrance, K.E., Sparrow, E.M.: Theory for off-specular reflection from roughened surfaces. Josa 57(9), 1105–1114 (1967)

    Article  Google Scholar 

  16. 16.

    Turquin, E.: Practical multiple scattering compensation for microfacet models. ILM (2019)

Download references

Author information

Affiliations

Authors

Corresponding author

Correspondence to Ian Mallett.

Ethics declarations

Conflict of interest

The authors declare that they have no conflict of interest.

Additional information

Publisher's Note

Springer Nature remains neutral with regard to jurisdictional claims in published maps and institutional affiliations.

Appendices

A: Derivation of energy normalization criterion

The following informal proof demonstrates the well-known BRDF normalization criterion. We start with 1:

$$\begin{aligned} 1&{=} \frac{L_o}{L_o} {=} \frac{1}{L_o} \int _{S^2} d L_o {=} \int _{S^2} \frac{d L_o}{L_o ~ (\varvec{N}\bullet \varvec{\upomega }_o) ~ d \varvec{\upomega }_o} ~ (\varvec{N}\bullet \varvec{\upomega }_o) ~ d \varvec{\upomega }_o \end{aligned}$$

Then, since the incoming irradiance \(E_e = d \Phi _i/d A\) must match the outgoing radiant exitance \(M_e = d \Phi _o/d A\):

$$\begin{aligned} 1&= \int _{S^2} \frac{d L_o}{d M_e} ~ (\varvec{N}\bullet \varvec{\upomega }_o) ~ d \varvec{\upomega }_o = \int _{S^2} \frac{d L_o}{d E_e} ~ (\varvec{N}\bullet \varvec{\upomega }_o) ~ d \varvec{\upomega }_o =\\&= \int _{S^2} f_s(\varvec{\upomega }_i\rightarrow \varvec{x}\rightarrow \varvec{\upomega }_o) ~ (\varvec{N}\bullet \varvec{\upomega }_o) ~ d \varvec{\upomega }_o \end{aligned}$$

B: Derivation of energy conservation

Unlike energy normalization, which is the subject of this paper, the derivation of energy conservation terms for the Phong BRDFs is widely known.

Consider the Modified Phong specular component BRDF. In Eq. 5, first assume that \({\varvec{\upomega }_i = \varvec{N}}\):

$$\begin{aligned} I_M&= \int _\Omega \text {max}\left( 0, \varvec{R}(\varvec{\upomega }_o) \bullet {\varvec{N}} \right) ^n \left( \varvec{N}\bullet \varvec{\upomega }_o\right) ~ d \varvec{\upomega }_o \end{aligned}$$

Then, since the dot product of the reflected vector must be nonnegative and the same as that of the original vector:

$$\begin{aligned} I_M&= \int _\Omega {\left( \varvec{\upomega }_o\right. } \bullet {\varvec{N}} {\left. \right) }^n \left( \varvec{N}\bullet \varvec{\upomega }_o\right) ~ d \varvec{\upomega }_o\\&= \int _\Omega \left( \varvec{N}\bullet \varvec{\upomega }_o\right) ^{n+1} d \varvec{\upomega }_o\\&= \int _0^{2\pi } \int _0^{\pi /2} \text {cos}^{n+1}(\phi ) ~ \text {sin}(\phi ) ~ d\phi ~ d\theta \\&= \int _0^{2\pi } \frac{1}{n+2} ~ d\theta \\&= \frac{2\pi }{n+2} \end{aligned}$$

The computation of \(I_P\) with Eq. 4 is analogous.

C: Example code

Although the normalization terms given by Eqs. 7 and 8 may look intimidating, we provide a listing of the key source code, with simple optimizations applied, to demonstrate that our approach can be implemented in only a few lines:

figuref

The incomplete beta function is the only omission from the above, since it is not provided by most implementations of the C/C++ standard library. However, there is no shortage of available implementations to choose from. For example, the function from Boost [3] will be available to many users; the additional implementation would look like:

figureh

In our experiments, we chose to adapt the implementation of [11], because it seems to be based on a newer method. Such choices also in principle affect the epsilon at which the incomplete beta term must be replaced with its limit. However, empirically, our implementation was stable down to \(n \approx 5 \times 10^{-37}\), so a very small epsilon, as-above, is still adequately conservative.

Rights and permissions

Reprints and Permissions

About this article

Verify currency and authenticity via CrossMark

Cite this article

Mallett, I., Yuksel, C. Constant-time energy-normalization for the Phong specular BRDFs. Vis Comput 36, 2029–2038 (2020). https://doi.org/10.1007/s00371-020-01954-x

Download citation

Keywords

  • Phong
  • BRDF
  • Phong BRDF
  • Modified Phong BRDF
  • Energy conservation
  • Energy normalization
  • Physically based rendering