fn compute_warping_parameter<F: Float + FloatConst>(
    gamma: F,
    (gamma_a, gamma_b, gamma_c): (F, F, F),
    (eta_b, eta_c): (F, F)
) -> F
Expand description

Compute a near-optimal warping parameter that helps minimize error in a shadow map.

See section 5.2 of Brandon Lloyd’s thesis:

[http://gamma.cs.unc.edu/papers/documents/dissertations/lloyd07.pdf](Logarithmic Perspective Shadow Maps).

η = 0 γ < γ_a -1 + (η_b + 1)(1 + cos(90 (γ - γ_a)/(γ_b - γ_a))) γ_a ≤ γ < γ_b η_b + (η_c - η_b) sin(90 (γ - γ_b)/(γ_c - γ_b)) γ_b ≤ γ < γ_c η_c γ_c ≤ γ

NOTE: Equation’s described behavior is wrong! I have pieced together a slightly different function that seems to more closely satisfy the author’s intent:

η = -1 γ < γ_a -1 + (η_b + 1) (γ - γ_a)/(γ_b - γ_a) γ_a ≤ γ < γ_b η_b + (η_c - η_b) sin(90 (γ - γ_b)/(γ_c - γ_b)) γ_b ≤ γ < γ_c η_c γ_c ≤ γ

There are other alternatives that may have more desirable properties, such as:

η = -1 γ < γ_a -1 + (η_b + 1)(1 - cos(90 (γ - γ_a)/(γ_b - γ_a))) γ_a ≤ γ < γ_b η_b + (η_c - η_b) sin(90 (γ - γ_b)/(γ_c - γ_b)) γ_b ≤ γ < γ_c η_c γ_c ≤ γ