KhronosGroup / KhronosGroup/glTF

Clarifying `KHR_materials_sheen` implementation section

Open
#2,323 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
HTML
Stars
7.8k
Forks
1.2k
Avg merge
17h 26m
Merged PRs (30d)
5

Description

Although non-normative, the implementation section of the [`KHR_materials_sheen` extension](https://github.com/KhronosGroup/glTF/tree/main/extensions/2.0/Khronos/KHR_materials_sheen) could be clarified to make adoption more straightforward.

Some points that could be useful:
- Inclusion of IBL lighting section for sheen
- Specifying that the `E(x)` term is the _directional albedo_
- Specifying that the BRDF LUT blue channel already stores `E(x)`

### Sheen IBL

The section could include a short description about IBL for sheen which[ is often achieved](https://google.github.io/filament/Filament.html#lighting/imagebasedlights/cloth) by storing a DG term in the blue channel of the BRDF LUT used for the split-sum approximation, as Fresnel is omitted. [The UE documentation by Karis](https://cdn2.unrealengine.com/Resources/files/2013SiggraphPresentationsNotes-26915738.pdf) gives the term as:

$$\int_{H} f(l, v) \cdot cos\theta\ d\omega_l$$

The Khronos sample viewer also [follows this approach](https://github.com/KhronosGroup/glTF-Sample-Viewer/blob/25ed2bea5de7b45ffe0907b45391f08e27db3c03/source/Renderer/shaders/ibl.glsl#L198).

### `E(x)` is _directional albedo_

The directional albedo used for [albedo scaling](https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Khronos/KHR_materials_sheen/README.md#albedo-scaling-technique) comes across as a bit of a mystery and is only called "the `E(x)` values". This makes it difficult to research.

The [source paper](https://citeseerx.ist.psu.edu/viewdoc/download;jsessionid=4D725C91D97DCD292F40FDBC0D54FB96?doi=10.1.1.21.6585&rep=rep1&type=pdf) for coupling diffuse and specular lobes gives the scaling equation as $a_{matte} = 1.0 - a_{spec}$, where $$a_{spec} = \int_{\Omega} f(L, V) \cdot cos\theta\ d\omega_V$$

The reader is referred to two external sources without specifying what the LUT stores. The implemention is tied to images hosted or generated by 3rd party sites. It's not easy to verify implementation correctness as pre-generated images can include minor tweaks like clamping values. Additionally there is risk of link rot. In fact, Enterprise PBR already [does not seem to use the LUT](https://github.com/DassaultSystemes-Technology/dspbr-pt/blob/e7cfa6e9aab2b99065a90694e1f58564d675c1a4/packages/lib/shader/bsdfs/sheen.glsl#L16C1-L20C2) themselves.

The issue of the nature of the LUT [has come up before](https://community.khronos.org/t/how-to-generate-sheen-e-lut/107489).

### `E(x)` is the same as the DG term

As long as the sheen BRDF is reciprocal, the above equations are equal. The directional albedo used for albedo scaling is the same as the DG term used for IBL. The UE documentation also states:
>This is the same as integrating the specular BRDF with a solid-white environment, i.e. $L_i(l_k) = 1$.

There is then no need for another texture as the data is stored in the blue channel of the BRDF LUT. This is also mentioned in [BabylonJS](https://github.com/BabylonJS/Babylon.js/blob/4f9998cf27d985e4b42fc8a7c68eb06274784c87/packages/dev/core/src/Shaders/ShadersInclude/pbrBlockSheen.fx#L216). The extension text can then refer to the Khronos GLTF Sample Viewer [IBL code](https://github.com/KhronosGroup/glTF-Sample-Viewer/blob/25ed2bea5de7b45ffe0907b45391f08e27db3c03/source/shaders/ibl_filtering.frag#L364), maintaining ownership of the link and providing an example implementation.

#### Clamping directional albedo

The DG term is clamped to [0, 1] (either [explicitly](https://github.com/KhronosGroup/glTF-Sample-Viewer/blob/25ed2bea5de7b45ffe0907b45391f08e27db3c03/source/shaders/ibl_filtering.frag#L359) or by storing it in a non-floting-point texture) which is not clear from any documentation. Because no citation is provided, it's not clear if and why this is required mathematically. To be fair, this one is a somewhat moot point as the numerical aspects of models are not what the extension text is about. Still, it causes confusion when implementing `KHR_materials_sheen`.

---

The above is not really a comment on the correctness or suitability of the extension text itself. These are just some suggestions for making the adoption and implementation of the `KHR_materials_sheen` extension easier. If there are obvious mistakes in the points above, that would also hopefully demonstrate that the subject is not as clear as it could be.

Contributor guide

Open the contributing guide

Research direction

Start with the implementation section of extensions/2.0/Khronos/KHR_materials_sheen and compare it with the linked glTF Sample Viewer IBL code and cited references. Clarify sheen IBL, identify E(x) as directional albedo and the BRDF LUT blue channel, and document the stated clamping behavior; done when the extension text makes these implementation details easier to verify.

Written by the indexing model from the issue text.

Assessment

Domain
computer-graphics, documentation
Issue type
Documentation
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.