---
title: Linearly Transformed Cosines for Area-Light Shading
url: https://www.emergentmind.com/topics/linearly-transformed-cosines-ltc
type: topic
---

# Linearly Transformed Cosines for Area-Light Shading

Linearly Transformed Cosines (LTCs) are a family of distributions designed for real-time area-light shading, notable for their analytic integration properties that allow efficient approximation of complex Bidirectional Reflectance Distribution Functions (BRDFs) such as GGX. LTCs enable the real-time rendering of specular highlights from area lights, a critical requirement for visually plausible graphics in modern rendering engines. The method has seen widespread adoption for isotropic GGX but, until recently, lacked a robust extension to anisotropic GGX—fundamental for simulating surfaces with directionally dependent roughness, such as brushed metals and anisotropic plastics [2203.11904].

## 1. Mathematical Definition of Linearly Transformed Cosines

The foundational element of LTCs is the clamped cosine lobe:
\[
D_{0}(n) = \frac{\max(n \cdot n_{0}, 0)}{\pi}, \quad n_{0} = (0,0,1)
\]
Given any invertible \(3\times3\) linear transformation \(T\), the linearly transformed cosine (LTC) distribution is defined as:
\[
D_{T}(n) = \det(T)\, D_{0}(T n) = \det(T) \frac{\max((T n) \cdot n_{0}, 0)}{\pi}
\]
An equivalent, widely used form applies the inverse transform to the direction and normalization:
\[
D_{M}(n) = D_{0}\left(\frac{M^{-1} n}{\|M^{-1} n\|}\right) \frac{|\det M^{-1}|}{\|M^{-1} n\|^{3}}
\]
where \(M\) is another notation for \(T\). Both definitions are algebraically identical.

## 2. Analytic Integration for Area-Light Shading

One of the principal advantages of LTCs is their support for analytic integration over spherical polygons, such as the spherical projection of a rectangular light source. The area integral of an LTC:
\[
\int_{\mathcal A} D_{T}(n) \, dn = \int_{T \mathcal A} D_0(n_o) \, dn_o
\]
For polygonal lights with vertices \(p_1, ..., p_4\), the edge direction on the unit sphere is:
\[
v_i = \frac{p_i}{\|p_i\|}\,,\qquad i=1\dots 4
\]
A closed-form solution for the clamped cosine over the spherical quadrilateral is:
\[
\int_{\mathcal A_{o}} \frac{\max(n_{o} \cdot n_{0}, 0)}{\pi} d n_{o} = \frac{1}{\pi} \sum_{i=1}^{4} \phi_i
\]
with edge angle:
\[
\phi_i = \operatorname{atan2}\big((v_i \times v_{i+1}) \cdot n_0 ,\ 1 + v_i \cdot v_{i+1}\big),\quad v_5 \equiv v_1
\]
Thus, the full LTC integral over the original light is:
\[
\int_{\mathcal A} D_{T}(n) \, dn = \frac{1}{\pi} \sum_{i=1}^{4} \operatorname{atan2}\big((T p_i \times T p_{i+1}) \cdot n_0,\ 1 + (T p_i) \cdot (T p_{i+1})\big)
\]
These closed-form properties are central to achieving real-time performance in rendering [2203.11904].

## 3. GGX Microfacet Distribution and LTC Approximation

The GGX (or Trowbridge-Reitz) normal distribution function describes the density of microfacet orientations. For LTC fitting, the two forms of GGX considered are:

- Isotropic (\(\alpha\) roughness):
  \[
  D_{\mathrm{GGX,iso}}(n) = \frac{\alpha^2}{\pi [\alpha^2(n_x^2 + n_y^2) + n_z^2]^2}
  \]
- Anisotropic (\(\alpha_x, \alpha_y\) roughnesses):
  \[
  D_{\mathrm{GGX,aniso}}(n) = \frac{1}{\pi \alpha_x \alpha_y \left(\frac{n_x^2}{\alpha_x^2} + \frac{n_y^2}{\alpha_y^2} + n_z^2\right)^2}
  \]
For rendering, the full specular BRDF also involves a Fresnel term and masking-shadowing (\(G_2\)), but for LTC parameter fitting, \(F \equiv 1\) is adopted.

The goal is to match the LTC \(D_{T}(n)\) to the target GGX distribution by optimizing the matrix \(M\) (and its implicit scaling). The constraint \(\|M e_z\| = 1\) ensures correspondence between the transformed cosine normal and the canonical normal.

## 4. Fitting Pipeline for Anisotropic GGX

The LTC fitting task seeks \(M\) and a scaling such that \(D_{T}(n) \approx D_{\mathrm{GGX}}(n)\). Rather than pointwise \(L^2\) or \(L^3\) losses (which present optimization challenges), the Sliced-Wasserstein discrepancy is used:
\[
M^{*} = \arg\min_{M,\,\|M e_z\|=1} \ L_{\mathrm{SW}}\big(D_T, D_{\mathrm{GGX}}\big)
\]
where
\[
L_{\mathrm{SW}}(f,g) = \mathbb{E}_{\omega \sim S^1} \int_0^1 \big| F_{f,\omega}^{-1}(u) - F_{g,\omega}^{-1}(u) \big| \, du
\]
This is approximated stochastically by sampling projected directions \(\omega\) in the tangent plane, sampling from both distributions, and averaging the differences of sorted projections.

In practice, optimization is performed (e.g., in PyTorch) over the nine entries of \(M\), retuning \(\|M e_z\|=1\) after each update to enforce normalization.

## 5. Invariance Properties and Symmetry Exploitation

LTCs and the GGX model exhibit significant invariances:

- **Matrix Non-Uniqueness**: For any rotation \(R_z\) about the \(z\) axis and any flip \(F_{xy}\) in \(x\) or \(y\), \(D_{M}(n) = D_{M R_{z} F_{xy}}(n)\). Alignment of each \(M\) is achieved by seeking \(R_z, F_{xy}\) that minimize:
  \[
  \mathbb{E}_{\omega_o \sim D_0} \left\| \frac{M R_z F_{xy} \omega_o}{\|M R_z F_{xy} \omega_o\|} - \omega_o \right\|^2
  \]
- **GGX View-Azimuth Symmetry**: Anisotropic GGX possesses symmetry under \(\phi \rightarrow \pi/2 - \phi\) with an \((x, y)\) swap, allowing fitting in \(\phi \in [0,\pi/2]\) and quadrant extension via sign-flip matrices.
- **Roughness Ratio Symmetry**: Only \(\{\alpha = \max(\alpha_x, \alpha_y), \lambda = \min(\alpha_y, \alpha_x)/\max(\alpha_y, \alpha_x)\}\) need sampling.
- **Boundary Symmetries**: For \(\phi=0\) or \(\pi/2\), specific off-diagonal entries in \(M\) vanish; at \(\theta=0\), the upper \(2\times2\) block is isotropic. These properties allow systematic zeroing of matrix entries in post-processing.

## 6. Post-Processing, Storage, and Real-Time Use

After fitting and matrix alignment, the results undergo:

- Enforced boundary zeros (e.g., at \(\phi=0\) set \(M_{01}=M_{12}=M_{21}=M_{10}=0\)).
- Renormalization (\(M \leftarrow M / \|Me_z\|\)).
- Discretization of the complete 4D parameter space (\(\theta, \phi, \alpha, \lambda\)) into \(8\) bins per dimension, resulting in an \(8^4\) look-up table.
- Storage in three 3D GPU textures of size \(64 \times 8 \times 8\), packing \(\theta\) and the remaining parameters, with additional channels for pre-integrated Fresnel factors.

The run-time workflow given \((\theta,\phi,\alpha_x,\alpha_y)\) comprises: folding \(\phi\), roughness parameter remapping, 3D texture sampling with trilinear interpolation, quadrant correction, and matrix inversion. The total real-time cost is approximately 0.61 ms per frame at 1080p on an RTX 2080, compared to 0.16 ms for the isotropic variant [2203.11904].

## 7. Rendering Accuracy and Visual Results

Quantitative measurements indicate that the mean absolute per-pixel deviation between LTC-shaded rectangular lights and Monte-Carlo ground truth remains within 1–2% across diverse views and anisotropy levels. The rendered images are free from noise and display plausible specular highlights for anisotropic materials. Noticeable errors occur only for extreme viewing angles or highly anisotropic settings, where GGX lobes might form sharp “lunes” that cannot be captured by affine-transformed cosine lobes. The implemented solution achieves visually robust and artifact-free rendering for real-time anisotropic GGX area-light shading in modern graphics engines.

---

For a foundational account and full methodological details, see "Bringing Linearly Transformed Cosines to Anisotropic GGX" [2203.11904].

Source: https://www.emergentmind.com/topics/linearly-transformed-cosines-ltc