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_clearcoat and KHR_materials_specular #1677

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
48600e2
First draft clearcoat "extension".
UX3D-nopper Aug 23, 2019
de405a6
Extend documentation and updated documentation in schema.
UX3D-nopper Aug 23, 2019
8eb0afd
Fxied uppercase letter.
UX3D-nopper Aug 23, 2019
1efc6f7
Changes regarding Alexey's feedback.
UX3D-nopper Aug 23, 2019
568ce98
Fxies regarding Ed's feedback.
UX3D-nopper Aug 23, 2019
b2c9acb
Added explanation for default texture etc.
UX3D-nopper Aug 23, 2019
9915267
Added line breaks fo better reading.
UX3D-nopper Aug 23, 2019
3f3b220
Fixed roughness bug.
UX3D-nopper Aug 23, 2019
984dbb8
Added Autodesk, Dassault links. Preference for Enterprise PBR formula?!
UX3D-nopper Aug 23, 2019
e0162e4
Added Unreal Clearcoat.
UX3D-nopper Aug 23, 2019
358e24a
Added calculation from Substance Painter.
UX3D-nopper Aug 23, 2019
d43a58f
Changes reagrding Don's feedback. Simplified formula.
UX3D-nopper Aug 24, 2019
0e2cde2
Moved reference sections into one. Minor typo fixing.
UX3D-nopper Aug 25, 2019
75dc386
Renamed files. Proper reference titles.
UX3D-nopper Aug 25, 2019
c6552af
Replaced "mixing" for clearcoat using AxF formula.
UX3D-nopper Aug 26, 2019
a52e188
Added Tobias to credits.
UX3D-nopper Aug 26, 2019
3481e0e
Shortened formula
UX3D-nopper Aug 27, 2019
786ff02
Better described the meaning of the abstract code.
UX3D-nopper Aug 28, 2019
f038171
Added KHR_materials_specular
UX3D-nopper Aug 29, 2019
c2bc97e
fix copy-paste mistake
Sep 6, 2019
64de4f3
Changed blend formula to be light independent.
UX3D-nopper Nov 29, 2019
57b2d03
Added KHR_materials_thinfilm.
UX3D-nopper Dec 9, 2019
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
94 changes: 94 additions & 0 deletions extensions/2.0/Khronos/KHR_materials_clearcoat/README.md
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.
Copy link
Member

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 and clearcoatRoughnessTexture.

Copy link
Member

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 white

Copy link
Contributor Author

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.

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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this formula be simplified as follows? Is this the same formula?

f = mix(f_emissive + f_diffuse + f_specular, f_clearcoat, blendFactor)

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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.
Where do you have the formula from?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's the same formula, just refactored. Recall that:

mix(x, y, a) = x * (1.0 - a) + y*a

Given the left side of mix is already multiplied by 1.0 - blendFactor, I don't think we need to show it being multiplied separately.

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": { }
}
}
64 changes: 64 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,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": { }
}
}
87 changes: 87 additions & 0 deletions extensions/2.0/Khronos/KHR_materials_thinfilm/README.md
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": { }
}
}