GAMES202 Lecture 05 - Real-Time Environment Mapping

GAMES202_Lecture_05 (ucsb.edu)

I. Distance Field Soft Shadows

image-20230919163306811

Pros: Faster than shadow maps, and looks way better.

Cons: Memory cost.

 

(Signed) Distance Function

Input: Coordinate

Output: The minimum distance from that coordinate to the object being described

Related to optimal transport.

 

Characteristics

 

Ray Marching (Sphere Tracing)

Used in ray marching to perform ray-SDF intersections.

image-20230912184257745

Therefore, each time at a given point p, just travel SDF(p) distance.

 

Computing Occlusions (SDF Soft Shadow)

image-20230912184425904

The value of SDF can be used to determine a "safe" angle seen from the eye:

 

During ray marching

image-20230919165149338

To compute the visibility (related to the safe angle) during ray marching:

image-20230912184640509

image-20230912184947922

 

Anti-Aliased Characters in RTR

image-20230912185138801

Troika-Three-Text from GitHub

 

Pros and Cons of Distance Field Soft Shadows

Pros:

Cons:

Acceleration

 

II. Shading from Environment Lighting

Environment lighting: Simulate lighting coming from the surroundings of a scene.

image-20230913185204341

There are spherical maps and cube maps. In the following context we may assume we have already obtained the lighting information regardless of the underlying structure.

The environment lighting is used when solving the rendering equation. In this chapter we will discuss shading only - that is, the visibility term will be ignored.

Environment maps provide information of incoming radiance on a specific shading point.

 

The Split Sum Approximation

In the industry, the resulting integral is computed using sampling and summing, thus it is called split sum rather than split integral.

1Nk=1NLi(lk)f(lk,v)cosθlkp(lk,v)(1Nk=1NLi(lk))(1Nk=1NlK,vcosθlkcosθlkp(lk,v))

Principle

The split sum approximation avoids sampling by approximating the given integral in a way described in Lecture 4:

Ωf(x)g(x)dxΩGf(x)dxΩGdxThe average valueof f(x) over theeffective interval of g(x)Ωg(x)dx

 

1st Stage

We approximate the rendering equation as follows:

(1)Lo(p,ωo)frLi(p,ωi)dωifrdωiΩ+fr(p,ωi,ωo)cosθidωiDo shading without considering lighting

image-20230913191319711

 

2nd Stage

Note that there is a another solution as of the time writing this note.

The idea is to:

 

Compute the latter part of equation 1 by approximating the surface as a microfacet, and extract the Fresnel term using the Schlick's Approximation:

(The Microfacet Model)f(ωi,ωo)=F(ωi,h)G(ωi,ωo,h)D(h)4(n,ωi)(n,ωo)
(The Schlick’s Approximation)R(θ)=R0+(1R0)(1cosθ)5

where

(Basic reflection rate)R0=(n1n2n1+n2)2
(The NDF, Normal Distribution Function)D(h)=exp(tan2θh/α2)πα2cos4θh

image-20230913192819390

The "base color R0" is now extracted:

Ω+fr(p,ωi,ωo)cosθidωiR0Ω+frF(1(1cosθi)5)cosθidωi+Ω+frF(1cosθi)5cosθidωi

and both integrals can be precomputed with only 2 parameters, as now there are only roughness α and incident angle of light ωi left:

image-20230913193058987

 

Results

Completely avoided sampling!

Very fast and almost identical:

image-20230913193333372