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
EXT_lights_image_based extension #1377
Conversation
Should the name be Seems consistent with WebGL extensions: https://www.khronos.org/registry/webgl/extensions/ We basically followed this naming convention for glTF extensions, except for Also, if we expect quick and broad adoption, perhaps just start with |
@pjcozzi I did talk to @bghgary about the naming and I believe we landed on the camelCase for If the support is strong for this extension, renaming to KHR would be great. I think we were just concerned that it's one very specific way of storing IBL prefiltered maps and maybe not all runtimes would want to go this route to support them. |
Can we please put the definition of the HDR textures in another extension? |
Is there a reason, not to provide the whole mip map chain? |
Finally, I would prefer to encode specularImages in such a way, that later e.g. one image can be referenced having all sides plus mip map levels. |
This is great. One request: it would be awesome to support per-mesh IBL maps, a.k.a. "light probes" / "reflection probes". This would allow much more realistic reflections, with objects reflecting nearby objects in the scene.
Thanks! |
Or, an even better way would be to allow IBL environment image changes per transform node:
|
I think when we added the KHR_materials_pbrSpecularGlossiness, we were (or at least I was) thinking the pattern was That said, +1 to using snake_case for image_based. |
We were thinking that an extension isn't necessary for HDR textures, just like we don't need a flag specifying the color space of a texture. It is implied by the object referencing the texture/image. The original proposal was to do this but I found that implementing it in Babylon was more difficult if we used an extension. Thoughts?
We went back a forth a few times on this. Most of the time, we don't want the whole mip map chain because the smallest mip maps don't have enough detail for the environment. It's the offset in some of the environment map creation tools (e.g. Lys). By not specifying all the levels, you implicitly also specify the offset and don't need to provide the unused images. The down-side is that some browsers don't support uploading partial chains and thus you have to fill the missing chains manually.
Can you elaborate on this? I'm not sure what you mean. |
I'm not an expert in this, but I would think this should be a separate extension. |
I think we can start with a special PNG encoding that can be used without additional extensions (implying that encoding scheme and |
+1. Does KTX2 help at all with this? |
Sure, even KTX1 can hold BC6H cube map with mip levels. |
I mean the texture transmission extension in conjunction with KTX2. Are there plans to support HDR? |
Ultimately, yes. Can't say anything about timeline, though. |
Great! I'm a 3d Artist over at Electronic Arts, we've just started experimenting with the gltf2.0 format and are very excited about it's potential To that end, I'd echo the comments from @gnagyusa on per-mesh / per-transform IBL map assignment. This would be a fantastic way of faking real-time reflections and allow for greater control over lighting, so we can better match the fidelity of our game and cinematic assets. |
After this discussion, I recommend that
|
Strongly disagree just having PNG for specular images, as the color channel resolution and finally the quality is too low. |
Finally, providing the whole mip map chain and going down to 1x1 pixel should be sufficient. Please comapre with this tool: |
For the IBL-per-node idea, we did discuss that and I can't remember why we didn't allow it. Maybe lack of runtime support? I think Babylon and Three.js should both be able to handle this. EXT_lights_imageBased -> EXT_lights_environment Leaving the door open for using other texture types would be nice. We just didn't want to support a long list of formats and layouts. e.g. equirectangular or cube layout, RGBE, RGBM, RGBD, logLuv-encoded PNG's, .hdr, .exr, etc. As for the mip chain, I believe the common practice is to have an offset that specifies which mip represents a fully convolved (i.e. corresponding to roughness = 1.0) reflection. Then the shader interpolates down to that mip. Using the 1x1 mip for this isn't useful. So, we either specify an offset or we specify only a portion of the mip chain and let that implicitly define which mip corresponds to roughness = 1. Gary and I discussed both options but I'm curious what others think. |
I don't know this part of Babylon well, but my understanding is that this is handled very differently. |
Regarding EXT_lights_imageBased -> EXT_lights_environment: Unity: https://docs.unity3d.com/Manual/GlobalIllumination.html#Environment I personally would prefer environment, as it describes the ligth type and note the technology/algorithm used, |
Images do become a texture:
|
Finally, we need an extension for textures:
First texture is for the existing use case or if the image contains all 6 sides plus all mip levels. This would allow to still use .png and .jpeg but also fiel formats like .hdr, .exr, .dds or .ktx |
Regarding the mip chain, I am not sure if this a common approach. Which engines are using it? Thought everyone is doing it like this (see 20.4 Mipmap Filtered Samples): In my opinion, information/precision is lost, as textures are "missing" and values have more to be interpolated. |
Should this extension be under the Khronos or Vendor folder? Or should there be a Multi-Vendor folder added for EXT extensions? |
I think for now it should go in |
Thanks. Since support for this extension is now live in Babylon and shipping on Monday with Dimension 2.0, should this PR be merged? |
Also @MiiBond it would help to provide a sample glTF with this extension to test with for people implementing it. For explaining how to generate the spherical harmonics, @TimvanScherpenzeel's tool (https://github.com/timvanscherpenzeel/cubegen/tree/octagen) is a wrapper around Filament's cmgen (https://github.com/google/filament#running-the-native-samples) which generates pre-filtered maps as well as the spherical harmonic coefficients. |
Updated the spec to address @emackey 's comments. |
We haven't tried to update an existing extension before. I'm not sure what the implications are. I think it might be okay to do it if the update is both forward and backwards compatible, like glTF 2.0 core. |
extensions/2.0/Vendor/EXT_lights_image_based/schema/glTF.EXT_lights_image_based.schema.json
Outdated
Show resolved
Hide resolved
extensions/2.0/Vendor/EXT_lights_image_based/schema/light.schema.json
Outdated
Show resolved
Hide resolved
extensions/2.0/Vendor/EXT_lights_image_based/schema/scene.EXT_lights_image_based.schema.json
Show resolved
Hide resolved
Excellent feedback, @lexaknyazev. Thank you! |
@MiiBond I haven't tried compiling cmgen on a mac but they do have prebuilt releases for all OS's (https://github.com/google/filament/releases). Also CesiumJS does have support for this almost ready which I think would help provide a second reference implementation. We've just been waiting to get our hands on some glTF models with this extension to test with. I know Adobe Dimensions can export it but do you know of any freely available models for testing? |
Thanks, @OmarShehata . I'll see if I can export some examples from Dimension today. |
@MiiBond for this version of the extension, can it be applied only to |
@MiiBond Actually it looks like the schema can be applied to the root or the |
The root gets an array of light definitions (like in punctual lights), the scene gets a light instance. |
@lexaknyazev Ah, of course. Thanks! |
Just a heads up if you are going to use the spherical harmonics generated by |
"title": "light", | ||
"type": "object", | ||
"description": "An image-based lighting environment.", | ||
"allOf" : [ { "$ref" : "../../../../specification/2.0/schema/glTFChildOfRootProperty.schema.json" } ], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know this just got merged, but I need to ask one more question. None of our other extensions put this whole relative path on here, they all just say glTFChildOfRootProperty.schema.json
without the path. Would it be OK to remove the path for consistency?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Further discussion migrated to #1480.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure. I can make that change and do another pull request. Thanks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@OmarShehata I added a sample asset here: |
@MiiBond Is there more info on "principled multi-scatter GGX normal distribution" or any reference code on how to generate assets compatible with this extension? Tried to have a look at BabylonJS repo but can't find anything. |
Actually, we don't really have any consistency in the exact lighting model or roughness curve used for generation or display of this data. However, we're currently in talks about defining a Khronos-ratified version of this extension which will spell-out, more concretely, the equations to use when generating the IBL maps and displaying them in the runtime. |
Here's a super rough pass of the IBL extension that I've been working on with Microsoft (@bghgary).
It needs a lot more info added, of course, but we thought we'd get it out there early.