Skip to content

Commit 87b8e15

Browse files
committed
Began adding additional information around spherical harmonics
1 parent 8974df1 commit 87b8e15

File tree

1 file changed

+72
-1
lines changed
  • extensions/2.0/Khronos/KHR_gaussian_splatting

1 file changed

+72
-1
lines changed

extensions/2.0/Khronos/KHR_gaussian_splatting/README.md

Lines changed: 72 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,71 @@ The `mode` of the `primitive` must be `POINTS`.
7070

7171
## Lighting
7272

73-
At the time of writing, the most common method for lighting 3D Gaussian splats is via spherical harmonics. This extension defines attributes to store spherical harmonic coefficients for each splat. The zeroth-order spherical harmonic coefficients are always required. Higher order coefficients are optional.
73+
At the time of writing, the most common method for lighting 3D Gaussian splats is via the real spherical harmonics. This extension defines attributes to store spherical harmonic coefficients for each splat. The zeroth-order spherical harmonic coefficients are always required. Higher order coefficients are optional. Each color channel has a separate coefficient, so for each degree $ℓ$, there are $(2ℓ + 1)$ coefficients, each containing RGB values.
7474

7575
These rules may be relaxed by future extensions that define alternative lighting methods or have specific requirements for handling compression, such as when a compression method stores the diffuse color components as linear color values instead of the zeroth-order coefficients.
7676

77+
### Calculating color from Spherical Harmonics
78+
79+
The diffuse color of the splat can be computed by multiplying the RGB coefficients of the zeroth-order spherical harmonic by the constant real spherical harmonic value of $0.282095$. This constant is derived from the formula for the real spherical harmonic of degree 0, order 0:
80+
81+
```math
82+
Y_{0,0}(θ, φ) = \frac{1}{2} \sqrt{\frac{1}{π}} ≈ 0.282095
83+
```
84+
85+
To keep the spherical harmonics within the [0, 1] range, the forward pass of the training process applies a _0.5_ bias to the DC component of the spherical harmonics. The rendering process must also apply this bias when reconstructing the color values from the spherical harmonics. This allows the training to occur around 0, ensuring numeric stability for the spherical harmonics, but also allows the coefficients to remain within a valid range for easy rendering.
86+
87+
Ergo, to calculate the diffuse RGB color from the DC component, the formula is:
88+
89+
```math
90+
Color_{diffuse} = SH_{0,0} * 0.282095 + 0.5
91+
```
92+
93+
Where $SH_{0,0}$ represents the RGB coefficients of the zeroth-order real spherical harmonic.
94+
95+
Subsequent degrees of spherical harmonics can be used to compute more complex lighting effects, such as ambient occlusion and specular highlights, by evaluating the spherical harmonics at the appropriate angles based on the surface normal and light direction. Functions for the higher order real spherical harmonics are defined as follows:
96+
97+
```math
98+
\begin{aligned}
99+
\text{ℓ = 1} \quad &
100+
\left\{
101+
\begin{aligned}
102+
Y_{1,-1}(θ, φ) &= \sqrt{\frac{3}{4π}} \cdot \frac{y}{r}\\
103+
Y_{1,0}(θ, φ) &= \sqrt{\frac{3}{4π}} \cdot \frac{z}{r}\\
104+
Y_{1,1}(θ, φ) &= \sqrt{\frac{3}{4π}} \cdot \frac{x}{r}\\
105+
\end{aligned}
106+
\right.\\
107+
\text{ℓ = 2} \quad &
108+
\left\{
109+
\begin{aligned}
110+
Y_{2,-2}(θ, φ) &= \frac{1}{2} \sqrt{\frac{15}{π}} \cdot \frac{xy}{r^2}\\
111+
Y_{2,-1}(θ, φ) &= \frac{1}{2} \sqrt{\frac{15}{π}} \cdot \frac{yz}{r^2}\\
112+
Y_{2,0}(θ, φ) &= \frac{1}{4} \sqrt{\frac{5}{π}} \cdot \frac{3z^2 - r^2}{r^2}\\
113+
Y_{2,1}(θ, φ) &= \frac{1}{2} \sqrt{\frac{15}{π}} \cdot \frac{xz}{r^2}\\
114+
Y_{2,2}(θ, φ) &= \frac{1}{4} \sqrt{\frac{15}{π}} \cdot \frac{x^2 - y^2}{r^2}\\
115+
\end{aligned}
116+
\right.\\
117+
\text{ℓ = 3} \quad &
118+
\left\{
119+
\begin{aligned}
120+
Y_{3,-3}(θ, φ) &= \frac{1}{4} \sqrt{\frac{35}{2π}} \cdot \frac{y(3x^2 - y^2)}{r^3}\\
121+
Y_{3,-2}(θ, φ) &= \frac{1}{2} \sqrt{\frac{105}{π}} \cdot \frac{xyz}{r^3}\\
122+
Y_{3,-1}(θ, φ) &= \frac{1}{4} \sqrt{\frac{21}{2π}} \cdot \frac{y(5z^2 - r^2)}{r^3}\\
123+
Y_{3,0}(θ, φ) &= \frac{1}{4} \sqrt{\frac{7}{π}} \cdot \frac{z(5z^2 - 3r^2)}{r^3}\\
124+
Y_{3,1}(θ, φ) &= \frac{1}{4} \sqrt{\frac{21}{2π}} \cdot \frac{x(5z^2 - r^2)}{r^3}\\
125+
Y_{3,2}(θ, φ) &= \frac{1}{4} \sqrt{\frac{105}{π}} \cdot \frac{z(x^2 - y^2)}{r^3}\\
126+
Y_{3,3}(θ, φ) &= \frac{1}{4} \sqrt{\frac{35}{2π}} \cdot \frac{x(x^2 - 3y^2)}{r^3}\\
127+
\end{aligned}
128+
\right.
129+
\end{aligned}
130+
```
131+
132+
TODO: Explain the relationship of r to the unit sphere and normalizing the (x, y, z) coordinates.
133+
134+
Other extensions may define alternative lighting methods, have specific requirements for handling compression, or define different spherical harmonics handling.
135+
136+
See [Appendix A: Rendering with the base Ellipse Kernel and Spherical Harmonics](#appendix-a-rendering-with-the-base-ellipse-kernel-and-spherical-harmonics) for more details on how to properly implement the lighting used by this extension.
137+
77138
## Schema Example
78139

79140
Example shown below including optional attributes and properties. This extension only affects any `primitive` nodes containting 3D Gaussian splat data.
@@ -148,6 +209,8 @@ Together, the scale and rotation can be used to reconstruct the full covariance
148209

149210
More details on how to interpret these attributes for rendering can be found in the [3D Gaussian Splatting for Real-Time Radiance Field Rendering](https://repo-sam.inria.fr/fungraph/3d-gaussian-splatting/) paper.
150211

212+
See [Appendix A: Rendering with the base Ellipse Kernel and Spherical Harmonics](#appendix-a-rendering-with-the-base-ellipse-kernel-and-spherical-harmonics) for more details on how to properly implement the ellipse kernel used by this extension.
213+
151214
### Color Space
152215

153216
The `colorSpace` property is a required property that specifies the color space of the 3D Gaussian Splat when spherical harmonics are being used for the lighting. The color space is typically determined by the training process for the splats. This color space value only applies to the 3D Gaussian splatting data and does not affect any other color data in the glTF.
@@ -303,6 +366,14 @@ The extension must also be listed in `extensionsUsed` at the top level of the gl
303366
]
304367
```
305368

369+
## Appendix A: Rendering with the base Ellipse Kernel and Spherical Harmonics
370+
371+
*This section is non-normative.*
372+
373+
The ellipse kernel defined in `KHR_gaussian_splatting` is based on the kernel and implementation described in the original research paper, [3D Gaussian Splatting for Real-Time Radiance Field Rendering](https://repo-sam.inria.fr/fungraph/3d-gaussian-splatting/). This kernel is defined by projecting a 3D ellipsoid onto a 2D plane using a perspective projection. The ellipsoid is defined by its mean (position), covariance matrix (derived from scale and rotation), and opacity.
374+
375+
TODO FINISH THIS THING
376+
306377
## Known Implementations
307378

308379
This is currently implemented within [3D Tiles and CesiumJS as an experimental feature](https://cesium.com/learn/cesiumjs/ref-doc/Cesium3DTileset.html?classFilter=3D).

0 commit comments

Comments
 (0)