Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KHR_materials_specular #1719

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
3847e6b
Added KHR_materials_specular.
proog128 Dec 2, 2019
cbd0d0e
Split texture.
proog128 Dec 18, 2019
3c3e048
Added more details, removed energy-preserving diffuse BRDF for now.
proog128 Mar 2, 2020
0cf4352
Allow 1-channel texture for specular color.
proog128 Mar 3, 2020
e9fc32b
Added conversion from spec-gloss.
proog128 Mar 4, 2020
2102679
Implementation section now aligns better to current glTF 2.0 spec; cl…
proog128 May 8, 2020
cdad1e2
Describe conversion from KHR_materials_pbrSpecularGlossiness.
proog128 May 8, 2020
75083f1
Pack all values in one texture, use enum to indicate texture type.
proog128 May 8, 2020
758eef8
Add images.
proog128 May 8, 2020
20aa586
Several minor improvements.
proog128 May 8, 2020
975a226
Clarify requirement of specularTextureType.
proog128 May 8, 2020
63d8343
Remove texture type.
proog128 May 18, 2020
e73ff06
Add non-normative marker.
proog128 May 18, 2020
05e0f7b
Remove all traces of specularColorTexture (it is now merged into spec…
proog128 May 20, 2020
a2b0c05
Add contributors and Khronos copyright.
proog128 May 22, 2020
a62f4c9
Removed empty section.
proog128 Jun 15, 2020
3da2dfc
Add details about complementary color weight.
proog128 Jul 15, 2020
c4f87b2
Add exclusions section and fix small issues.
proog128 Aug 4, 2020
1cd78c6
Suggest ior=1000 for conversion from spec-gloss to metal-rough, as 0 …
proog128 Aug 19, 2020
06f85d7
Increase recommended ior for spec-gloss conversion.
proog128 Jan 12, 2021
e41ed16
Update copyright year.
proog128 Jan 12, 2021
abf2200
Add note to explain spec-gloss conversion.
proog128 Jan 12, 2021
e53e478
Make compatible to new Appendix B.
proog128 Jan 18, 2021
229d53a
Recommend ior=0 for spec-gloss conversion.
proog128 Jan 19, 2021
7a3c821
Split specularTexture.
proog128 Jan 29, 2021
2002ef9
Remove upper limit of specular color and change recommendation for re…
proog128 Jan 29, 2021
8ae8ce6
Fix bug in fresnel_mix.
proog128 Feb 18, 2021
2c45562
Update contributor list
emackey Apr 5, 2021
4251448
Draft status
emackey Apr 5, 2021
395c52e
More contributors
emackey Apr 5, 2021
fc08213
Add suggestion from Alexey regarding clamping.
proog128 Apr 6, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 80 additions & 0 deletions extensions/2.0/Khronos/KHR_materials_specular/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
# KHR\_materials\_specular

## Khronos 3D Formats Working Group

* TODO

## Acknowledgments

* TODO

## Status

Experimental

## Dependencies

Written against the glTF 2.0 spec.

## Overview

This extension adds two parameters to the metallic-roughness material: `specular` and `specularColor`.

`specular` allows users to configure the strength of the specular reflection in the dielectric BRDF. A value of zero disables the specular reflection, resulting in a pure diffuse material. The metal BRDF is not affected by the parameter.
rsahlin marked this conversation as resolved.
Show resolved Hide resolved

`specularColor` changes the F0 color of the specular reflection in the dielectric BRDF, allowing artists to use effects known from the specular-glossiness material (`KHR_materials_pbrSpecularGlossiness`) in the metallic-roughness material.
rsahlin marked this conversation as resolved.
Show resolved Hide resolved


## Extending Materials

The strength of the specular reflection is defined by adding the `KHR_materials_specular` extension to any glTF material.

```json
{
"materials": [
{
"extensions": {
"KHR_materials_specular": {
"specularFactor": 1.0,
"specularTexture": 0,
emackey marked this conversation as resolved.
Show resolved Hide resolved
"specularColorFactor": [1.0, 1.0, 1.0],
"specularColorTexture": 0
}
}
}
]
}
```

Factor and texture are combined by multiplication to describe a single value.

| |Type|Description|Required|
|-|----|-----------|--------|
| **specularFactor** | `number` | The strength of the specular reflection. | No, default: `1.0`|
rsahlin marked this conversation as resolved.
Show resolved Hide resolved
| **specularColorFactor** | `number[3]` | The F0 color of the specular reflection (RGB). | No, default: `[1.0, 1.0, 1.0]`|
| **specularTexture** | [`textureInfo`](/specification/2.0/README.md#reference-textureInfo) | Either a 4-channel texture that defines the specular color in the RGB channels and the specular factor in the alpha channel, a 3-channel texture that defines only the specular color, or a grayscale texture that defines only the specular factor. Will be multiplied by specularFactor and/or specularColorFactor. | No |

## Implementation

The specular factor scales the microfacet BRDF in the dielectric BRDF. It also affects the diffuse BRDF; the less energy is reflected by the microfacet BRDF, the more can be shifted to the diffuse BRDF.

The specular color changes the F0 color of the Fresnel that is multiplied to the microfacet BRDF. The color at grazing angles (F90) is not changed.

```
dielectric_brdf =
fresnel_mix(
diffuse_brdf(baseColor, specular, specularColor),
microfacet_brdf(roughness^2) * specular,
ior = 1.5,
f0 = ((1-ior)/(1+ior))^2 * specularColor)
```

This makes `f0` wavelength-dependent, i.e., it is now a 3-channel RGB value. For the directional albedo `E` and average albedo `Eavg`, this is reduced to 1 channel by taking the maximum of the RGB channels, This avoids unexpected color shifts caused by the subtraction.

```
1 (1 - E(VdotN, max(f0))) * (1 - E(LdotN, max(f0)))
diffuse_brdf = -- * mix(1, ---------------------------------------------------, specular)
pi 1 - Eavg
```

The specular color does not affect the index of refraction that may also be used in `KHR_materials_transmission` to refract light rays going through the surface.
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
"$schema": "http://json-schema.org/draft-04/schema",
"title": "KHR_materials_specular glTF extension",
"type": "object",
"description": "glTF extension that defines the strength of the specular reflection.",
"allOf": [ { "$ref": "glTFProperty.schema.json" } ],
"properties": {
"specularFactor": {
"type": "number",
"description": "The strength of the specular reflection.",
"default": 1.0,
"minimum": 0.0,
"maximum": 1.0,
"gltf_detailedDescription": "This parameter scales the amount of specular reflection on non-metallic surfaces. It has no effect on metals."
},
"specularColorFactor": {
"type": "array",
"items": {
"type": "number",
"minimum": 0.0,
"maximum": 1.0
},
"description": "The F0 RGB color of the specular reflection.",
"default": [ 1.0, 1.0, 1.0 ],
"minItems": 3,
"maxItems": 3,
"gltf_detailedDescription": "This is an additional RGB color parameter that tints the specular reflection of non-metallic surfaces. At grazing angles, the reflection still blends to white, and the parameter has not effect on metals. The value is linear."
},
"specularTexture": {
"allOf": [ { "$ref": "textureInfo.schema.json" } ],
"description": "An RGBA texture that defines the F0 color of the specular reflection and the specular factor.",
"gltf_detailedDescription": "Either a 4-channel texture that defines the specular color in the RGB channels and the specular factor in the alpha channel, a 3-channel texture that defines only the specular color, or a grayscale texture that defines only the specular factor. Will be multiplied by specularFactor and/or specularColorFactor."
emackey marked this conversation as resolved.
Show resolved Hide resolved
},
"extensions": { },
"extras": { }
}
}