Algorithm Search⌘K

Modelintro

Blinn-Phong reflection model

Also called Blinn-Phong model, modified Phong model.

An empirical reflection model that adds ambient, diffuse and a specular lobe built on the half vector between the light and view directions.

The Blinn-Phong reflection model shades a point as the sum of an ambient term, a Lambertian diffuse term and a specular highlight. For a light in the direction ll, a view direction vv and the unit normal nn, all pointing away from the surface, the highlight uses the half vector h=(l+v)/∥l+v∥h = (l + v) / \lVert l + v \rVert:

I=ka+E(kdmax⁡(0,n⋅l)+ksmax⁡(0,n⋅h)s),I = k_a + E \big(k_d \max(0, n \cdot l) + k_s \max(0, n \cdot h)^s\big),

where EE is the light intensity and ss the shininess exponent. Bui Tuong Phong (1975) used the power of r⋅vr \cdot v, the cosine between the mirror direction rr of ll and the view. James Blinn (1977) replaced it by the power of n⋅hn \cdot h, which is cheaper when ll and vv are constant over a surface and which has a better shape at grazing angles. It was the fixed-function lighting model of OpenGL and Direct3D and is still common where cost matters. The model is a heuristic: its terms were chosen to look plausible, not derived from optics. A normalized form fits into the microfacet framework, where it is close to the Beckmann distribution.

The machine

Inputs. Unit vectors nn, ll and vv; the ambient, diffuse and specular coefficients kak_a, kdk_d and ksk_s in linear RGB; the exponent s≥0s \ge 0; the intensity EE of each light. For several lights the light terms are summed.

The classic form. The equation above. The specular term is set to zero when n⋅l≤0n \cdot l \le 0, so a light behind the surface does not cause a highlight. The ambient term kak_a is a constant that stands in for all indirect light. No term has a unit; the coefficients are tuned by eye.

The half vector. hh is the normal that a mirror facet must have to reflect ll into vv. The highlight is brightest when h=nh = n, which is exactly when vv is the mirror direction of ll. This is the link to microfacet theory: (n⋅h)s(n \cdot h)^s measures how many facets are oriented to reflect ll into vv.

The normalized BRDF. To use the model with physically based lights, replace the coefficients by reflectances and divide by solid angle:

f(l,v)=kdπ+kss+88π(n⋅h)s.f(l, v) = \frac{k_d}{\pi} + k_s \frac{s + 8}{8 \pi} (n \cdot h)^s.

The factor (s+8)/(8π)(s + 8) / (8\pi) is a common choice that keeps the specular albedo near ksk_s for all ss; it is a convenient approximation, not an exact normalization (see below). The units of ff are 1/sr.

The distribution form. As a microfacet DD, the normalized lobe is D(h)=s+22π(n⋅h)sD(h) = \frac{s + 2}{2\pi} (n \cdot h)^s, and this one is exact: ∫D(n⋅h) dωh=1\int D (n \cdot h)\, d\omega_h = 1 for every s≥0s \ge 0. It goes into f=DFG/(4(n⋅l)(n⋅v))f = D F G / (4 (n \cdot l)(n \cdot v)) like GGX.

What it counts

The classic form counts nothing physical. It gives a brightness in [0,ka+E(kd+ks)][0, k_a + E(k_d + k_s)], which the display code clamps. The normalized BRDF is a ratio of reflected radiance to incoming irradiance, and its directional albedo ∫f (n⋅l) dωl\int f\, (n \cdot l)\, d\omega_l is the fraction of light that it reflects.

Example. The specular albedo of s+88π(n⋅h)s\frac{s + 8}{8\pi} (n \cdot h)^s, computed by the code of this page:

ss 1 4 16 64 256
View at 0° 1.0243 1.0625 1.0669 1.0267 1.0075
View at 60° 0.8388 0.5938 0.3702 0.2811 0.2578

At normal view the albedo has the closed form (s+8)(2(1−c0s+4)/(s+4)−(1−c0s+2)/(s+2))(s + 8)\big(2 (1 - c_0^{s + 4}) / (s + 4) - (1 - c_0^{s + 2}) / (s + 2)\big) with c0=1/2c_0 = 1 / \sqrt 2. It is 1 at s=0s = 0, tends to 1 as s→∞s \to \infty, and peaks at 1.07521.0752 near s=8.76s = 8.76. So the factor reflects up to 7.5 percent more light than it receives at normal view. At 60° the albedo falls well below 1, because the lobe of (n⋅h)s(n \cdot h)^s is cut off by the horizon and there is no Fresnel or masking term. Both effects are small next to the errors of the classic model, but they show that the factor is a heuristic.

Example of the shape. For vv at 75° from the normal, s=40s = 40, and a light 0.2 radians from the mirror direction: in the plane of incidence, the lobe is 0.8180.818; across that plane, at the same angular distance, it is 0.0620.062. The Phong lobe (r⋅v)10(r \cdot v)^{10} gives 0.8180.818 in both directions, because it is round around rr. The Blinn highlight on a flat floor at a grazing view is therefore stretched toward the viewer, much like the long reflections of street lights on a wet road. The code of this page tests these values.

Relation to other models

  • Phong. max⁡(0,r⋅v)p\max(0, r \cdot v)^p with r=2(n⋅l)n−lr = 2 (n \cdot l) n - l. At normal view, r⋅v=cos⁡2θhr \cdot v = \cos 2\theta_h and n⋅h=cos⁡θhn \cdot h = \cos\theta_h, and cos⁡p2θ≈e−2pθ2\cos^p 2\theta \approx e^{-2 p \theta^2}, cos⁡4pθ≈e−2pθ2\cos^{4p}\theta \approx e^{-2 p \theta^2} for small θ\theta, so s≈4ps \approx 4p gives about the same highlight. This rule holds only near normal view and near the peak. The Phong reflection model is a different thing from Phong shading, which interpolates normals across a triangle; both can be used together or apart, and Gouraud shading interpolates the result instead.
  • Lambert. The diffuse term kdmax⁡(0,n⋅l)k_d \max(0, n \cdot l) is Lambert's cosine law, and kd/πk_d / \pi is the Lambertian BRDF.
  • Microfacet models. The normalized D=s+22π(n⋅h)sD = \frac{s + 2}{2\pi} (n \cdot h)^s is a valid microfacet distribution. Near its peak it is close to Beckmann with s≈2/α2−2s \approx 2 / \alpha^2 - 2, a common fit. GGX has a much longer tail than both.
  • Physically based shading. Physically based shading replaced the classic model in most engines after about 2010, with GGX for DD, a Smith GG and Schlick's FF. Some engines keep Blinn-Phong as a cheap DD.
  • Stylized shading. Gooch shading and toon shading replace the diffuse term and often keep a Blinn-Phong highlight.

Known results in the model

  • Reciprocity (proved). hh is symmetric in ll and vv, so the normalized BRDF is symmetric. The Phong lobe is also symmetric, because r(l)⋅v=2(n⋅l)(n⋅v)−l⋅v=r(v)⋅lr(l) \cdot v = 2 (n \cdot l)(n \cdot v) - l \cdot v = r(v) \cdot l.
  • Normalization of DD (proved). ∫H2s+22π(n⋅h)s+1 dωh=(s+2)∫01μs+1 dμ=1\int_{H^2} \frac{s + 2}{2\pi} (n \cdot h)^{s + 1}\, d\omega_h = (s + 2) \int_0^1 \mu^{s + 1}\, d\mu = 1.
  • Albedo of the (s+8)/(8π)(s + 8) / (8\pi) factor (proved at normal view, measured elsewhere). The closed form above, with a largest value of 1.07521.0752; at other angles the values in the table are quadrature results.
  • No energy conservation of the classic form (proved). For kd+ks>1k_d + k_s > 1 the classic form can return more light than it receives; nothing in the model prevents it.
  • Lobe shape (measured). The highlight is round at normal view and stretched in the plane of incidence at grazing views, while Phong's stays round.
  • Fit to real materials (measurement). How well the model fits a material is a measurement for that material. With a Fresnel and a masking term in the microfacet form, it behaves like Beckmann.
Proof: Properties of the Blinn-Phong modelfull

Setting. For unit vectors nn, ll and vv with n⋅l>0n \cdot l > 0 and n⋅v>0n \cdot v > 0, the code computes h=(l+v)/∥l+v∥h = (l + v) / \lVert l + v \rVert, the lobe max⁡(0,n⋅h)s\max(0, n \cdot h)^s, the normalized BRDF f=kd/π+kss+88π(n⋅h)sf = k_d / \pi + k_s \frac{s + 8}{8\pi} (n \cdot h)^s, the distribution D=s+22π(n⋅h)sD = \frac{s + 2}{2\pi} (n \cdot h)^s and the Phong lobe max⁡(0,r⋅v)p\max(0, r \cdot v)^p with r=2(n⋅l)n−lr = 2 (n \cdot l) n - l. The claims are about these formulas in exact arithmetic. That the model looks plausible is a heuristic and is not claimed.

Claim 1 (the half vector). h⋅l=h⋅vh \cdot l = h \cdot v, and n⋅h=1n \cdot h = 1 exactly when v=rv = r.

Proof. h⋅l=(1+l⋅v)/∥l+v∥=h⋅vh \cdot l = (1 + l \cdot v) / \lVert l + v \rVert = h \cdot v. If v=rv = r, then l+v=2(n⋅l)nl + v = 2 (n \cdot l) n, a positive multiple of nn, so h=nh = n. Conversely, if h=nh = n, then l+v=c nl + v = c\, n for some c>0c > 0, and c=2(n⋅l)c = 2 (n \cdot l) because n⋅v=c−n⋅ln \cdot v = c - n \cdot l and h⋅l=h⋅vh \cdot l = h \cdot v give n⋅l=n⋅vn \cdot l = n \cdot v; so v=2(n⋅l)n−l=rv = 2 (n \cdot l) n - l = r. □\square

Claim 2 (reciprocity). f(l,v)=f(v,l)f(l, v) = f(v, l) and r(l)⋅v=r(v)⋅lr(l) \cdot v = r(v) \cdot l.

Proof. hh is symmetric in ll and vv, and so is ff. r(l)⋅v=2(n⋅l)(n⋅v)−l⋅vr(l) \cdot v = 2 (n \cdot l)(n \cdot v) - l \cdot v, which is symmetric. □\square

Claim 3 (normalization of DD). ∫H2D(h) (n⋅h) dωh=1\int_{H^2} D(h)\, (n \cdot h)\, d\omega_h = 1 for every s≥0s \ge 0.

Proof. With μ=n⋅h\mu = n \cdot h and dωh=dμ dϕd\omega_h = d\mu\, d\phi after the change of variables, the integral is 2π⋅s+22π∫01μs+1 dμ=12\pi \cdot \frac{s + 2}{2\pi} \int_0^1 \mu^{s + 1}\, d\mu = 1. □\square

Claim 4 (the albedo at normal view). For v=nv = n, the specular albedo A(s)=∫k (n⋅h)s(n⋅l) dωlA(s) = \int k\, (n \cdot h)^s (n \cdot l)\, d\omega_l with k=(s+8)/(8π)k = (s + 8) / (8\pi) equals (s+8)(2(1−c0s+4)/(s+4)−(1−c0s+2)/(s+2))(s + 8)\big(2 (1 - c_0^{s + 4}) / (s + 4) - (1 - c_0^{s + 2}) / (s + 2)\big) with c0=1/2c_0 = 1 / \sqrt 2. It is 1 at s=0s = 0 and tends to 1 as s→∞s \to \infty.

Proof. Change variables from ll to hh: l=2(v⋅h)h−vl = 2 (v \cdot h) h - v and dωl=4(v⋅h) dωhd\omega_l = 4 (v \cdot h)\, d\omega_h. With v=nv = n and θh\theta_h the angle of hh, v⋅h=cos⁡θh=cv \cdot h = \cos\theta_h = c and n⋅l=2c2−1n \cdot l = 2c^2 - 1, which is positive for c>c0c > c_0. So A=2πk∫c01cs(2c2−1) 4c dc=(s+8)∫c01(2cs+3−cs+1) dcA = 2\pi k \int_{c_0}^1 c^s (2c^2 - 1)\, 4c\, dc = (s + 8) \int_{c_0}^1 (2 c^{s + 3} - c^{s + 1})\, dc, which is the closed form. At s=0s = 0 it is 8(2⋅34/4−12/2)=18 (2 \cdot \frac34 / 4 - \frac12 / 2) = 1. As s→∞s \to \infty, the powers of c0c_0 vanish and A→lim⁡(s+8) s/((s+4)(s+2))=1A \to \lim (s + 8)\, s / ((s + 4)(s + 2)) = 1. □\square

The largest value, 1.07521.0752 near s=8.76s = 8.76, is found on a grid by the tests. The albedo at other view angles is computed by quadrature in hh and checked against the closed form at v=nv = n.

Claim 5 (the Phong match at normal view). For v=nv = n, r⋅v=cos⁡2θhr \cdot v = \cos 2\theta_h, and log⁡cos⁡p2θ−log⁡cos⁡4pθ=O(pθ4)\log \cos^p 2\theta - \log \cos^{4p} \theta = O(p \theta^4) as θ→0\theta \to 0.

Proof. For v=nv = n, r⋅v=n⋅l=2cos⁡2θh−1=cos⁡2θhr \cdot v = n \cdot l = 2 \cos^2\theta_h - 1 = \cos 2\theta_h. With log⁡cos⁡x=−x2/2−x4/12+O(x6)\log \cos x = -x^2 / 2 - x^4 / 12 + O(x^6), plog⁡cos⁡2θ=−2pθ2−43pθ4+O(pθ6)p \log\cos 2\theta = -2 p \theta^2 - \frac{4}{3} p \theta^4 + O(p \theta^6) and 4plog⁡cos⁡θ=−2pθ2−13pθ4+O(pθ6)4 p \log\cos\theta = -2 p \theta^2 - \frac13 p \theta^4 + O(p \theta^6). The θ2\theta^2 terms are equal. □\square

What the tests check. Claim 1 and Claim 2 at random directions, Claim 3 by the midpoint rule for ss up to 1000, Claim 4 against quadrature, Claim 5 at small angles, the lobe shape at 75°, and the classic form at a mirror configuration.

Code

Each implementation follows the pseudocode above. A comment @line links a line of code to a line of the pseudocode. Point at a line of the pseudocode to see the matching code. The build runs the native tests of each language.

blinn_phong_reflection_model.pyI0RawGitHub
# SPDX-License-Identifier: MIT
# Part of https://algorithm.tamnd.com/blinn-phong-reflection-model/. The authors are listed in prov/3J4E53.jsonl.

"""The Blinn-Phong reflection model, its classic shading form, its
normalized BRDF form, and the Phong lobe it replaces.

All vectors point away from the surface. n, l and v are unit vectors.
Colors are single linear channels here.
"""

import math

Vec = tuple[float, float, float]


def dot(a: Vec, b: Vec) -> float:
    return a[0] * b[0] + a[1] * b[1] + a[2] * b[2]


def normalize(a: Vec) -> Vec:
    r = math.sqrt(dot(a, a))
    return (a[0] / r, a[1] / r, a[2] / r)


def half_vector(l: Vec, v: Vec) -> Vec:
    """h = (l + v) / |l + v|; undefined when l = -v."""
    return normalize((l[0] + v[0], l[1] + v[1], l[2] + v[2]))


def reflect(l: Vec, n: Vec) -> Vec:
    """The mirror direction r = 2 (n.l) n - l."""
    c = 2.0 * dot(n, l)
    return (c * n[0] - l[0], c * n[1] - l[1], c * n[2] - l[2])


def phong_lobe(n: Vec, l: Vec, v: Vec, p: float) -> float:
    """The Phong specular factor max(0, r.v)^p."""
    return max(0.0, dot(reflect(l, n), v)) ** p


def blinn_lobe(n: Vec, l: Vec, v: Vec, s: float) -> float:
    """The Blinn specular factor max(0, n.h)^s."""
    return max(0.0, dot(n, half_vector(l, v))) ** s


def shade_classic(n: Vec, l: Vec, v: Vec, ka: float, kd: float, ks: float, s: float, light: float = 1.0) -> float:
    """The classic intensity ka + light (kd max(0, n.l) + ks max(0, n.h)^s).

    The specular term is set to zero when the light is behind the surface.
    """
    nl = dot(n, l)
    if nl <= 0.0:
        return ka
    return ka + light * (kd * nl + ks * blinn_lobe(n, l, v, s))


def blinn_phong_d(cos_h: float, s: float) -> float:
    """The normalized distribution (s + 2) / (2 pi) (n.h)^s, a valid microfacet D."""
    if cos_h <= 0.0:
        return 0.0
    return (s + 2.0) / (2.0 * math.pi) * cos_h ** s


def blinn_phong_brdf(n: Vec, l: Vec, v: Vec, kd: float, ks: float, s: float) -> float:
    """The normalized BRDF kd / pi + ks (s + 8) / (8 pi) (n.h)^s, in 1/sr."""
    if dot(n, l) <= 0.0 or dot(n, v) <= 0.0:
        return 0.0
    return kd / math.pi + ks * (s + 8.0) / (8.0 * math.pi) * blinn_lobe(n, l, v, s)


def specular_albedo(theta_v: float, s: float, nt: int = 400, npf: int = 96) -> float:
    """The directional albedo of the specular term (s + 8) / (8 pi) (n.h)^s.

    It integrates f (n.l) over the hemisphere of l by a change of variables to
    the half vector, d omega_l = 4 (v.h) d omega_h, with the midpoint rule in
    theta_h and phi_h. The frame has n = z and v in the xz plane.
    """
    n = (0.0, 0.0, 1.0)
    v = (math.sin(theta_v), 0.0, math.cos(theta_v))
    k = (s + 8.0) / (8.0 * math.pi)
    tmax = math.pi / 2.0
    total = 0.0
    dt = tmax / nt
    dp = 2.0 * math.pi / npf
    for i in range(nt):
        t = (i + 0.5) * dt
        st, ct = math.sin(t), math.cos(t)
        lobe = k * ct ** s
        if lobe == 0.0:
            continue
        ring = 0.0
        for j in range(npf):
            p = (j + 0.5) * dp
            h = (st * math.cos(p), st * math.sin(p), ct)
            vh = dot(v, h)
            if vh <= 0.0:
                continue
            l = (2.0 * vh * h[0] - v[0], 2.0 * vh * h[1] - v[1], 2.0 * vh * h[2] - v[2])
            nl = dot(n, l)
            if nl <= 0.0:
                continue
            ring += nl * 4.0 * vh
        total += lobe * ring * st
    return total * dt * dp


def specular_albedo_normal(s: float) -> float:
    """The exact albedo of the specular term at v = n.

    There l is the mirror of v about h, so n.l = cos(2 theta_h), v.h = cos(theta_h),
    and the integral over cos(theta_h) from 1/sqrt(2) to 1 has a closed form.
    """
    c0 = 1.0 / math.sqrt(2.0)
    return (s + 8.0) * (2.0 * (1.0 - c0 ** (s + 4.0)) / (s + 4.0) - (1.0 - c0 ** (s + 2.0)) / (s + 2.0))


def phong_to_blinn_exponent(p: float) -> float:
    """s = 4 p makes the two lobes match near the mirror direction at normal view."""
    return 4.0 * p
test_blinn_phong_reflection_model.py 124 lines
# SPDX-License-Identifier: MIT
# Part of https://algorithm.tamnd.com/blinn-phong-reflection-model/. The authors are listed in prov/3J4E53.jsonl.

"""Tests of the Blinn-Phong model: normalization, albedo, reciprocity and the Phong match."""

import math
import random

from blinn_phong_reflection_model import (
    blinn_lobe,
    blinn_phong_brdf,
    blinn_phong_d,
    dot,
    half_vector,
    normalize,
    phong_lobe,
    phong_to_blinn_exponent,
    reflect,
    shade_classic,
    specular_albedo,
    specular_albedo_normal,
)

N = (0.0, 0.0, 1.0)


def random_up(rng: random.Random) -> tuple[float, float, float]:
    """A random unit vector in the upper hemisphere, by rejection."""
    while True:
        x, y, z = rng.uniform(-1, 1), rng.uniform(-1, 1), rng.uniform(0, 1)
        r2 = x * x + y * y + z * z
        if 1e-6 < r2 <= 1.0 and z > 1e-3:
            return normalize((x, y, z))


def test_half_vector_and_mirror() -> None:
    rng = random.Random(1)
    for _ in range(500):
        l, v = random_up(rng), random_up(rng)
        h = half_vector(l, v)
        assert abs(dot(h, l) - dot(h, v)) < 1e-12
        # When v is the mirror of l, h is n and both lobes peak.
        r = reflect(l, N)
        assert abs(dot(half_vector(l, r), N) - 1.0) < 1e-12
        assert abs(blinn_lobe(N, l, r, 50.0) - 1.0) < 1e-9
        assert abs(phong_lobe(N, l, r, 50.0) - 1.0) < 1e-9


def test_d_is_normalized() -> None:
    # The integral of D (n.h) over the hemisphere is 1 for every s; midpoint rule in theta.
    for s in (0.0, 1.0, 10.0, 100.0, 1000.0):
        k = 20000
        dt = (math.pi / 2.0) / k
        total = 0.0
        for i in range(k):
            t = (i + 0.5) * dt
            total += blinn_phong_d(math.cos(t), s) * math.cos(t) * math.sin(t)
        assert abs(total * 2.0 * math.pi * dt - 1.0) < 1e-4


def test_reciprocity() -> None:
    rng = random.Random(2)
    for _ in range(1000):
        l, v = random_up(rng), random_up(rng)
        s = rng.uniform(1.0, 200.0)
        a = blinn_phong_brdf(N, l, v, 0.5, 0.5, s)
        b = blinn_phong_brdf(N, v, l, 0.5, 0.5, s)
        assert abs(a - b) <= 1e-12 * max(1.0, a)
        # The Phong lobe is also symmetric: r(l).v = r(v).l.
        assert abs(phong_lobe(N, l, v, 10.0) - phong_lobe(N, v, l, 10.0)) < 1e-12


def test_albedo_at_normal_incidence() -> None:
    expected = {1.0: 1.0243, 4.0: 1.0625, 16.0: 1.0669, 64.0: 1.0267, 256.0: 1.0075}
    for s, val in expected.items():
        assert abs(specular_albedo_normal(s) - val) < 5e-5
        assert abs(specular_albedo(0.0, s) - specular_albedo_normal(s)) < 5e-4
    # The largest value over s is 1.0752, near s = 8.76; it tends to 1 at both ends.
    best = max(specular_albedo_normal(i / 100.0) for i in range(1, 5001))
    assert abs(best - 1.0752) < 5e-5
    assert abs(specular_albedo_normal(1e-6) - 1.0) < 1e-4
    assert abs(specular_albedo_normal(1e6) - 1.0) < 1e-4


def test_albedo_at_sixty_degrees() -> None:
    expected = {1.0: 0.8388, 4.0: 0.5938, 16.0: 0.3702, 64.0: 0.2811, 256.0: 0.2578}
    for s, val in expected.items():
        assert abs(specular_albedo(math.radians(60.0), s) - val) < 5e-4


def test_phong_to_blinn_match() -> None:
    # At v = n, n.h = cos(t / 2) and r.v = cos t for the angle t between l and n.
    for p in (10.0, 50.0, 200.0):
        s = phong_to_blinn_exponent(p)
        for t in (0.02, 0.05, 0.1):
            l = (math.sin(t), 0.0, math.cos(t))
            ph = phong_lobe(N, l, N, p)
            bl = blinn_lobe(N, l, N, s)
            assert abs(math.log(bl) - math.log(ph)) < 0.02 * p * t * t + 1e-12
    # Away from normal view the Blinn lobe gets narrow across the plane of incidence.
    def sph(t: float, p: float) -> tuple[float, float, float]:
        return (math.sin(t) * math.cos(p), math.sin(t) * math.sin(p), math.cos(t))

    tv = math.radians(75.0)
    v = sph(tv, 0.0)
    d = 0.2
    in_plane = sph(tv - d, math.pi)
    dphi = 2.0 * math.asin(math.sin(d / 2.0) / math.sin(tv))
    across = sph(tv, math.pi + dphi)
    assert abs(math.acos(dot(across, reflect(v, N))) - d) < 1e-12
    assert abs(phong_lobe(N, in_plane, v, 10.0) - 0.818) < 5e-4
    assert abs(blinn_lobe(N, in_plane, v, 40.0) - 0.818) < 5e-4
    assert abs(phong_lobe(N, across, v, 10.0) - 0.818) < 5e-4
    assert abs(blinn_lobe(N, across, v, 40.0) - 0.062) < 5e-4


def test_classic_shading() -> None:
    l = normalize((1.0, 0.0, 1.0))
    v = normalize((-1.0, 0.0, 1.0))
    # Mirror configuration: n.l = 0.7071 and n.h = 1.
    val = shade_classic(N, l, v, 0.1, 0.6, 0.3, 32.0)
    assert abs(val - (0.1 + 0.6 * math.sqrt(0.5) + 0.3)) < 1e-12
    # Light behind the surface: only ambient.
    assert shade_classic(N, (0.0, 0.0, -1.0), v, 0.1, 0.6, 0.3, 32.0) == 0.1

References

  1. James F. Blinn, Models of light reflection for computer synthesized pictures, Computer Graphics (SIGGRAPH 77) 11(2), 1977, 192 to 198, the specular term with the half vector H and the exponent of N.H, and its comparison with the Phong term and the Torrance-Sparrow model (general locator)
  2. Bui Tuong Phong, Illumination for computer generated pictures, Communications of the ACM 18(6), 1975, 311 to 317, the reflection model with the power of the cosine between the reflected direction and the view direction (general locator)
  3. Tomas Akenine-Möller, Eric Haines, Naty Hoffman, Angelo Pesce, Michał Iwanicki and Sébastien Hillaire, Real-Time Rendering, fourth edition, CRC Press, 2018, Chapter 5, Shading Basics, and Chapter 9, Physically Based Shading (the Blinn-Phong distribution as a microfacet D) (general locator)
  4. Matt Pharr, Wenzel Jakob and Greg Humphreys, Physically Based Rendering, From Theory to Implementation, third edition, Morgan Kaufmann, 2016, Section 8.4, Microfacet Models (the microfacet framework into which a normalized Blinn-Phong D fits)

About this page

The build computes these levels from the evidence in the repository. Each row says what the next level needs. Read what the levels mean.

LadderLevelWhat the next level needs
Human proofH2 full proof
  • correctness: no review record reviews/3J4E53/proof-correctness.yaml
LeanL0 no Lean part
  • name a Lean module in the lean field (07)
Code (python)I0 not checked yet
  • the tests did not run in this build
VisualV0 none
  • add viz/scene.ts or a figure (10)
WritingW4 complete
  • a review of the text: no review record reviews/3J4E53/text.yaml