bevyengine / bevyengine/bevy

Confusion about Reflectance vs. IOR with StandardMaterial

Open
#17,382 0 comments 0 reactions 0 assignees View on GitHub
A-Rendering C-Docs D-Straightforward S-Ready-For-Implementation
Dominant language
Rust
Stars
48.2k
Forks
4.8k
Avg merge
3d 22h
Merged PRs (30d)
161

Description

## How can Bevy's documentation be improved?

In PBR shading (as described in the [Filament docs](https://google.github.io/filament/Materials.html#toc3.1)), IOR and Reflectance refer to the same thing.

In Filament, if you specify one, the other is derived automatically. If you specify both, you get a non-physically-accurate material.

In other software, only one of the two parameters is exposed. For example, in Blender, you only have IOR (in the Principled BSDF shader).

The relationship is governed by the equation: `reflectance = pow((1.0 - ior)/(1.0 + ior), 2.0)`. The default value is 4% reflectance == 1.5 IOR. Filament and Bevy specify reflectance in a range of 0.0..=1.0, where 1.0 is 16% and 0.5 is 4%.

In Bevy's StandardMaterial, there are both `reflectance` and `ior` fields in the struct. However, they are not related as described above. I had to read the shader source code to figure out how they are used. Turns out that the PBR shading model only uses the `reflectance` value and the `ior` value is only used for transmissive materials. This was very confusing to me, as in other software (Blender, Filament, etc), I can set the IOR of the material (say according to a database like https://physicallybased.info), and the PBR shading uses that. In Bevy, setting the IOR does nothing (for non-transmissive materials). I have to convert it to a reflectance value and set reflectance instead. This is a footgun and not documented anywhere.

Perhaps Bevy should even get rid of the separate fields in the struct?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.