Goshido / android-vulkan

This repository is a project for learning Vulkan API, constraint based 3D physics, Lua scripting, spatial sound rendering, HTML+CSS UI rendering.
30 stars 3 forks source link

Another way to avoid INF values in Cook-Torrance model #74

Closed Goshido closed 3 months ago

Goshido commented 3 months ago

This is related to previous research from #59. Quick recap you could get INF values from point light at certain conditions. Such single value destroys whole HDR pipeline.

[2024/06/12] The dude with Discord's nickname Suslik told about another approach to avoid INF values. The idea is to clamp input values:

there's 3 ways it can break: D() goes to infinity, NoV goes to 0 and NoL goes to 0. each of them corresponds to a different mode of failure and needs to be taken care of separately D() breaks when your roughness reaches 0. solution: never allow roughness to go below eps. use an actual mirror BRDF for mirrors if you have to. NoV and NoL can be safely clamped to be greater than eps as well, because they basically correspond to a grazing view angle and a grazing light angles respectively

For asset roughness he told about Diablo 4 approach which clamps this value to 0.2. But he pointed out that

also 0.2 is a crazy high value that will result in all blood looking dry. blizzard did it because of specular aliasing. you can clamp to a much lower value if your goal is to just get rid of infinities (something like 1e-2 should work for nonlinear roughness)

So it's needed to try this approach.

Steps

Goshido commented 3 months ago

results