Razakhel / RaZ

Modern & multiplatform 3D game engine in C++17

Home Page:http://razakhel.github.io/RaZ

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Cook-Torrance] Investigate UE4's Fresnel Shlick optimization

Razakhel opened this issue · comments

Instead of the common Fresnel calculation, Brian Karis suggests using a spherical gaussian approximation, which he deems more efficient with unnoticeable differences.

As such, the current Fresnel calculation:

Standard formula

vec3 fresnel = baseReflectivity + (1.0 - baseReflectivity) * pow(1.0 - cosTheta, 5.0);

would become:

Optimization formula

vec3 fresnel = baseReflectivity + (1.0 - baseReflectivity) * pow(2.0, (-5.55473 * cosTheta - 6.98316) * cosTheta);

In RaZ's case, this actually fixes black artifacts when the light's position is strictly equivalent to the camera's (which should not happen in real life cases):

Fresnel artifacts
Fresnel optimization

This optimization should probably be investigated, as the artifacts may come from a small blunder in the implementation.