glTF-Sample-Viewer icon indicating copy to clipboard operation
glTF-Sample-Viewer copied to clipboard

Minor tweaks to KHR_materials_specular

Open emackey opened this issue 5 years ago • 4 comments

Following up on #309 which had a great fix. There are two more tiny wrinkles in the spec:

image

The top parameter "specular" should affect both F0 and F90 (reference the last few paragraphs of this section). So, the part circled in yellow above shouldn't have a bright halo around the edges of the spheres, in the top 2 rows on the left. Both F0 and F90 reach zero there.

A separate issue is circled in blue. Those two rows should appear identical. I believe the specularColorFactor has not been through the sRGB-to-linear transfer function here.

emackey avatar Apr 27 '21 17:04 emackey

Regarding the F90 term, with the implementation, we only follow the normative section from the KHR_materials_specular specification

At grazing incidence (f90), the reflectance remains at 1.

and the glTF spec

The reflection color at grazing incidence is called f90. It is set to 1 because the grazing angle reflectance for any material approaches pure white in the limit.

As the non-normative implementation section seems to conflict with the above, the glTF viewer does not follow it.

mobecher avatar Apr 28 '21 08:04 mobecher

I think F90 is the only real difference between the two parameters. Without that we're using two separate samplers to control the same effect, right?

/cc @proog128

emackey avatar Apr 28 '21 11:04 emackey

@emackey Yes, you are right. "Specular" scales f0 and f90. "Specular color" scales f0 only. And both only affect the dielectric BRDF of the material (I am mentioning this explicitly because @UX3D-becher quoted the glTF spec of the metal BRDF).

proog128 avatar Apr 28 '21 11:04 proog128

we have found the source of our confusion, instead of applying the specular weight to both f0 and f90 we now explicitly use it to mix between f_diffuse and f_specular as stated in the spec

mobecher avatar Apr 28 '21 14:04 mobecher