-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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_clearcoat and KHR_materials_specular #1677
Changes from all commits
48600e2
de405a6
8eb0afd
1efc6f7
568ce98
b2c9acb
9915267
3f3b220
984dbb8
e0162e4
358e24a
d43a58f
0e2cde2
75dc386
c6552af
a52e188
3481e0e
786ff02
f038171
c2bc97e
64de4f3
57b2d03
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
# KHR\_materials\_clearcoat | ||
|
||
## Khronos 3D Formats Working Group | ||
|
||
* Alexey Knyazev | ||
* Don McCurdy | ||
* Ed Mackey | ||
* Norbert Nopper, UX3D [@UX3DGpuSoftware](https://twitter.com/UX3DGpuSoftware) | ||
* Romain Guy | ||
* Tobias Haeussler | ||
|
||
## Acknowledgments | ||
|
||
* TODO | ||
|
||
## Status | ||
|
||
Experimental | ||
|
||
## Dependencies | ||
|
||
Written against the glTF 2.0 spec. | ||
|
||
## Overview | ||
|
||
TODO | ||
|
||
## Extending Materials | ||
|
||
The PBR clearcoat materials are defined by adding the `KHR_materials_clearcoat` extension to any glTF material. | ||
For example, the following defines a material like varnish using clearcoat parameters. | ||
|
||
```json | ||
{ | ||
"materials": [ | ||
{ | ||
"name": "varnish", | ||
"extensions": { | ||
"KHR_materials_clearcoat": { | ||
"clearcoatFactor": 1.0 | ||
} | ||
} | ||
} | ||
] | ||
} | ||
``` | ||
|
||
### Clearcoat | ||
|
||
All implementations should use the same calculations for the BRDF inputs. Implementations of the BRDF itself can vary based on device performance and resource constraints. See [appendix](/specification/2.0/README.md#appendix-b-brdf-implementation) for more details on the BRDF calculations. | ||
|
||
| | Type | Description | Required | | ||
|----------------------------------|---------------------------------------------------------------------------------|----------------------------------------|----------------------| | ||
|**clearcoatFactor** | `number` | The clearcoat layer intensity. | No, default: `0.0` | | ||
|**clearcoatTexture** | [`textureInfo`](/specification/2.0/README.md#reference-textureInfo) | The clearcoat layer intensity texture. | No | | ||
|**clearcoatRoughnessFactor** | `number` | The clearcoat layer roughness. | No, default: `0.0` | | ||
|**clearcoatRoughnessTexture** | [`textureInfo`](/specification/2.0/README.md#reference-textureInfo) | The clearcoat layer roughness texture. | No | | ||
|**clearcoatNormalTexture** | [`normalTextureInfo`](/specification/2.0/README.md#reference-normaltextureinfo) | The clearcoat normal map texture. | No | | ||
|
||
The clearcoat formula `f_clearcoat` is the same as the specular term from the Metallic-Roughness material, using F0 equal 0.04. | ||
The following abstract code describes how the base and clearcoat layers should be blended together: | ||
|
||
``` | ||
blendFactor = clearcoatFactor * fresnel(0.04, NdotV) | ||
f = (f_emissive + f_diffuse) * (1.0 - blendFactor) + mix(f_specular, f_clearcoat, blendFactor) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can this formula be simplified as follows? Is this the same formula?
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The formula I provided is from Substance Painter and they are just blending the specular part, which does makes sense from my point of view. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's the same formula, just refactored. Recall that:
Given the left side of Looking at Substance Painter's code, I see why they did it that way: Their shader needed diffuse, emissive, and specular outputs as separate values, not added together. Perhaps we could show it as separate values too, but if we're showing it all added together then it may as well all go into the mix statement. |
||
``` | ||
|
||
If `clearcoatFactor = 0`, the clearcoat layer is disabled and the material is behaving like the core Metallic-Roughness material: | ||
|
||
``` | ||
f = f_emissive + f_diffuse + f_specular | ||
``` | ||
|
||
If textures are not set, the default values of the clearcoat layer textures are used and the values are not inherited from the underlying Metallic-Roughness (or other) material. If one wants to have the same textures, one have to explicitly set the same texture sources. | ||
|
||
## Appendix | ||
|
||
TODO | ||
|
||
## Reference | ||
|
||
### Theory, Documentation and Implementations | ||
|
||
[Autodesk Standard Surface - Coating](https://autodesk.github.io/standard-surface/#closures/coating) | ||
[AxF - Appearance exchange Format](https://www.xrite.com/-/media/xrite/files/whitepaper_pdfs/axf/axf_whitepaper_en.pdf) | ||
[Blender Principled BSDF](https://docs.blender.org/manual/en/latest/render/shader_nodes/shader/principled.html) | ||
[Disney BRDF Explorer - disney.brdf](https://github.com/wdas/brdf/blob/master/src/brdfs/disney.brdf) | ||
[Enterprise PBR Shading Model - Clearcoat](https://dassaultsystemes-technology.github.io/EnterprisePBRShadingModel/spec.md.html#components/clearcoat) | ||
[Filament Material models - Clear coat](https://google.github.io/filament/Materials.md.html#materialmodels/litmodel/clearcoat) | ||
[Physically-Based Shading at Disney](https://disney-animation.s3.amazonaws.com/library/s2012_pbs_disney_brdf_notes_v2.pdf) | ||
[Substance Painter - Updated Clear Coat Shader](https://docs.substance3d.com/spdoc/version-2018-3-172823522.html#Version2018.3-UpdatedClearCoatShader) | ||
[THE PBR GUIDE BY ALLEGORITHMIC - PART 1](https://academy.substance3d.com/courses/the-pbr-guide-part-1) | ||
[THE PBR GUIDE BY ALLEGORITHMIC - PART 2](https://academy.substance3d.com/courses/the-pbr-guide-part-2) | ||
[Unreal Engine 4 Material - Clear Coat](https://docs.unrealengine.com/en-US/Engine/Rendering/Materials/MaterialInputs/index.html#clearcoat) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
{ | ||
"$schema": "http://json-schema.org/draft-04/schema", | ||
"title": "KHR_materials_clearcoat glTF extension", | ||
"type": "object", | ||
"description": "glTF extension that defines the clearcoat material layer.", | ||
"allOf": [ { "$ref": "glTFProperty.schema.json" } ], | ||
"properties": { | ||
"clearcoatFactor": { | ||
"type": "number", | ||
"description": "The clearcoat layer intensity.", | ||
"default": 0.0, | ||
"minimum": 0.0, | ||
"maximum": 1.0, | ||
"gltf_detailedDescription": "The clearcoat layer intensity (aka opacity) of the material. A value of 0.0 means the material has no clearcoat layer enabled." | ||
}, | ||
"clearcoatTexture": { | ||
"allOf": [ { "$ref": "textureInfo.schema.json" } ], | ||
"description": "The clearcoat layer intensity texture.", | ||
"gltf_detailedDescription": "The clearcoat layer intensity texture. Stored in channel R with default linear value 1.0." | ||
}, | ||
"clearcoatRoughnessFactor": { | ||
"type": "number", | ||
"description": "The clearcoat layer roughness.", | ||
"default": 0.0, | ||
"minimum": 0.0, | ||
"maximum": 1.0, | ||
"gltf_detailedDescription": "The clearcoat layer roughness of the material." | ||
}, | ||
"clearcoatRoughnessTexture": { | ||
"allOf": [ { "$ref": "textureInfo.schema.json" } ], | ||
"description": "The clearcoat layer roughness texture.", | ||
"gltf_detailedDescription": "The clearcoat layer roughness texture. Stored in channel G with default linear value 1.0." | ||
}, | ||
"clearcoatNormalTexture": { | ||
"allOf": [ { "$ref": "material.normalTextureInfo.schema.json" } ], | ||
"description": "The clearcoat normal map texture.", | ||
"gltf_detailedDescription": "A tangent space normal map for the clearcoat layer." | ||
}, | ||
"extensions": { }, | ||
"extras": { } | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
# KHR\_materials\_specular | ||
|
||
## Khronos 3D Formats Working Group | ||
|
||
* Norbert Nopper, UX3D [@UX3DGpuSoftware](https://twitter.com/UX3DGpuSoftware) | ||
|
||
## Acknowledgments | ||
|
||
* TODO | ||
|
||
## Status | ||
|
||
Experimental | ||
|
||
## Dependencies | ||
|
||
Written against the glTF 2.0 spec. | ||
|
||
## Overview | ||
|
||
TODO | ||
|
||
## Extending Materials | ||
|
||
The specular materials are defined by adding the `KHR_materials_specular` extension to any glTF material. | ||
|
||
```json | ||
{ | ||
"materials": [ | ||
{ | ||
"extensions": { | ||
"KHR_materials_specular": { | ||
"specularFactor": 0.5 | ||
} | ||
} | ||
} | ||
] | ||
} | ||
``` | ||
|
||
### Specular | ||
|
||
All implementations should use the same calculations for the BRDF inputs. Implementations of the BRDF itself can vary based on device performance and resource constraints. See [appendix](/specification/2.0/README.md#appendix-b-brdf-implementation) for more details on the BRDF calculations. | ||
|
||
| | Type | Description | Required | | ||
|---------------------|---------------------------------------------------------------------|------------------------|----------------------| | ||
|**specularFactor** | `number` | The specular. | No, default: `0.5` | | ||
|**specularTexture** | [`textureInfo`](/specification/2.0/README.md#reference-textureInfo) | The specular texture. | No | | ||
|
||
This extension is overwriting the default `F0 = 0.04` for non-metallic materials in the Metallic-Roughness workflow. Instead, `F0 = 0.08 * specularFactor * specularTexture` is used. | ||
|
||
## Appendix | ||
|
||
TODO | ||
|
||
## Reference | ||
|
||
### Theory, Documentation and Implementations | ||
|
||
[Blender Principled BSDF](https://docs.blender.org/manual/en/latest/render/shader_nodes/shader/principled.html) | ||
[Disney BRDF Explorer - disney.brdf](https://github.com/wdas/brdf/blob/master/src/brdfs/disney.brdf) | ||
[Physically-Based Shading at Disney](https://disney-animation.s3.amazonaws.com/library/s2012_pbs_disney_brdf_notes_v2.pdf) | ||
[THE PBR GUIDE BY ALLEGORITHMIC - PART 1](https://academy.substance3d.com/courses/the-pbr-guide-part-1) | ||
[THE PBR GUIDE BY ALLEGORITHMIC - PART 2](https://academy.substance3d.com/courses/the-pbr-guide-part-2) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{ | ||
"$schema": "http://json-schema.org/draft-04/schema", | ||
"title": "KHR_materials_specular glTF extension", | ||
"type": "object", | ||
"description": "glTF extension that defines the specular channel for the Metallic-Roughness layer.", | ||
"allOf": [ { "$ref": "glTFProperty.schema.json" } ], | ||
"properties": { | ||
"specularFactor": { | ||
"type": "number", | ||
"description": "The specular channel.", | ||
"default": 0.5, | ||
"minimum": 0.0, | ||
"maximum": 1.0, | ||
"gltf_detailedDescription": "" | ||
}, | ||
"specularTexture": { | ||
"allOf": [ { "$ref": "textureInfo.schema.json" } ], | ||
"description": "The specular channel texture.", | ||
"gltf_detailedDescription": "The specular channel texture. Stored in channel A with default linear value 1.0 of the AO-Roughness-Metallic texture." | ||
}, | ||
"extensions": { }, | ||
"extras": { } | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
# KHR\_materials\_thinfilm | ||
|
||
## Khronos 3D Formats Working Group | ||
|
||
* Norbert Nopper, UX3D [@UX3DGpuSoftware](https://twitter.com/UX3DGpuSoftware) | ||
|
||
## Acknowledgments | ||
|
||
* TODO | ||
|
||
## Status | ||
|
||
Experimental | ||
|
||
## Dependencies | ||
|
||
Written against the glTF 2.0 spec. | ||
|
||
## Overview | ||
|
||
TODO | ||
|
||
## Extending Materials | ||
|
||
The thin film materials are defined by adding the `KHR_materials_thinfilm` extension to any glTF material. | ||
|
||
```json | ||
{ | ||
"materials": [ | ||
{ | ||
"extensions": { | ||
"KHR_materials_thinfilm": { | ||
"thinfilmFactor": 1.0 | ||
} | ||
} | ||
} | ||
] | ||
} | ||
``` | ||
|
||
### Thinfilm | ||
|
||
All implementations should use the same calculations for the BRDF inputs. Implementations of the BRDF itself can vary based on device performance and resource constraints. See [appendix](/specification/2.0/README.md#appendix-b-brdf-implementation) for more details on the BRDF calculations. | ||
|
||
| | Type | Description | Required | | ||
|-----------------------------|---------------------------------------------------------------------|----------------------------------|-----------------------| | ||
|**thinfilmFactor** | `number` | The thin film intensity. | No, default: `0.0` | | ||
|**thinfilmTexture** | [`textureInfo`](/specification/2.0/README.md#reference-textureInfo) | The thin film intensity texture. | No | | ||
|**thinfilmThicknessMinimum** | `number` | The thin film minimum thickness. | No, default: `400.0` | | ||
|**thinfilmThicknessMaximum** | `number` | The thin film maximum thickness. | No, default: `1200.0` | | ||
|**thinfilmThicknessTexture** | [`textureInfo`](/specification/2.0/README.md#reference-textureInfo) | The thin film thickness texture. | No | | ||
|
||
``` | ||
float thinfilmThicknessNormalized = (thinfilmTexture.g * (thinfilmThicknessMaximum - thinfilmThicknessMinimum) + thinfilmThicknessMinimum) / 1200.0; | ||
float thinfilmIntensity = thinfilmTexture.r * thinfilmFactor; | ||
``` | ||
|
||
The thin film effect is overwriting the F (Surface Reflection Ratio) from the specular glossiness effect. | ||
``` | ||
vec3 thinfilmSpecularReflection(vec3 F0, float VdotH, float thinfilmIntensity, float thinfilmThicknessNormalized) | ||
{ | ||
vec3 F = fresnelReflection(F0, VdotH); | ||
|
||
if (thinfilmIntensity == 0.0) | ||
{ | ||
return F; | ||
} | ||
|
||
vec3 lutSample = texture(lutTexture, thinfilmThicknessNormalized, VdotH)).rgb - 0.5; | ||
|
||
vec3 intensity = thinfilmIntensity * 4.0 * F0 * (1.0 - F0); | ||
|
||
return clamp(lutSample * intensity + F, 0.0, 1.0); | ||
} | ||
``` | ||
|
||
|
||
## Appendix | ||
|
||
TODO | ||
|
||
## Reference | ||
|
||
### Theory, Documentation and Implementations | ||
|
||
[A Practical Extension to Microfacet Theory for the Modeling of Varying Iridescence](https://belcour.github.io/blog/research/2017/05/01/brdf-thin-film.html) | ||
[Practical Multilayered Materials - Call of Duty - page 62](https://blog.selfshadow.com/publications/s2017-shading-course/drobot/s2017_pbs_multilayered.pdf) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
{ | ||
"$schema": "http://json-schema.org/draft-04/schema", | ||
"title": "KHR_materials_thinfilm glTF extension", | ||
"type": "object", | ||
"description": "glTF extension that defines the thin film effect.", | ||
"allOf": [ { "$ref": "glTFProperty.schema.json" } ], | ||
"properties": { | ||
"thinfilmFactor": { | ||
"type": "number", | ||
"description": "The thin film intensity.", | ||
"default": 0.0, | ||
"minimum": 0.0, | ||
"maximum": 1.0, | ||
"gltf_detailedDescription": "" | ||
}, | ||
"thinfilmTexture": { | ||
"allOf": [ { "$ref": "textureInfo.schema.json" } ], | ||
"description": "The thin film intensity texture.", | ||
"gltf_detailedDescription": "The thin film intensity texture. Stored in channel R with default linear value 1.0 of the thin film texture." | ||
}, | ||
"thinfilmThicknessMinimum": { | ||
"type": "number", | ||
"description": "The thin film minimum thickness.", | ||
"default": 400.0, | ||
"minimum": 0.0, | ||
"gltf_detailedDescription": "" | ||
}, | ||
"thinfilmThicknessMaximum": { | ||
"type": "number", | ||
"description": "The thin film maximum thickness.", | ||
"default": 1200.0, | ||
"maximum": 1200.0, | ||
"gltf_detailedDescription": "" | ||
}, | ||
"thinfilmThicknessTexture": { | ||
"allOf": [ { "$ref": "textureInfo.schema.json" } ], | ||
"description": "The thin film thickness texture.", | ||
"gltf_detailedDescription": "The thin film thickness texture. Stored in channel G with default linear value 1.0 of the thin film texture." | ||
}, | ||
"extensions": { }, | ||
"extras": { } | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In addition to specifying F0, perhaps also specify that metallic is zero and roughness comes from the product of
clearcoatRoughnessFactor
andclearcoatRoughnessTexture
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also that baseColor is
vec3(1.0)
, full whiteThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For clear coat, no diffuse part is calculated. So baseColor does not have to be specified. The same with metallic.
But I agree, that how the specular part is calculated should be better described.