CesiumGS / cesium

An open-source JavaScript library for world-class 3D globes and maps :earth_americas:
https://cesium.com/cesiumjs/
Apache License 2.0
13.04k stars 3.51k forks source link

Verify geometric shadowing function in PBR shader #12010

Closed jjhembd closed 5 months ago

jjhembd commented 6 months ago

As noticed in https://github.com/CesiumGS/cesium/pull/12006: In pbrLighting.glsl we use a formula for geometric self-shadowing that is rather different from the glTF reference implementation.

On a quick first look, the closest method I could find to our smithVisibilityGGX function is the Schlick-GGX Approximation. We are, however, using a different k-value which I have not been able to trace. And the way we avoid divide-by-zero errors is somewhat inconsistent for different inputs.

We either need to:

jjhembd commented 6 months ago

For reference, this paper questions the validity of the "Schlick-Smith Approximation", suggesting that it overestimates the masking effect (which could potentially make our images too dim): https://jcgt.org/published/0003/02/03/paper.pdf See Figure 12 and the surrounding discussion.

jjhembd commented 5 months ago

Here is a quick comparison of the two geometric self-shadowing functions. The effect is subtle, and limited to direct lighting. We use a different code path for IBL.

Current Cesium code: image

glTF Sample Viewer: image

The Sample Viewer function gives a slightly broader and brighter specular reflection.