## Spherical Gaussian approximation for Blinn-Phong, Phong and Fresnel

June 3, 2012 20 Comments

Spherical Gaussian approximation for lighting calculation is not new to the graphic community[4][5][6][7][8] but its use has recently been adopted by the game developer community [1][2][3].

Spherical Gaussian (SG) is a type of spherical radial basis function (SRBF) [8] which can be used to approximate spherical lobes with Gaussian-like function.

This post will describe how SG can be use to approximate Blinn-Phong lighting, Phong lighting and Fresnel.

Why care about SG approximation ?

In the context of realtime rendering for games, the SG approximation allows to save a few instructions when performing lighting calculations. For modern graphics cards, saving few ALU in a shader is not always beneficial, but for older hardware like one can find in the PS3, every GPU cycle counts. This is less true for XBOX360 GPU, which performs better with arithmetic instructions, though this optimization can still be beneficial. It can also be used to schedule instructions in a different (low loaded) pipe on SPUs to increase performance [2].

Part of the work presented here credits to Matthew Jones (from Criterion Games) [9].

## Different spherical radial basis function

The post talk about SG, but it is good to know that there is several different types of SRBF found in graphics papers.

For completeness, I will talk quickly about SG and von Mises-Fisher (vMF) as this can be confusing.

SG definition can be found in [4]:

where p ∈ 𝕊2 is the lobe axis, λ ∈ (0,+∞) is the lobe sharpness,

and μ ∈ ℝ is the lobe amplitude (μ ∈ ℝ3 for RGB color).

vMF is detailed in [8]:

with inverse width k and central direction μ. vMFs are normalized to integrate

to 1. Note: the notation from the paper [8] doesn’t match the notation from above.

The paper presents an approximation of this formula for k > 2 (which is almost always the case) :

As you can see, the formulation stays the same for a lobe sharpness > 2, the difference lies only in the normalization constant for vMF, which we will omit. In the following, I will only refer to the SG function.

## Approximate Blinn-Phong with SG

An approximation of the Blinn-Phong model with SG is provided in the supplementary material of [4]:

Here is the comparison of the accuracy of the approximation for low specular power (<10), medium (25) and high( > 50)