From ea5088fd69920b32b118a98a1804ba58d20d8a28 Mon Sep 17 00:00:00 2001 From: Saurabh Bhatia Date: Thu, 9 Mar 2017 18:39:09 -0800 Subject: [PATCH 1/3] Add alpha coverage details --- specification/2.0/README.md | 19 ++++++++++++ .../material.pbrMetallicRoughness.schema.json | 4 +-- specification/2.0/schema/material.schema.json | 29 +++++++++++++++++-- 3 files changed, 47 insertions(+), 5 deletions(-) diff --git a/specification/2.0/README.md b/specification/2.0/README.md index 6f1c413afa..67e6ea2639 100644 --- a/specification/2.0/README.md +++ b/specification/2.0/README.md @@ -61,6 +61,7 @@ Copyright (C) 2013-2017 The Khronos Group Inc. All Rights Reserved. glTF is a tr * [Materials](#materials) * [Metallic-Roughness Material](#metallic-roughness-material) * [Additional Maps](#additional-maps) + * [Alpha Coverage](#alpha-coverage) * [Cameras](#cameras) * [Projection Matrices](#projection-matrices) * [Animations](#animations) @@ -1003,6 +1004,24 @@ The following examples shows a material that is defined using `pbrMetallicRoughn >| Occlusion | Model will appear brighter in areas that should be darker. | >| Emissive | Model with lights will not be lit. For example, the headlights of a car model will be off instead of on. | +### Alpha Coverage + +The `alphaMode` property defines how the alpha value of the main factor and texture should be interpreted. The alpha value is defined in the `baseColor` for metallic-roughness material model. + +`alphaMode` can be one of the following values: +* `OPAQUE` - The rendered output is fully opaque and any alpha value is ignored. +* `MASK` - The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value. This mode is used to simulate geometry such as tree leaves or wire fences. +* `BLEND` - The rendered output is combined with the background using the normal painting operation (i.e. the Porter and Duff over operator). This mode is used to simulate geometry such as guaze cloth or animal fur. + + When `alphaMode` is set to `MASK` the `alphaCutoff` property specifies the cutoff threshold. If the alpha value is greater than or equal to the `alphaCutoff` value then it is rendered as fully opaque, otherwise, it is rendered as fully transparent. `alphaCutoff` value is ignored for other modes. + +The `doubleSided` property specified whether the material is double sided. + +>**Implementation Note for Real-Time Rasterizers:** Real-time rasterizers typically use depth buffers and mesh sorting to support alpha modes. The following describe the expected behavior for these types of renderers. +>* `OPAQUE` - A depth value is written for every pixel and mesh sorting is not required for correct output. +>* `MASK` - A depth value is not written for a pixel that is discarded after the alpha test. A depth value is written for all other pixels. Mesh sorting is not required for correct output. +>* `BLEND` - Support for this mode varies. There is no perfect and fast solution that works for all cases. Implementations should try to achieve the correct blending output for as many situations as possible. Whether depth value is written or whether to sort is up to the implementation. For example, implementations can discard pixels which have zero or close to zero alpha value to avoid sorting issues. + ## Cameras A camera defines the projection matrix that transforms from view to clip coordinates. The projection can be perspective or orthographic. Cameras are contained in nodes and thus can be transformed. Their world-space transformation matrix is used for calculating view-space transformation. diff --git a/specification/2.0/schema/material.pbrMetallicRoughness.schema.json b/specification/2.0/schema/material.pbrMetallicRoughness.schema.json index c797e591b2..91ecf7df52 100644 --- a/specification/2.0/schema/material.pbrMetallicRoughness.schema.json +++ b/specification/2.0/schema/material.pbrMetallicRoughness.schema.json @@ -15,12 +15,12 @@ "default": [ 1.0, 1.0, 1.0, 1.0 ], "minItems": 4, "maxItems": 4, - "gltf_detailedDescription": "The RGBA components of the base color of the material. The fourth component (A) is the opacity of the material. These values are linear." + "gltf_detailedDescription": "The RGBA components of the base color of the material. The fourth component (A) is the alpha coverage of the material. The `alphaMode` property specifies how alpha is interpreted. These values are linear." }, "baseColorTexture": { "allOf": [ { "$ref": "textureInfo.schema.json" } ], "description": "The base color texture.", - "gltf_detailedDescription": "The base color texture. This texture contains RGB(A) components in sRGB color space. The first three components (RGB) specify the base color of the material. If the fourth component (A) is present, it represents the opacity of the material. Otherwise, an opacity of 1.0 is assumed." + "gltf_detailedDescription": "The base color texture. This texture contains RGB(A) components in sRGB color space. The first three components (RGB) specify the base color of the material. If the fourth component (A) is present, it represents the alpha coverage of the material. Otherwise, an alpha of 1.0 is assumed. The `alphaMode` property specifies how alpha is interpreted. The stored texels must not be premultiplied." }, "metallicFactor": { "type": "number", diff --git a/specification/2.0/schema/material.schema.json b/specification/2.0/schema/material.schema.json index b73a88cea1..c4427b1e96 100644 --- a/specification/2.0/schema/material.schema.json +++ b/specification/2.0/schema/material.schema.json @@ -5,9 +5,9 @@ "description": "The material appearance of a primitive.", "allOf": [ { "$ref": "glTFChildOfRootProperty.schema.json" } ], "properties": { - "name": {}, - "extensions": {}, - "extras": {}, + "name": { }, + "extensions": { }, + "extras": { }, "pbrMetallicRoughness": { "allOf": [ { "$ref": "material.pbrMetallicRoughness.schema.json" } ], "description": "A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology." @@ -39,7 +39,30 @@ "default": [ 0.0, 0.0, 0.0 ], "description": "The emissive color of the material.", "gltf_detailedDescription": "The RGB components of the emissive color of the material. If an emissiveTexture is specified, this value is multiplied with the texel values." + }, + "alphaMode": { + "type": "string", + "enum": [ "OPAQUE", "MASK", "BLEND" ], + "default": "OPAQUE", + "description": "The alpha rendering mode of the material.", + "gltf_detailedDescription": "The material's alpha rendering mode enumeration specifying the interpretation of the alpha value of the main factor and texture. If the alpha mode is not specified, it defaults to `OPAQUE` where the alpha value is ignored and the rendered output is fully opaque. In `MASK` mode, the rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value. In `BLEND` mode, the alpha value is used to composite the source and destination areas. The rendered output is combined with the background using the normal painting operation (i.e. the Porter and Duff over operator)." + }, + "alphaCutoff": { + "type": "number", + "minimum": 0.0, + "default": 0.5, + "description": "The alpha cutoff value of the material.", + "gltf_detailedDescription": "This value specifies the cutoff threshold when in `MASK` mode. If the alpha value is greater than or equal to this value then it is rendered as fully opaque, otherwise, it is rendered as fully transparent. This value is ignored for other modes." + }, + "doubleSided": { + "type": "boolean", + "default": false, + "description": "Indicates whether a material is double sided.", + "gltf_detailedDescription": "Declares whether back-face culling should be disabled for this material." } + }, + "dependencies" : { + "alphaCutoff" : ["alphaMode"] }, "additionalProperties": false } \ No newline at end of file From 41284aef0c5f8dfcc1570e887c40dfc40e079aa2 Mon Sep 17 00:00:00 2001 From: Saurabh Bhatia Date: Thu, 30 Mar 2017 15:23:17 -0700 Subject: [PATCH 2/3] Updated double sided property description to include double sided lighting. --- specification/2.0/README.md | 7 +++++-- specification/2.0/schema/material.schema.json | 6 +++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/specification/2.0/README.md b/specification/2.0/README.md index 67e6ea2639..84f1de20e3 100644 --- a/specification/2.0/README.md +++ b/specification/2.0/README.md @@ -62,6 +62,7 @@ Copyright (C) 2013-2017 The Khronos Group Inc. All Rights Reserved. glTF is a tr * [Metallic-Roughness Material](#metallic-roughness-material) * [Additional Maps](#additional-maps) * [Alpha Coverage](#alpha-coverage) + * [Double Sided](#double-sided) * [Cameras](#cameras) * [Projection Matrices](#projection-matrices) * [Animations](#animations) @@ -1015,13 +1016,15 @@ The `alphaMode` property defines how the alpha value of the main factor and text When `alphaMode` is set to `MASK` the `alphaCutoff` property specifies the cutoff threshold. If the alpha value is greater than or equal to the `alphaCutoff` value then it is rendered as fully opaque, otherwise, it is rendered as fully transparent. `alphaCutoff` value is ignored for other modes. -The `doubleSided` property specified whether the material is double sided. - >**Implementation Note for Real-Time Rasterizers:** Real-time rasterizers typically use depth buffers and mesh sorting to support alpha modes. The following describe the expected behavior for these types of renderers. >* `OPAQUE` - A depth value is written for every pixel and mesh sorting is not required for correct output. >* `MASK` - A depth value is not written for a pixel that is discarded after the alpha test. A depth value is written for all other pixels. Mesh sorting is not required for correct output. >* `BLEND` - Support for this mode varies. There is no perfect and fast solution that works for all cases. Implementations should try to achieve the correct blending output for as many situations as possible. Whether depth value is written or whether to sort is up to the implementation. For example, implementations can discard pixels which have zero or close to zero alpha value to avoid sorting issues. +### Double Sided + +The `doubleSided` property specified whether the material is double sided. When this value is false, back-face culling is enabled. When this value is true, back-face culling is disabled and double sided lighting is enabled. The back-face must have its normals reversed before the lighting equation is evaluated. + ## Cameras A camera defines the projection matrix that transforms from view to clip coordinates. The projection can be perspective or orthographic. Cameras are contained in nodes and thus can be transformed. Their world-space transformation matrix is used for calculating view-space transformation. diff --git a/specification/2.0/schema/material.schema.json b/specification/2.0/schema/material.schema.json index c4427b1e96..a42c1545f0 100644 --- a/specification/2.0/schema/material.schema.json +++ b/specification/2.0/schema/material.schema.json @@ -52,13 +52,13 @@ "minimum": 0.0, "default": 0.5, "description": "The alpha cutoff value of the material.", - "gltf_detailedDescription": "This value specifies the cutoff threshold when in `MASK` mode. If the alpha value is greater than or equal to this value then it is rendered as fully opaque, otherwise, it is rendered as fully transparent. This value is ignored for other modes." + "gltf_detailedDescription": "Specifies the cutoff threshold when in `MASK` mode. If the alpha value is greater than or equal to this value then it is rendered as fully opaque, otherwise, it is rendered as fully transparent. This value is ignored for other modes." }, "doubleSided": { "type": "boolean", "default": false, - "description": "Indicates whether a material is double sided.", - "gltf_detailedDescription": "Declares whether back-face culling should be disabled for this material." + "description": "Specifies whether the material is double sided.", + "gltf_detailedDescription": "Specifies whether the material is double sided. When this value is false, back-face culling is enabled. When this value is true, back-face culling is disabled and double sided lighting is enabled. The back-face must have its normals reversed before the lighting equation is evaluated." } }, "dependencies" : { From a64e7a329853a800fa525256a84f1449fedea0e1 Mon Sep 17 00:00:00 2001 From: Saurabh Bhatia Date: Fri, 31 Mar 2017 10:14:56 -0700 Subject: [PATCH 3/3] fix typo --- specification/2.0/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/specification/2.0/README.md b/specification/2.0/README.md index 84f1de20e3..1eb72a0831 100644 --- a/specification/2.0/README.md +++ b/specification/2.0/README.md @@ -1023,7 +1023,7 @@ The `alphaMode` property defines how the alpha value of the main factor and text ### Double Sided -The `doubleSided` property specified whether the material is double sided. When this value is false, back-face culling is enabled. When this value is true, back-face culling is disabled and double sided lighting is enabled. The back-face must have its normals reversed before the lighting equation is evaluated. +The `doubleSided` property specifies whether the material is double sided. When this value is false, back-face culling is enabled. When this value is true, back-face culling is disabled and double sided lighting is enabled. The back-face must have its normals reversed before the lighting equation is evaluated. ## Cameras