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_environment_map #1956

Open
wants to merge 29 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
a2dbf75
Initial commit for environment light extension
rsahlin Mar 16, 2021
5e7ec02
Update schema
rsahlin Mar 16, 2021
e44c245
Simplify by using KTX2 for cubemaps
rsahlin Mar 16, 2021
2b2a174
Remove rotation and update to use specularCubemaps
rsahlin Mar 16, 2021
0370801
Add KTX2 float formats
rsahlin Mar 16, 2021
c2df7bb
Clarify use of other KHR extensions
rsahlin Mar 17, 2021
6612a00
Updates according to review comments
rsahlin Apr 7, 2021
3b3e9be
Updated wording related to KTX
rsahlin Apr 8, 2021
905350a
Updates, reference KHR_texture_ktx
rsahlin Apr 9, 2021
0df13f2
Update to open issues
rsahlin Apr 9, 2021
fdc5e5b
Clarification for cubemap filtering
rsahlin Apr 30, 2021
20d55ca
Clarification for cubemap filtering
rsahlin Apr 30, 2021
70653fe
Remove resolved issues
rsahlin May 20, 2021
0f553ce
Updated light properties
rsahlin May 26, 2021
4706330
Update specularCubemap description
rsahlin May 26, 2021
3744d7e
Moved `lights` into extension
rsahlin May 26, 2021
71d8f3a
Updates to use local cubemap, clarifications
rsahlin Oct 15, 2021
73b3133
Add bbox min/max, use luminance and texture ref
rsahlin Oct 15, 2021
6f2b3fc
Remove KHR_texture ktx extension
rsahlin Oct 18, 2021
904937b
Add KHR_texture_ktx to textures array
rsahlin Oct 18, 2021
a596a69
Clarification of light contribution
rsahlin Oct 21, 2021
d2ffe33
Remove luminance factor
rsahlin Oct 21, 2021
a8c21ec
Remove luminance from schema
rsahlin Oct 21, 2021
3232a99
Add contributor
rsahlin Oct 21, 2021
00b3730
Clarification of pre-filtered maps, add references
rsahlin Oct 22, 2021
590c2ac
Remove dependency to KHR_texture_ktx
rsahlin Dec 8, 2021
bdbd58d
Schema update
rsahlin Dec 13, 2021
0b849a7
Rename extension to KHR_environment_map
rsahlin Jun 14, 2023
c6241f9
Update README.md
rsahlin Jun 20, 2023
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
30 changes: 18 additions & 12 deletions extensions/2.0/Khronos/KHR_lights_environment/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,23 @@

Draft

Open issues:
Should Spherical Harmonics be supported or should clients be forced to evaluate the specular cubemap for diffuse contribution.
The question comes down to if resolution supplied by 9 coefficients SH is enough for most usecases?
Since the SH are optional, and I believe the quality using 9 coefficients is reasonable, I am leaning towards keeping them.

If compressed texture format is used how should pre-filtering for roughness reflection be done?
rsahlin marked this conversation as resolved.
Show resolved Hide resolved
May lead to unpredicted results of clients shall decode then create mip-levels since the result will likely take much more GPU memory since compression is likely not supported on target.

## Dependencies

Written against the glTF 2.0 spec.
This extension may use KHR_texture_basisu, KHR_texture_float_bc6h or KHR_texture_float_f16
This extension depends on KHR_texture_ktx
This extension may use KHR_texture_basisu or KHR_texture_float_bc6h to support compressed texture formats.

## Overview
This extension provides the ability to define image-based lights in a glTF scene using KTX v2 images.
Image-based lights consist of an environment map that represents specular radiance for the scene as well as irradiance information.
This extension provides the ability to define image-based lights in a glTF scene using KTX v2 images as defined by KHR_texture_ktx.
Image-based lights (environment map, light map) consist of a cubemap map that represents specular radiance for the scene, irradiance information and is the source for environment reflection.
This can be used on it's own - ie a glTF asset with only environment map data - for a usecase where the IBL needs to be distributed.
It can also be used together with model data, for usecases where a model shall be displayed in a defined environment.

Expand All @@ -34,24 +43,21 @@ Secondly, it ensures that rendering of the image-based lighting is consistent ac
A conforming implementation of this extension must be able to load the image-based environment data and render the PBR materials using this lighting.

The environment light is defined by a cubemap, this is to simplify realtime implementations as these are likely to use cubemap texture format.
Cubemaps can be supplied pre-filtered, by including the pre-filtered mip-levels, where each mip-level corresponds to increasing roughness values.
If cubemap does not include mip-levels then filtering will be performed at load time.
If a compressed texture format is used then pre-filtered mip-levels must be included.
Cubemaps shall be supplied without pre-filtered mip-maps for roughness values > 0, pre-filtering shall be done by the client.
[See Specular radiance cubemaps](#specular-radiance-cubemaps)

If a compressed texture format is used then pre-filtered mip-levels for roughness values > 0 shall be specified.
rsahlin marked this conversation as resolved.
Show resolved Hide resolved

## Declaring an environment light

The KHR_lights_environment extension defines an array of image-based lights at the root of the glTF and then each scene can reference one.
Each environment light definition consists of a single cubemap that describes the specular radiance of the scene, the l=2 spherical harmonics coefficients for diffuse irradiance and intensity values.
The cubemap is defined by texture references to a KTX2 file containing a cubemap.
These files can contain compressed textures using KHR_texture_basisu or use a float texture format as defined by KHR_texture_float_bc6h or KHR_texture_float_f16
These files can contain compressed textures using KHR_texture_basisu or compressed float texture format as defined by KHR_texture_float_bc6h.

When the extension is used, images shall use `image/ktx2` as mimeType for cubemaps that are referenced by the `specularCubemap` property of KHR_lights_environment extension object.
The texture type of the KTX v2 file shall be 'Cubemap'

Supported formats are:
VK_FORMAT_R8G8B8_SRGB
VK_FORMAT_R16G16B16_SFLOAT
VK_FORMAT_R32G32B32_SFLOAT

The following will load the environment light using KHR_texture_basisu on clients that supports that extension, otherwise fall back to using KTX2 using VK_FORMAT_R8G8B8_SRGB.

Expand Down Expand Up @@ -123,7 +129,7 @@ Coefficients are calculated for the first 3 SH bands (l=2) and take the form of
## Implementation Note
This section is non-normative

Implementations may calculate the irradiance cubemap from the specular radiance cubemap and use instead.
Implementations may calculate the irradiance from the specular radiance cubemap and use instead.
One possible benefit with spherical harmonics is that it is generally enough evaluate the harmonics on a per vertex basis, instead of sampling a cubemap on a per fragment basis.

[Realtime Image Based Lighting using Spherical Harmonics](https://metashapes.com/blog/realtime-image-based-lighting-using-spherical-harmonics/)
Expand Down