-
Notifications
You must be signed in to change notification settings - Fork 1.2k
KHR_materials_specular #1719
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
Merged
emackey
merged 31 commits into
KhronosGroup:master
from
DassaultSystemes-Technology:KHR_materials_specular
Apr 14, 2021
Merged
KHR_materials_specular #1719
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 cbd0d0e
Split texture.
proog128 3c3e048
Added more details, removed energy-preserving diffuse BRDF for now.
proog128 0cf4352
Allow 1-channel texture for specular color.
proog128 e9fc32b
Added conversion from spec-gloss.
proog128 2102679
Implementation section now aligns better to current glTF 2.0 spec; cl…
proog128 cdad1e2
Describe conversion from KHR_materials_pbrSpecularGlossiness.
proog128 75083f1
Pack all values in one texture, use enum to indicate texture type.
proog128 758eef8
Add images.
proog128 20aa586
Several minor improvements.
proog128 975a226
Clarify requirement of specularTextureType.
proog128 63d8343
Remove texture type.
proog128 e73ff06
Add non-normative marker.
proog128 05e0f7b
Remove all traces of specularColorTexture (it is now merged into spec…
proog128 a2b0c05
Add contributors and Khronos copyright.
proog128 a62f4c9
Removed empty section.
proog128 3da2dfc
Add details about complementary color weight.
proog128 c4f87b2
Add exclusions section and fix small issues.
proog128 1cd78c6
Suggest ior=1000 for conversion from spec-gloss to metal-rough, as 0 …
proog128 06f85d7
Increase recommended ior for spec-gloss conversion.
proog128 e41ed16
Update copyright year.
proog128 abf2200
Add note to explain spec-gloss conversion.
proog128 e53e478
Make compatible to new Appendix B.
proog128 229d53a
Recommend ior=0 for spec-gloss conversion.
proog128 7a3c821
Split specularTexture.
proog128 2002ef9
Remove upper limit of specular color and change recommendation for re…
proog128 8ae8ce6
Fix bug in fresnel_mix.
proog128 2c45562
Update contributor list
emackey 4251448
Draft status
emackey 395c52e
More contributors
emackey fc08213
Add suggestion from Alexey regarding clamping.
proog128 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. | ||
|
||
`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. |
37 changes: 37 additions & 0 deletions
37
extensions/2.0/Khronos/KHR_materials_specular/schema/glTF.KHR_materials_specular.schema.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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": { } | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.