From 75ad1fec05b2ce971ef64c45de736f6626ef98c3 Mon Sep 17 00:00:00 2001 From: Wasim Abbas Date: Mon, 18 Mar 2024 15:35:55 +0000 Subject: [PATCH 1/9] Add KHR_texture_astc extension --- .../2.0/Khronos/KHR_texture_astc/README.md | 253 ++++++++++++++++++ .../texture.KHR_texture_basisu.schema.json | 15 ++ 2 files changed, 268 insertions(+) create mode 100644 extensions/2.0/Khronos/KHR_texture_astc/README.md create mode 100644 extensions/2.0/Khronos/KHR_texture_astc/schema/texture.KHR_texture_basisu.schema.json diff --git a/extensions/2.0/Khronos/KHR_texture_astc/README.md b/extensions/2.0/Khronos/KHR_texture_astc/README.md new file mode 100644 index 0000000000..0c7e28352e --- /dev/null +++ b/extensions/2.0/Khronos/KHR_texture_astc/README.md @@ -0,0 +1,253 @@ + + +# KHR_texture_astc + +## Contributors + +- Wasim Abbas [@wasimabbas-arm](https://github.com/wasimabbas-arm) +- Jan-Harald Fredriksen [@janharaldfredriksen-arm](https://github.com/janharaldfredriksen-arm) +- Peter Harris [@solidpixel](https://github.com/solidpixel) +- Mark Callow [@MarkCallow](https://github.com/MarkCallow) + +Copyright 2023 The Khronos Group Inc. All Rights Reserved. glTF is a trademark of The Khronos Group Inc. +See [Appendix](#appendix-full-khronos-copyright-statement) for full Khronos Copyright Statement. + +## Status + +Draft + +## Dependencies + +Written against the glTF 2.0 spec. + +## Overview + +This extension adds the ability to specify textures using KTX v2 images with (ASTC compression)[https://github.com/ARM-software/astc-encoder/blob/main/Docs/FormatOverview.md]. An implementation of this extension can use such images as an alternative to the PNG or JPEG images available in glTF 2.0 for more efficient asset transmission, reducing GPU memory footprint, higher texture throughput and faster execution. + +When this extension is used, it's allowed to use value `image/astc` for the `mimeType` property of images that are referenced by the `source` property of `KHR_texture_astc` texture extension object. + +At runtime, engines can directly use the ktx images unlike EXT_texture_basisu which requires doing transcoding to other compressed formats. This also means you get support for all ASTC block formats and quality presets. + +## glTF Schema Updates + +The `KHR_texture_astc` extension is added to the `textures` object and specifies a `source` property that points to the index of the `image` which defines a reference to the KTX v2 image with ASTC compression. + +The following glTF will load `astc_image.ktx2` in clients that support this extension, and fall back to `image.png` otherwise. + +```json +{ + "asset": { + "version": "2.0" + }, + "extensionsUsed": [ + "KHR_texture_astc" + ], + "textures": [ + { + "source": 0, + "extensions": { + "KHR_texture_astc": { + "source": 1 + } + } + } + ], + "images": [ + { + "uri": "image.png" + }, + { + "uri": "astc_image.ktx2" + } + ] +} +``` + +When used in the glTF Binary (GLB) format the `image` that points to the KTX v2 resource uses the `mimeType` value of `image/ktx2`. + +```json +{ + "asset": { + "version": "2.0" + }, + "extensionsUsed": [ + "KHR_texture_astc" + ], + "textures": [ + { + "source": 0, + "extensions": { + "KHR_texture_astc": { + "source": 1 + } + } + } + ], + "images": [ + { + "mimeType": "image/png", + "bufferView": 1 + }, + { + "mimeType": "image/ktx2", + "bufferView": 2 + } + ] +} +``` + +### Using Without a Fallback + +To use KTX v2 image with ASTC compression without a fallback, define `KHR_texture_astc` in both `extensionsUsed` and `extensionsRequired`. The `texture` object will then have its `source` property omitted as shown below. + +```json +{ + "asset": { + "version": "2.0" + }, + "extensionsUsed": [ + "KHR_texture_astc" + ], + "extensionsRequired": [ + "KHR_texture_astc" + ], + "textures": [ + { + "extensions": { + "KHR_texture_astc": { + "source": 0 + } + } + } + ], + "images": [ + { + "uri": "astc_image.ktx2" + } + ] +} +``` + +### JSON Schema + +[texture.KHR_texture_astc.schema.json](schema/texture.KHR_texture_astc.schema.json) + +## KTX v2 Images with Astc compression + +To cover a broad range of use cases, this extension allows different ASTC block sizes as well as LDR, HDR and 3D images. These can be determined from the vkFormat of the KTX image. + +For the purposes of this extension, the following texture types are defined: + +- **RGB:** A texture that uses red, green, and blue channels. Alpha channel is either assumed to be always equal to `1.0` (`255`) or unused and not sampled at runtime. Such textures MAY be encoded with the sRGB transfer function. + > **Note:** RGB textures from the core glTF 2.0 specification include: + > - `baseColorTexture` (opaque case) + > - `normalTexture` + > - `emissiveTexture` + > - `metallicRoughnessTexture` (when combined with `occlusionTexture`, otherwise red channel is ignored) + +- **RGBA:** A texture that uses all four channels. Such textures MAY be encoded with the sRGB transfer function (not applied to Alpha). + > **Note:** RGBA textures from the core glTF 2.0 specification include: + > - `baseColorTexture` (non-opaque case) + +- **Red:** A texture that uses only red channel. All other channels are unused and their values are not sampled at runtime. Such textures MUST NOT be encoded with the sRGB transfer function. + > **Note:** Red textures from the core glTF 2.0 specification include: + > - `occlusionTexture` (standalone) + +- **Luminance-Alpha:** A texture that uses only Luminance and Alpha channels. To sample these textures use `.ga` swizzle in your shaders. Such textures MUST NOT be encoded with sRGB transfer function. + > **Note:** The core glTF 2.0 specification has no examples of luminance-alpha textures. + +### KTX header fields for ASTC payloads + - `supercompressionScheme` MUST be `0` (None). + - ASTC HDR vs LDR as well as block sizes can be determined from the vkFormat of the image + - DFD `colorModel` MUST be `KHR_DF_MODEL_ASTC`. + - DFD `channelId` MUST be `KHR_DF_CHANNEL_ASTC_DATA`. + +### Additional requirements + +Regardless of the format used, these additional restrictions apply for compatibility reasons: + +- Swizzling metadata (`KTXswizzle`) MUST be `rgba` or omitted. +- Orientation metadata (`KTXorientation`) MUST be `rd` or omitted. +- Color space information in the DFD MUST match the expected usage, namely: + - For textures with **color data** (e.g., base color maps), + - `colorPrimaries` MUST be `KHR_DF_PRIMARIES_BT709`; + - `transferFunction` MUST be `KHR_DF_TRANSFER_SRGB`. + - For textures with **non-color data** (e.g., normal maps), + - `colorPrimaries` MUST be `KHR_DF_PRIMARIES_UNSPECIFIED`; + - `transferFunction` MUST be `KHR_DF_TRANSFER_LINEAR`. +- When a texture refers to a sampler with mipmap minification, the KTX image MUST contain a full mip pyramid. +- When a texture referencing a KTX v2 image with ASTC compression is used for glTF 2.0 material maps (both color and non-color), the KTX v2 image MUST be of **2D** type as defined in the KTX v2 Specification, Section 4.1. +- `KHR_DF_FLAG_ALPHA_PREMULTIPLIED` flag MUST NOT be set unless the material's specification requires premultiplied alpha. + +## Known Implementations + +Authoring: + +- [KTX Reference Software](https://github.com/KhronosGroup/KTX-Software/) + +Viewing: + + + +## Resources + +[KTX File Format Specification, version 2](https://github.khronos.org/KTX-Specification/) + +[KTX Reference Software](https://github.com/KhronosGroup/KTX-Software/) + +[ASTC encoder](https://github.com/ARM-software/astc-encoder) + +## Appendix: Full Khronos Copyright Statement + +Copyright 2023 The Khronos Group Inc. + +Some parts of this Specification are purely informative and do not define requirements +necessary for compliance and so are outside the Scope of this Specification. These +parts of the Specification are marked as being non-normative, or identified as +**Implementation Notes**. + +Where this Specification includes normative references to external documents, only the +specifically identified sections and functionality of those external documents are in +Scope. Requirements defined by external documents not created by Khronos may contain +contributions from non-members of Khronos not covered by the Khronos Intellectual +Property Rights Policy. + +This specification is protected by copyright laws and contains material proprietary +to Khronos. Except as described by these terms, it or any components +may not be reproduced, republished, distributed, transmitted, displayed, broadcast +or otherwise exploited in any manner without the express prior written permission +of Khronos. + +This specification has been created under the Khronos Intellectual Property Rights +Policy, which is Attachment A of the Khronos Group Membership Agreement available at +www.khronos.org/files/member_agreement.pdf. Khronos grants a conditional +copyright license to use and reproduce the unmodified specification for any purpose, +without fee or royalty, EXCEPT no licenses to any patent, trademark or other +intellectual property rights are granted under these terms. Parties desiring to +implement the specification and make use of Khronos trademarks in relation to that +implementation, and receive reciprocal patent license protection under the Khronos +IP Policy must become Adopters and confirm the implementation as conformant under +the process defined by Khronos for this specification; +see https://www.khronos.org/adopters. + +Khronos makes no, and expressly disclaims any, representations or warranties, +express or implied, regarding this specification, including, without limitation: +merchantability, fitness for a particular purpose, non-infringement of any +intellectual property, correctness, accuracy, completeness, timeliness, and +reliability. Under no circumstances will Khronos, or any of its Promoters, +Contributors or Members, or their respective partners, officers, directors, +employees, agents or representatives be liable for any damages, whether direct, +indirect, special or consequential damages for lost revenues, lost profits, or +otherwise, arising from or in connection with these materials. + +Khronos® and Vulkan® are registered trademarks, and ANARI™, WebGL™, glTF™, NNEF™, OpenVX™, +SPIR™, SPIR-V™, SYCL™, OpenVG™ and 3D Commerce™ are trademarks of The Khronos Group Inc. +OpenXR™ is a trademark owned by The Khronos Group Inc. and is registered as a trademark in +China, the European Union, Japan and the United Kingdom. OpenCL™ is a trademark of Apple Inc. +and OpenGL® is a registered trademark and the OpenGL ES™ and OpenGL SC™ logos are trademarks +of Hewlett Packard Enterprise used under license by Khronos. ASTC is a trademark of +ARM Holdings PLC. All other product names, trademarks, and/or company names are used solely +for identification and belong to their respective owners. diff --git a/extensions/2.0/Khronos/KHR_texture_astc/schema/texture.KHR_texture_basisu.schema.json b/extensions/2.0/Khronos/KHR_texture_astc/schema/texture.KHR_texture_basisu.schema.json new file mode 100644 index 0000000000..052ff27a3f --- /dev/null +++ b/extensions/2.0/Khronos/KHR_texture_astc/schema/texture.KHR_texture_basisu.schema.json @@ -0,0 +1,15 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema", + "title": "KHR_texture_astc glTF Texture Extension", + "type": "object", + "description": "glTF extension to specify textures using the KTX v2 images with astc compression.", + "allOf": [ { "$ref": "glTFProperty.schema.json" } ], + "properties": { + "source": { + "allOf": [ { "$ref": "glTFid.schema.json" } ], + "description": "The index of the image which points to a KTX v2 resource with astc compression." + }, + "extensions": {}, + "extras": {} + } +} From 0b5690b76bd09839a9a3ce1dfd286f4c4adc4b41 Mon Sep 17 00:00:00 2001 From: Wasim Abbas Date: Wed, 20 Mar 2024 10:00:48 +0000 Subject: [PATCH 2/9] Add WebGL astc extension restriction of npot textures back in --- extensions/2.0/Khronos/KHR_texture_astc/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/extensions/2.0/Khronos/KHR_texture_astc/README.md b/extensions/2.0/Khronos/KHR_texture_astc/README.md index 0c7e28352e..3fb715c1f1 100644 --- a/extensions/2.0/Khronos/KHR_texture_astc/README.md +++ b/extensions/2.0/Khronos/KHR_texture_astc/README.md @@ -178,6 +178,7 @@ Regardless of the format used, these additional restrictions apply for compatibi - For textures with **non-color data** (e.g., normal maps), - `colorPrimaries` MUST be `KHR_DF_PRIMARIES_UNSPECIFIED`; - `transferFunction` MUST be `KHR_DF_TRANSFER_LINEAR`. +- `pixelWidth` and `pixelHeight` MUST be multiples of 4. - When a texture refers to a sampler with mipmap minification, the KTX image MUST contain a full mip pyramid. - When a texture referencing a KTX v2 image with ASTC compression is used for glTF 2.0 material maps (both color and non-color), the KTX v2 image MUST be of **2D** type as defined in the KTX v2 Specification, Section 4.1. - `KHR_DF_FLAG_ALPHA_PREMULTIPLIED` flag MUST NOT be set unless the material's specification requires premultiplied alpha. From 94e429323ad4c901cc31a2d9deb56e18d718fe21 Mon Sep 17 00:00:00 2001 From: Wasim Abbas Date: Wed, 24 Jul 2024 16:54:45 +0100 Subject: [PATCH 3/9] Fix review comments --- extensions/2.0/Khronos/KHR_texture_astc/README.md | 4 ++-- .../schema/texture.KHR_texture_basisu.schema.json | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/extensions/2.0/Khronos/KHR_texture_astc/README.md b/extensions/2.0/Khronos/KHR_texture_astc/README.md index 3fb715c1f1..0513fdbd97 100644 --- a/extensions/2.0/Khronos/KHR_texture_astc/README.md +++ b/extensions/2.0/Khronos/KHR_texture_astc/README.md @@ -27,7 +27,7 @@ Written against the glTF 2.0 spec. This extension adds the ability to specify textures using KTX v2 images with (ASTC compression)[https://github.com/ARM-software/astc-encoder/blob/main/Docs/FormatOverview.md]. An implementation of this extension can use such images as an alternative to the PNG or JPEG images available in glTF 2.0 for more efficient asset transmission, reducing GPU memory footprint, higher texture throughput and faster execution. -When this extension is used, it's allowed to use value `image/astc` for the `mimeType` property of images that are referenced by the `source` property of `KHR_texture_astc` texture extension object. +When this extension is used, it's allowed to use value `image/ktx2` for the `mimeType` property of images that are referenced by the `source` property of `KHR_texture_astc` texture extension object. At runtime, engines can directly use the ktx images unlike EXT_texture_basisu which requires doing transcoding to other compressed formats. This also means you get support for all ASTC block formats and quality presets. @@ -137,7 +137,7 @@ To use KTX v2 image with ASTC compression without a fallback, define `KHR_textur ## KTX v2 Images with Astc compression -To cover a broad range of use cases, this extension allows different ASTC block sizes as well as LDR, HDR and 3D images. These can be determined from the vkFormat of the KTX image. +To cover a broad range of use cases, this extension allows different ASTC block sizes as well as LDR, HDR and 3D images. These can be determined from the VkFormat of the KTX image. For the purposes of this extension, the following texture types are defined: diff --git a/extensions/2.0/Khronos/KHR_texture_astc/schema/texture.KHR_texture_basisu.schema.json b/extensions/2.0/Khronos/KHR_texture_astc/schema/texture.KHR_texture_basisu.schema.json index 052ff27a3f..d716c88eb8 100644 --- a/extensions/2.0/Khronos/KHR_texture_astc/schema/texture.KHR_texture_basisu.schema.json +++ b/extensions/2.0/Khronos/KHR_texture_astc/schema/texture.KHR_texture_basisu.schema.json @@ -2,12 +2,12 @@ "$schema": "http://json-schema.org/draft-04/schema", "title": "KHR_texture_astc glTF Texture Extension", "type": "object", - "description": "glTF extension to specify textures using the KTX v2 images with astc compression.", + "description": "glTF extension to specify textures using the KTX v2 images with ASTC compression.", "allOf": [ { "$ref": "glTFProperty.schema.json" } ], "properties": { "source": { "allOf": [ { "$ref": "glTFid.schema.json" } ], - "description": "The index of the image which points to a KTX v2 resource with astc compression." + "description": "The index of the image which points to a KTX v2 resource with ASTC compression." }, "extensions": {}, "extras": {} From b7b6dd2397b7df15f740e40265650c74abb0cb77 Mon Sep 17 00:00:00 2001 From: Wasim Abbas Date: Sat, 7 Sep 2024 16:13:36 +0100 Subject: [PATCH 4/9] Review comments --- .../2.0/Khronos/KHR_texture_astc/README.md | 23 ++++++++++++------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/extensions/2.0/Khronos/KHR_texture_astc/README.md b/extensions/2.0/Khronos/KHR_texture_astc/README.md index 0513fdbd97..84a15deeca 100644 --- a/extensions/2.0/Khronos/KHR_texture_astc/README.md +++ b/extensions/2.0/Khronos/KHR_texture_astc/README.md @@ -25,15 +25,15 @@ Written against the glTF 2.0 spec. ## Overview -This extension adds the ability to specify textures using KTX v2 images with (ASTC compression)[https://github.com/ARM-software/astc-encoder/blob/main/Docs/FormatOverview.md]. An implementation of this extension can use such images as an alternative to the PNG or JPEG images available in glTF 2.0 for more efficient asset transmission, reducing GPU memory footprint, higher texture throughput and faster execution. +This extension adds the ability to specify textures using (ASTC compressed images)[https://github.com/ARM-software/astc-encoder/blob/main/Docs/FormatOverview.md] in KTX v2 containers. An implementation of this extension can use such images as an alternative to the PNG or JPEG images available in glTF 2.0 for more efficient asset transmission, reducing GPU memory footprint, higher texture throughput and faster execution. When this extension is used, it's allowed to use value `image/ktx2` for the `mimeType` property of images that are referenced by the `source` property of `KHR_texture_astc` texture extension object. -At runtime, engines can directly use the ktx images unlike EXT_texture_basisu which requires doing transcoding to other compressed formats. This also means you get support for all ASTC block formats and quality presets. +At runtime, engines can directly use the ktx images unlike EXT_texture_basisu which requires transcoding to other compressed formats. This also means you get support for all ASTC block formats and quality presets. ## glTF Schema Updates -The `KHR_texture_astc` extension is added to the `textures` object and specifies a `source` property that points to the index of the `image` which defines a reference to the KTX v2 image with ASTC compression. +The `KHR_texture_astc` extension is added to the `textures` object and specifies a `source` property that points to the index of the `image` which defines a reference to the KTX v2 file with the ASTC compressed image. The following glTF will load `astc_image.ktx2` in clients that support this extension, and fall back to `image.png` otherwise. @@ -137,7 +137,7 @@ To use KTX v2 image with ASTC compression without a fallback, define `KHR_textur ## KTX v2 Images with Astc compression -To cover a broad range of use cases, this extension allows different ASTC block sizes as well as LDR, HDR and 3D images. These can be determined from the VkFormat of the KTX image. +To cover a broad range of use cases, this extension allows different ASTC block sizes as well as LDR, HDR and 3D images. These can be determined from the vkFormat of the KTX image. For the purposes of this extension, the following texture types are defined: @@ -156,12 +156,20 @@ For the purposes of this extension, the following texture types are defined: > **Note:** Red textures from the core glTF 2.0 specification include: > - `occlusionTexture` (standalone) -- **Luminance-Alpha:** A texture that uses only Luminance and Alpha channels. To sample these textures use `.ga` swizzle in your shaders. Such textures MUST NOT be encoded with sRGB transfer function. +- **Luminance-Alpha:** A texture that uses only Luminance and Alpha channels. To sample these textures use `.ga` swizzle in your shaders. Such textures MAY be encoded with sRGB transfer function. > **Note:** The core glTF 2.0 specification has no examples of luminance-alpha textures. +If the texture type is `normalTexture` the output will be a two component X+Y normal map stored as (RGB=X, A=Y). The Z component can be recovered programmatically in shader code by using the equation: + +```GLSL + nml.xy = texture(...).ga; // Load in [0,1] + nml.xy = nml.xy * 2.0 - 1.0; // Unpack to [-1,1] + nml.z = sqrt(1 - dot(nml.xy, nml.xy)); // Compute Z +``` + ### KTX header fields for ASTC payloads - `supercompressionScheme` MUST be `0` (None). - - ASTC HDR vs LDR as well as block sizes can be determined from the vkFormat of the image + - ASTC HDR vs LDR as well as block sizes can be determined from the vkFormat of the KTX image - DFD `colorModel` MUST be `KHR_DF_MODEL_ASTC`. - DFD `channelId` MUST be `KHR_DF_CHANNEL_ASTC_DATA`. @@ -169,7 +177,6 @@ For the purposes of this extension, the following texture types are defined: Regardless of the format used, these additional restrictions apply for compatibility reasons: -- Swizzling metadata (`KTXswizzle`) MUST be `rgba` or omitted. - Orientation metadata (`KTXorientation`) MUST be `rd` or omitted. - Color space information in the DFD MUST match the expected usage, namely: - For textures with **color data** (e.g., base color maps), @@ -180,7 +187,7 @@ Regardless of the format used, these additional restrictions apply for compatibi - `transferFunction` MUST be `KHR_DF_TRANSFER_LINEAR`. - `pixelWidth` and `pixelHeight` MUST be multiples of 4. - When a texture refers to a sampler with mipmap minification, the KTX image MUST contain a full mip pyramid. -- When a texture referencing a KTX v2 image with ASTC compression is used for glTF 2.0 material maps (both color and non-color), the KTX v2 image MUST be of **2D** type as defined in the KTX v2 Specification, Section 4.1. +- When a texture referencing a KTX v2 file with ASTC compressed image is used for glTF 2.0 material maps (both color and non-color), the KTX v2 image MUST be of **2D** type as defined in the KTX v2 Specification, Section 4.1. - `KHR_DF_FLAG_ALPHA_PREMULTIPLIED` flag MUST NOT be set unless the material's specification requires premultiplied alpha. ## Known Implementations From 3a34159967615d086a76dd033f6ba7d83f625e18 Mon Sep 17 00:00:00 2001 From: Wasim Abbas Date: Tue, 19 Nov 2024 12:04:55 +0000 Subject: [PATCH 5/9] Fix review comments --- extensions/2.0/Khronos/KHR_texture_astc/README.md | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/extensions/2.0/Khronos/KHR_texture_astc/README.md b/extensions/2.0/Khronos/KHR_texture_astc/README.md index 84a15deeca..ef93b2edda 100644 --- a/extensions/2.0/Khronos/KHR_texture_astc/README.md +++ b/extensions/2.0/Khronos/KHR_texture_astc/README.md @@ -11,6 +11,7 @@ SPDX-License-Identifier: LicenseRef-KhronosSpecCopyright - Jan-Harald Fredriksen [@janharaldfredriksen-arm](https://github.com/janharaldfredriksen-arm) - Peter Harris [@solidpixel](https://github.com/solidpixel) - Mark Callow [@MarkCallow](https://github.com/MarkCallow) +- Alexey Knyazev [@lexaknyazev](https://github.com/lexaknyazev) Copyright 2023 The Khronos Group Inc. All Rights Reserved. glTF is a trademark of The Khronos Group Inc. See [Appendix](#appendix-full-khronos-copyright-statement) for full Khronos Copyright Statement. @@ -29,7 +30,7 @@ This extension adds the ability to specify textures using (ASTC compressed image When this extension is used, it's allowed to use value `image/ktx2` for the `mimeType` property of images that are referenced by the `source` property of `KHR_texture_astc` texture extension object. -At runtime, engines can directly use the ktx images unlike EXT_texture_basisu which requires transcoding to other compressed formats. This also means you get support for all ASTC block formats and quality presets. +At runtime, engines can directly use the ktx images unlike KHR_texture_basisu which requires transcoding to other compressed formats. This also means you get support for all ASTC block formats and quality presets. ## glTF Schema Updates @@ -135,7 +136,7 @@ To use KTX v2 image with ASTC compression without a fallback, define `KHR_textur [texture.KHR_texture_astc.schema.json](schema/texture.KHR_texture_astc.schema.json) -## KTX v2 Images with Astc compression +## KTX v2 files with ASTC compression To cover a broad range of use cases, this extension allows different ASTC block sizes as well as LDR, HDR and 3D images. These can be determined from the vkFormat of the KTX image. @@ -156,8 +157,8 @@ For the purposes of this extension, the following texture types are defined: > **Note:** Red textures from the core glTF 2.0 specification include: > - `occlusionTexture` (standalone) -- **Luminance-Alpha:** A texture that uses only Luminance and Alpha channels. To sample these textures use `.ga` swizzle in your shaders. Such textures MAY be encoded with sRGB transfer function. - > **Note:** The core glTF 2.0 specification has no examples of luminance-alpha textures. +- **Red-Green:** A texture that uses only red and green channels. Blue and Alpha channels are unused and their values are not sampled at runtime. Such textures MUST NOT be encoded with sRGB transfer function. + > **Note:** The core glTF 2.0 specification has no examples of red-green textures. If the texture type is `normalTexture` the output will be a two component X+Y normal map stored as (RGB=X, A=Y). The Z component can be recovered programmatically in shader code by using the equation: @@ -168,7 +169,6 @@ If the texture type is `normalTexture` the output will be a two component X+Y no ``` ### KTX header fields for ASTC payloads - - `supercompressionScheme` MUST be `0` (None). - ASTC HDR vs LDR as well as block sizes can be determined from the vkFormat of the KTX image - DFD `colorModel` MUST be `KHR_DF_MODEL_ASTC`. - DFD `channelId` MUST be `KHR_DF_CHANNEL_ASTC_DATA`. @@ -185,7 +185,6 @@ Regardless of the format used, these additional restrictions apply for compatibi - For textures with **non-color data** (e.g., normal maps), - `colorPrimaries` MUST be `KHR_DF_PRIMARIES_UNSPECIFIED`; - `transferFunction` MUST be `KHR_DF_TRANSFER_LINEAR`. -- `pixelWidth` and `pixelHeight` MUST be multiples of 4. - When a texture refers to a sampler with mipmap minification, the KTX image MUST contain a full mip pyramid. - When a texture referencing a KTX v2 file with ASTC compressed image is used for glTF 2.0 material maps (both color and non-color), the KTX v2 image MUST be of **2D** type as defined in the KTX v2 Specification, Section 4.1. - `KHR_DF_FLAG_ALPHA_PREMULTIPLIED` flag MUST NOT be set unless the material's specification requires premultiplied alpha. From 8781d2296877799387f293c4ebc3da6bd0b9a254 Mon Sep 17 00:00:00 2001 From: Wasim Abbas Date: Tue, 19 Nov 2024 17:47:26 +0000 Subject: [PATCH 6/9] Remove references to HDR and 3D --- .../2.0/Khronos/KHR_texture_astc/README.md | 24 ++----------------- 1 file changed, 2 insertions(+), 22 deletions(-) diff --git a/extensions/2.0/Khronos/KHR_texture_astc/README.md b/extensions/2.0/Khronos/KHR_texture_astc/README.md index ef93b2edda..e1f2e22023 100644 --- a/extensions/2.0/Khronos/KHR_texture_astc/README.md +++ b/extensions/2.0/Khronos/KHR_texture_astc/README.md @@ -138,27 +138,7 @@ To use KTX v2 image with ASTC compression without a fallback, define `KHR_textur ## KTX v2 files with ASTC compression -To cover a broad range of use cases, this extension allows different ASTC block sizes as well as LDR, HDR and 3D images. These can be determined from the vkFormat of the KTX image. - -For the purposes of this extension, the following texture types are defined: - -- **RGB:** A texture that uses red, green, and blue channels. Alpha channel is either assumed to be always equal to `1.0` (`255`) or unused and not sampled at runtime. Such textures MAY be encoded with the sRGB transfer function. - > **Note:** RGB textures from the core glTF 2.0 specification include: - > - `baseColorTexture` (opaque case) - > - `normalTexture` - > - `emissiveTexture` - > - `metallicRoughnessTexture` (when combined with `occlusionTexture`, otherwise red channel is ignored) - -- **RGBA:** A texture that uses all four channels. Such textures MAY be encoded with the sRGB transfer function (not applied to Alpha). - > **Note:** RGBA textures from the core glTF 2.0 specification include: - > - `baseColorTexture` (non-opaque case) - -- **Red:** A texture that uses only red channel. All other channels are unused and their values are not sampled at runtime. Such textures MUST NOT be encoded with the sRGB transfer function. - > **Note:** Red textures from the core glTF 2.0 specification include: - > - `occlusionTexture` (standalone) - -- **Red-Green:** A texture that uses only red and green channels. Blue and Alpha channels are unused and their values are not sampled at runtime. Such textures MUST NOT be encoded with sRGB transfer function. - > **Note:** The core glTF 2.0 specification has no examples of red-green textures. +To cover a broad range of use cases, this extension allows different ASTC block sizes for LDR image types while HDR and 3D ASTC images are not supported. These can be determined from the vkFormat of the KTX image. If the texture type is `normalTexture` the output will be a two component X+Y normal map stored as (RGB=X, A=Y). The Z component can be recovered programmatically in shader code by using the equation: @@ -169,7 +149,7 @@ If the texture type is `normalTexture` the output will be a two component X+Y no ``` ### KTX header fields for ASTC payloads - - ASTC HDR vs LDR as well as block sizes can be determined from the vkFormat of the KTX image + - ASTC block sizes can be determined from the vkFormat of the KTX image. It will always be an LDR ASTC image. - DFD `colorModel` MUST be `KHR_DF_MODEL_ASTC`. - DFD `channelId` MUST be `KHR_DF_CHANNEL_ASTC_DATA`. From cac347078219383aa212796fc29b346e4d3e39be Mon Sep 17 00:00:00 2001 From: Wasim Abbas Date: Thu, 21 Nov 2024 12:31:29 +0000 Subject: [PATCH 7/9] Answer review comments --- extensions/2.0/Khronos/KHR_texture_astc/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extensions/2.0/Khronos/KHR_texture_astc/README.md b/extensions/2.0/Khronos/KHR_texture_astc/README.md index e1f2e22023..a124494b89 100644 --- a/extensions/2.0/Khronos/KHR_texture_astc/README.md +++ b/extensions/2.0/Khronos/KHR_texture_astc/README.md @@ -13,7 +13,7 @@ SPDX-License-Identifier: LicenseRef-KhronosSpecCopyright - Mark Callow [@MarkCallow](https://github.com/MarkCallow) - Alexey Knyazev [@lexaknyazev](https://github.com/lexaknyazev) -Copyright 2023 The Khronos Group Inc. All Rights Reserved. glTF is a trademark of The Khronos Group Inc. +Copyright 2024 The Khronos Group Inc. See [Appendix](#appendix-full-khronos-copyright-statement) for full Khronos Copyright Statement. ## Status From 23b4a73ba424be4b053adb2801d4b0d4d4d5331f Mon Sep 17 00:00:00 2001 From: Wasim Abbas Date: Thu, 21 Nov 2024 15:34:56 +0000 Subject: [PATCH 8/9] Remove 2-component normal texture restriction --- extensions/2.0/Khronos/KHR_texture_astc/README.md | 8 -------- 1 file changed, 8 deletions(-) diff --git a/extensions/2.0/Khronos/KHR_texture_astc/README.md b/extensions/2.0/Khronos/KHR_texture_astc/README.md index a124494b89..6d216d98d5 100644 --- a/extensions/2.0/Khronos/KHR_texture_astc/README.md +++ b/extensions/2.0/Khronos/KHR_texture_astc/README.md @@ -140,14 +140,6 @@ To use KTX v2 image with ASTC compression without a fallback, define `KHR_textur To cover a broad range of use cases, this extension allows different ASTC block sizes for LDR image types while HDR and 3D ASTC images are not supported. These can be determined from the vkFormat of the KTX image. -If the texture type is `normalTexture` the output will be a two component X+Y normal map stored as (RGB=X, A=Y). The Z component can be recovered programmatically in shader code by using the equation: - -```GLSL - nml.xy = texture(...).ga; // Load in [0,1] - nml.xy = nml.xy * 2.0 - 1.0; // Unpack to [-1,1] - nml.z = sqrt(1 - dot(nml.xy, nml.xy)); // Compute Z -``` - ### KTX header fields for ASTC payloads - ASTC block sizes can be determined from the vkFormat of the KTX image. It will always be an LDR ASTC image. - DFD `colorModel` MUST be `KHR_DF_MODEL_ASTC`. From b5717f9ffc6285701a87791f68f42d9d47712430 Mon Sep 17 00:00:00 2001 From: Wasim Abbas Date: Thu, 21 Nov 2024 16:20:23 +0000 Subject: [PATCH 9/9] Change overview wording and rename schema --- extensions/2.0/Khronos/KHR_texture_astc/README.md | 8 ++++++-- ...u.schema.json => texture.KHR_texture_astc.schema.json} | 0 2 files changed, 6 insertions(+), 2 deletions(-) rename extensions/2.0/Khronos/KHR_texture_astc/schema/{texture.KHR_texture_basisu.schema.json => texture.KHR_texture_astc.schema.json} (100%) diff --git a/extensions/2.0/Khronos/KHR_texture_astc/README.md b/extensions/2.0/Khronos/KHR_texture_astc/README.md index 6d216d98d5..edc2eb908d 100644 --- a/extensions/2.0/Khronos/KHR_texture_astc/README.md +++ b/extensions/2.0/Khronos/KHR_texture_astc/README.md @@ -30,7 +30,9 @@ This extension adds the ability to specify textures using (ASTC compressed image When this extension is used, it's allowed to use value `image/ktx2` for the `mimeType` property of images that are referenced by the `source` property of `KHR_texture_astc` texture extension object. -At runtime, engines can directly use the ktx images unlike KHR_texture_basisu which requires transcoding to other compressed formats. This also means you get support for all ASTC block formats and quality presets. +When running on supported platforms, engines can directly upload ASTC data without transcoding it to other compressed formats. This means that all ASTC block sizes and quality presets are supported unlike other texture extensions that focus on portability of compressed texture payloads. + +Platforms that do not have hardware ASTC support would have to either use other texture sources or decompress ASTC data manually. ## glTF Schema Updates @@ -165,10 +167,12 @@ Regardless of the format used, these additional restrictions apply for compatibi Authoring: -- [KTX Reference Software](https://github.com/KhronosGroup/KTX-Software/) +TBA + Viewing: +TBA ## Resources diff --git a/extensions/2.0/Khronos/KHR_texture_astc/schema/texture.KHR_texture_basisu.schema.json b/extensions/2.0/Khronos/KHR_texture_astc/schema/texture.KHR_texture_astc.schema.json similarity index 100% rename from extensions/2.0/Khronos/KHR_texture_astc/schema/texture.KHR_texture_basisu.schema.json rename to extensions/2.0/Khronos/KHR_texture_astc/schema/texture.KHR_texture_astc.schema.json