From eecc9f00bea3a228b3db8dab294e9baadb156f61 Mon Sep 17 00:00:00 2001 From: Ben Houston Date: Sun, 22 Oct 2023 14:20:36 -0400 Subject: [PATCH 1/7] first draft of bump extension. --- .../2.0/Vendor/EXT_materials_bump/README.md | 128 ++++++++++++++++++ .../material.KHR_materials_bump.schema.json | 24 ++++ 2 files changed, 152 insertions(+) create mode 100644 extensions/2.0/Vendor/EXT_materials_bump/README.md create mode 100644 extensions/2.0/Vendor/EXT_materials_bump/schema/material.KHR_materials_bump.schema.json diff --git a/extensions/2.0/Vendor/EXT_materials_bump/README.md b/extensions/2.0/Vendor/EXT_materials_bump/README.md new file mode 100644 index 0000000000..8e96b13584 --- /dev/null +++ b/extensions/2.0/Vendor/EXT_materials_bump/README.md @@ -0,0 +1,128 @@ +# EXT\_materials\_bump + +## Contributors + +- Ben Houston, Threekit [@bhouston](https://github.com/bhouston) + +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, Ratified by the Khronos Group + +## Dependencies + +Written against the glTF 2.0 spec. + +## Exclusions + +- This extension must not be used on a material that also uses `KHR_materials_pbrSpecularGlossiness`. +- This extension must not be used on a material that also uses `KHR_materials_unlit`. + +## Overview + +This extension adds one parameters to the metallic-roughness material: `bump`. + +`bump` allows users to perturb the surface normal via a bump map. The bump map is a grayscale texture, where the value of each texel represents the height of the surface at that texel. The height is then used to perturb the normal direction. + +## Extending Materials + +The `KHR_materials_bump` extension can be specified in the `extensions` property of the material: + +```json +{ + "materials": [ + { + "extensions": { + "KHR_materials_bump": { + "bumpFactor": 0.5 + } + } + } + ] +} +``` + +Factor and texture are combined by multiplication to describe a single value. + +| |Type|Description|Required| +|-|----|-----------|--------| +| **bumpFactor** | `number` | The strength of the specular reflection. | No, default: `1.0`| +| **bumpTexture** | [`textureInfo`](https://www.khronos.org/registry/glTF/specs/2.0/glTF-2.0.html#reference-textureinfo) | A texture that defines the strength of the specular reflection, stored in the alpha (`A`) channel. This will be multiplied by bumpFactor. | No | + +The `bump` parameters affect the normal used in `dielectric_brdf` of the glTF 2.0 metallic-roughness material. + +## Implementation + +*This section is non-normative.* + +The `bump` parameter is used to perturb the normal direction. The normal direction is perturbed by the value of the bump map at the texel corresponding to the fragment. The perturbed normal is then used in the `dielectric_brdf` function of the glTF 2.0 metallic-roughness material. + +** TODO Derive Normal from Bump ** + +In order to properly blend the bump map with a normal map, please follow the recommendation of https://blog.selfshadow.com/publications/blending-in-detail/. + +```glsl +vec3 t = originalNormal.xyz * vec3( 2, 2, 2 ) + vec3( -1, -1, 0 ); +vec3 u = bumpNormal.xyz * vec3( -2, -2, 2 ) + vec3( 1, 1, -1 ); +vec3 r = normalize( t * dot(t, u) / t.z - u ); // not required if t and u are pre-normalized +vec3 blendedNormal = r * 0.5 + 0.5; +``` + +## Schema + +- [material.KHR_materials_bump.schema.json](schema/material.KHR_materials_bump.schema.json) + +## 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. + +Vulkan is a registered trademark and Khronos, OpenXR, SPIR, SPIR-V, SYCL, WebGL, +WebCL, OpenVX, OpenVG, EGL, COLLADA, glTF, NNEF, OpenKODE, OpenKCAM, StreamInput, +OpenWF, OpenSL ES, OpenMAX, OpenMAX AL, OpenMAX IL, OpenMAX DL, OpenML and DevU are +trademarks of The Khronos Group Inc. ASTC is a trademark of ARM Holdings PLC, +OpenCL is a trademark of Apple Inc. and OpenGL and OpenML are registered trademarks +and the OpenGL ES and OpenGL SC logos are trademarks of Silicon Graphics +International used under license by Khronos. 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/Vendor/EXT_materials_bump/schema/material.KHR_materials_bump.schema.json b/extensions/2.0/Vendor/EXT_materials_bump/schema/material.KHR_materials_bump.schema.json new file mode 100644 index 0000000000..1bbeff5fe2 --- /dev/null +++ b/extensions/2.0/Vendor/EXT_materials_bump/schema/material.KHR_materials_bump.schema.json @@ -0,0 +1,24 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema", + "title": "KHR_materials_bump glTF Material Extension", + "type": "object", + "description": "glTF extension that defines a bump which perturbs the surface normal.", + "allOf": [ { "$ref": "glTFProperty.schema.json" } ], + "properties": { + "bumpFactor": { + "type": "number", + "description": "The strength of the bump displacement.", + "default": 1.0, + "minimum": 0.0, + "maximum": 1.0, + "gltf_detailedDescription": "This parameter scales the amount of normal perturbation by the bump map on the surface normal." + }, + "bumpTexture": { + "allOf": [ { "$ref": "textureInfo.schema.json" } ], + "description": "A texture that defines the displacement in the alpha channel.", + "gltf_detailedDescription": "A texture that defines the displacement in the alpha channel. This will be multiplied by bumpFactor." + }, + "extensions": { }, + "extras": { } + } +} From da11125fb38c9b9b81c22237a64269876adacc09 Mon Sep 17 00:00:00 2001 From: Ben Houston Date: Mon, 23 Oct 2023 09:26:43 -0400 Subject: [PATCH 2/7] add use cases, TODOs --- .../2.0/Vendor/EXT_materials_bump/README.md | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/extensions/2.0/Vendor/EXT_materials_bump/README.md b/extensions/2.0/Vendor/EXT_materials_bump/README.md index 8e96b13584..2211be974b 100644 --- a/extensions/2.0/Vendor/EXT_materials_bump/README.md +++ b/extensions/2.0/Vendor/EXT_materials_bump/README.md @@ -26,6 +26,12 @@ This extension adds one parameters to the metallic-roughness material: `bump`. `bump` allows users to perturb the surface normal via a bump map. The bump map is a grayscale texture, where the value of each texel represents the height of the surface at that texel. The height is then used to perturb the normal direction. +Benefits of bump maps are primarily these two: + +1. Bump maps are much more compact that normal maps and lead to smaller glTF files as well as less GPU memory requirements. This is because the normal map has to store a full 3D vector per texel, while the bump map only needs to store a single scalar value per texel. Thus bump maps require 3 times less data than normal maps for transmission and GPU storage. Normal maps are also very sensitive to texture compressions methods, while bump maps are less sensitive. + +2. Bump maps are useful for capturing small details in combination with a normal map for large scale structures. For example, when rendering human faces, there are usually two layers of surface pertubation detail, the unwrapped normal map is used for representing wrinkles, and then a repeating bump map is used for skin pore details. This is also the case for many other materials such as wood, metal, and stone, where there is both macro and micro details. + ## Extending Materials The `KHR_materials_bump` extension can be specified in the `extensions` property of the material: @@ -59,7 +65,7 @@ The `bump` parameters affect the normal used in `dielectric_brdf` of the glTF 2. The `bump` parameter is used to perturb the normal direction. The normal direction is perturbed by the value of the bump map at the texel corresponding to the fragment. The perturbed normal is then used in the `dielectric_brdf` function of the glTF 2.0 metallic-roughness material. -** TODO Derive Normal from Bump ** +### Blending Normal and Bump Perturbations In order to properly blend the bump map with a normal map, please follow the recommendation of https://blog.selfshadow.com/publications/blending-in-detail/. @@ -70,6 +76,14 @@ vec3 r = normalize( t * dot(t, u) / t.z - u ); // not required if t and u are pr vec3 blendedNormal = r * 0.5 + 0.5; ``` +### Conversion of bump to normal + +*TODO* + +### Coneersion of normal to bump + +*TODO* + ## Schema - [material.KHR_materials_bump.schema.json](schema/material.KHR_materials_bump.schema.json) From 219e90d6086161a5aac3f8c422b29de439dee343 Mon Sep 17 00:00:00 2001 From: Ben Houston Date: Mon, 23 Oct 2023 16:41:57 -0400 Subject: [PATCH 3/7] remove draft --- extensions/2.0/Vendor/EXT_materials_bump/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extensions/2.0/Vendor/EXT_materials_bump/README.md b/extensions/2.0/Vendor/EXT_materials_bump/README.md index 2211be974b..91c392a13d 100644 --- a/extensions/2.0/Vendor/EXT_materials_bump/README.md +++ b/extensions/2.0/Vendor/EXT_materials_bump/README.md @@ -9,7 +9,7 @@ See [Appendix](#appendix-full-khronos-copyright-statement) for full Khronos Copy ## Status -Draft, Ratified by the Khronos Group +Draft ## Dependencies From aa25bd1f5a3599b366029afa5636c418365ab684 Mon Sep 17 00:00:00 2001 From: Ben Houston Date: Mon, 23 Oct 2023 16:43:24 -0400 Subject: [PATCH 4/7] mention that both ThreeJS and BabylonJS support both bump and normal maps. --- extensions/2.0/Vendor/EXT_materials_bump/README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/extensions/2.0/Vendor/EXT_materials_bump/README.md b/extensions/2.0/Vendor/EXT_materials_bump/README.md index 91c392a13d..c0047dd1a1 100644 --- a/extensions/2.0/Vendor/EXT_materials_bump/README.md +++ b/extensions/2.0/Vendor/EXT_materials_bump/README.md @@ -32,6 +32,8 @@ Benefits of bump maps are primarily these two: 2. Bump maps are useful for capturing small details in combination with a normal map for large scale structures. For example, when rendering human faces, there are usually two layers of surface pertubation detail, the unwrapped normal map is used for representing wrinkles, and then a repeating bump map is used for skin pore details. This is also the case for many other materials such as wood, metal, and stone, where there is both macro and micro details. +Additionally, maybe WebGL rendering engines, including both ThreeJS and BabylonJS, already support both bump mapping and normal maps in their default materials. Without this extension, these engines can not save or load this information via glTF files. + ## Extending Materials The `KHR_materials_bump` extension can be specified in the `extensions` property of the material: From 23153c459acb5cc2837d452cea583a4ca8d73e69 Mon Sep 17 00:00:00 2001 From: Ben Houston Date: Tue, 24 Oct 2023 09:53:36 -0400 Subject: [PATCH 5/7] adad mention the limitation of bump maps and references. --- .../2.0/Vendor/EXT_materials_bump/README.md | 22 +++++++++++-------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/extensions/2.0/Vendor/EXT_materials_bump/README.md b/extensions/2.0/Vendor/EXT_materials_bump/README.md index c0047dd1a1..5d708ae1fe 100644 --- a/extensions/2.0/Vendor/EXT_materials_bump/README.md +++ b/extensions/2.0/Vendor/EXT_materials_bump/README.md @@ -26,13 +26,17 @@ This extension adds one parameters to the metallic-roughness material: `bump`. `bump` allows users to perturb the surface normal via a bump map. The bump map is a grayscale texture, where the value of each texel represents the height of the surface at that texel. The height is then used to perturb the normal direction. -Benefits of bump maps are primarily these two: +Bump maps were introduced into computer graphics in 1978 by Blinn in "Simulation of Wrinkled Surfaces, while normal maps were introduced in 1989 by Cohen et al, "Appearance-Preserving Simplification." -1. Bump maps are much more compact that normal maps and lead to smaller glTF files as well as less GPU memory requirements. This is because the normal map has to store a full 3D vector per texel, while the bump map only needs to store a single scalar value per texel. Thus bump maps require 3 times less data than normal maps for transmission and GPU storage. Normal maps are also very sensitive to texture compressions methods, while bump maps are less sensitive. +Benefits of bump maps over normal maps are primarily these two: + +1. Bump maps are much more compact that normal maps and lead to smaller glTF files as well as less GPU memory requirements. This is because the normal map has to store a full 3D vector per texel with floating point precision, while the bump map only needs to store a single scalar value per texel. Thus bump maps require 3 times less data than normal maps for transmission and GPU storage. Normal maps are also very sensitive to texture compressions methods, while bump maps are less sensitive. 2. Bump maps are useful for capturing small details in combination with a normal map for large scale structures. For example, when rendering human faces, there are usually two layers of surface pertubation detail, the unwrapped normal map is used for representing wrinkles, and then a repeating bump map is used for skin pore details. This is also the case for many other materials such as wood, metal, and stone, where there is both macro and micro details. -Additionally, maybe WebGL rendering engines, including both ThreeJS and BabylonJS, already support both bump mapping and normal maps in their default materials. Without this extension, these engines can not save or load this information via glTF files. +Normal maps are more resistant to artifacts when undergoing going magnification as compared to bump maps, thus they are better suited for large scale smooth detail. This limitation of bump maps is not significant though when bump maps are being used for detail textures where the magnification is small and they align roughly with the same texel resolution as the color map. + +Additionally, maybe WebGL rendering engines, including both ThreeJS and Sketchfab, already support simultaneous bump maps and normal maps in their default materials. Without this extension, these engines can not save or load this information via glTF files. ## Extending Materials @@ -78,17 +82,17 @@ vec3 r = normalize( t * dot(t, u) / t.z - u ); // not required if t and u are pr vec3 blendedNormal = r * 0.5 + 0.5; ``` -### Conversion of bump to normal +## Schema -*TODO* +- [material.KHR_materials_bump.schema.json](schema/material.KHR_materials_bump.schema.json) -### Coneersion of normal to bump +## References -*TODO* +[Blinn, J.F., "Simulation of Wrinkled Surfaces" (1978)](https://www.microsoft.com/en-us/research/wp-content/uploads/1978/01/p286-blinn.pdf) -## Schema +[Cohen, J. et al. "Appearance-Preserving Simplification" (1989)](http://www.cs.unc.edu/~geom/APS/APS.pdf) -- [material.KHR_materials_bump.schema.json](schema/material.KHR_materials_bump.schema.json) +[Waveren, J.M.P. et al. "Real-Time Normal Map DXT Compression" (2008)](https://developer.download.nvidia.com/whitepapers/2008/real-time-normal-map-dxt-compression.pdf) ## Appendix: Full Khronos Copyright Statement From 2d5807a9bd908650907e5fa26b91a342504dbbe4 Mon Sep 17 00:00:00 2001 From: Ben Houston Date: Tue, 24 Oct 2023 09:54:55 -0400 Subject: [PATCH 6/7] fix left over KHR_ prefixes with EXT_ prefixes. --- extensions/2.0/Vendor/EXT_materials_bump/README.md | 2 +- ...mp.schema.json => material.EXT_materials_bump.schema.json} | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) rename extensions/2.0/Vendor/EXT_materials_bump/schema/{material.KHR_materials_bump.schema.json => material.EXT_materials_bump.schema.json} (91%) diff --git a/extensions/2.0/Vendor/EXT_materials_bump/README.md b/extensions/2.0/Vendor/EXT_materials_bump/README.md index 5d708ae1fe..1e0dc06213 100644 --- a/extensions/2.0/Vendor/EXT_materials_bump/README.md +++ b/extensions/2.0/Vendor/EXT_materials_bump/README.md @@ -84,7 +84,7 @@ vec3 blendedNormal = r * 0.5 + 0.5; ## Schema -- [material.KHR_materials_bump.schema.json](schema/material.KHR_materials_bump.schema.json) +- [material.EXT_materials_bump.schema.json](schema/material.EXT_materials_bump.schema.json) ## References diff --git a/extensions/2.0/Vendor/EXT_materials_bump/schema/material.KHR_materials_bump.schema.json b/extensions/2.0/Vendor/EXT_materials_bump/schema/material.EXT_materials_bump.schema.json similarity index 91% rename from extensions/2.0/Vendor/EXT_materials_bump/schema/material.KHR_materials_bump.schema.json rename to extensions/2.0/Vendor/EXT_materials_bump/schema/material.EXT_materials_bump.schema.json index 1bbeff5fe2..e2117a220f 100644 --- a/extensions/2.0/Vendor/EXT_materials_bump/schema/material.KHR_materials_bump.schema.json +++ b/extensions/2.0/Vendor/EXT_materials_bump/schema/material.EXT_materials_bump.schema.json @@ -1,6 +1,6 @@ { "$schema": "http://json-schema.org/draft-04/schema", - "title": "KHR_materials_bump glTF Material Extension", + "title": "EXT_materials_bump glTF Material Extension", "type": "object", "description": "glTF extension that defines a bump which perturbs the surface normal.", "allOf": [ { "$ref": "glTFProperty.schema.json" } ], @@ -10,7 +10,7 @@ "description": "The strength of the bump displacement.", "default": 1.0, "minimum": 0.0, - "maximum": 1.0, + "maximum": 100.0, "gltf_detailedDescription": "This parameter scales the amount of normal perturbation by the bump map on the surface normal." }, "bumpTexture": { From 2a08ad42ec1117ca396f210bb9bc324542f7ec32 Mon Sep 17 00:00:00 2001 From: Ben Houston Date: Thu, 26 Oct 2023 10:39:00 -0400 Subject: [PATCH 7/7] be sure that we are using the red channel for bump texture. --- extensions/2.0/Vendor/EXT_materials_bump/README.md | 2 +- .../schema/material.EXT_materials_bump.schema.json | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/extensions/2.0/Vendor/EXT_materials_bump/README.md b/extensions/2.0/Vendor/EXT_materials_bump/README.md index 1e0dc06213..94c0476325 100644 --- a/extensions/2.0/Vendor/EXT_materials_bump/README.md +++ b/extensions/2.0/Vendor/EXT_materials_bump/README.md @@ -61,7 +61,7 @@ Factor and texture are combined by multiplication to describe a single value. | |Type|Description|Required| |-|----|-----------|--------| | **bumpFactor** | `number` | The strength of the specular reflection. | No, default: `1.0`| -| **bumpTexture** | [`textureInfo`](https://www.khronos.org/registry/glTF/specs/2.0/glTF-2.0.html#reference-textureinfo) | A texture that defines the strength of the specular reflection, stored in the alpha (`A`) channel. This will be multiplied by bumpFactor. | No | +| **bumpTexture** | [`textureInfo`](https://www.khronos.org/registry/glTF/specs/2.0/glTF-2.0.html#reference-textureinfo) | A texture that defines the strength of the specular reflection, stored in the red (`R`) channel. This will be multiplied by bumpFactor. | No | The `bump` parameters affect the normal used in `dielectric_brdf` of the glTF 2.0 metallic-roughness material. diff --git a/extensions/2.0/Vendor/EXT_materials_bump/schema/material.EXT_materials_bump.schema.json b/extensions/2.0/Vendor/EXT_materials_bump/schema/material.EXT_materials_bump.schema.json index e2117a220f..1641432c5d 100644 --- a/extensions/2.0/Vendor/EXT_materials_bump/schema/material.EXT_materials_bump.schema.json +++ b/extensions/2.0/Vendor/EXT_materials_bump/schema/material.EXT_materials_bump.schema.json @@ -15,8 +15,8 @@ }, "bumpTexture": { "allOf": [ { "$ref": "textureInfo.schema.json" } ], - "description": "A texture that defines the displacement in the alpha channel.", - "gltf_detailedDescription": "A texture that defines the displacement in the alpha channel. This will be multiplied by bumpFactor." + "description": "A texture that defines the displacement in the red channel.", + "gltf_detailedDescription": "A texture that defines the displacement in the red channel. This will be multiplied by bumpFactor." }, "extensions": { }, "extras": { }