-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
glTF 2.0: New KHR_lights extension #945
Comments
In general, a node will have no or one entry of a light with its index. An ambient light can only be assigned to a scene. Is this approach accepted? |
Lgtm. Ambient light has no transform to apply. |
I will implement this extension. If it works out fine, I will create a schema and bring it back to the glTF working group. |
This is the current export. Moved the color 'up', as it does appear in all light types. |
Should this extension also address the use case of pre-computed lighting? Perhaps an additional optional texture map in materials? |
Yes, pre-computed lighting should also go into materials like e.g. occlusion. I suggest to create another extension for this, where all light maps come in. |
As promised in yesterdays call, this is the current syntax of the lights export by example:
|
We are implementing this extension in three.js with mrdoob/three.js#11551. Would this article be an appropriate introduction to the lighting model described here? I am making the following assumptions:
I am not sure I understand the difference between quadraticAttenuation and fallOffExponent. I assume we want to modify intensity by a factor |
fallOffAngle is also known as spotCosCutoff (with angle vs "cos" encoding) and So, quadraticAttenuation is defined as mentioned in your article. The fallOff* parameters are just for the spot light. |
I see, thanks! My only concern then is with the Also, if both are just for the spotlight, should naming be |
The fallOffExponent probably exists since years and other encoding would be probably much better. I am flexible on this but we should ask the others in next weeks call. Also regarding the naming, we should discuss this. |
Current KHR_lights specifcation: |
@UX3D-nopper
|
Regarding point one, this is from the old spec. I agree, we could just kick it out. Also agree on second point. Maybe name is "positional", as point and spot share the same attenuation parameters. Nested inside "positional" we have a "spot", where the "falloff" is defined? Also agre, this has clearly be specified, that these lights can only place either in nodes or scenes. |
Okay, continued with the light extension description. |
Exactly define Spotlight falloff_angle for glTF 2.0: |
About the additional proposed light types,
|
Yeah, I'm okay with getting rid of We still need to work out physical units for each light type as well. I'm inclined to go with what Babylon defines. i.e.
Thoughts? |
three.js supports I understand lux for area lights but (and I hope this isn't a dumb question 😅) can lm/m^2 be applied in a physically correct way for a directional light with infinite area? Many of the three.js lighting assumptions are based on this paper from SIGGRAPH: https://seblagarde.files.wordpress.com/2015/07/course_notes_moving_frostbite_to_pbr_v32.pdf It is silent on directional lighting, treating the sun as a disc area light with finite area. Probably more physically correct, but less widely supported as mentioned. Aside, I didn't mean to say "glTF should not support area lights" or anything like that earlier. But since they're not widely supported in runtime formats, might make more sense as part of some experimental |
Yeah, I don't think directional lights can ever be treated in a truly energy conserving manner. By definition, they exist at an infinite distance and have a precise direction so attenuation and spread are both meaningless. But, they are an excellent approximation of a point or spot light at a very far distance. As long as the coverage area is relatively small compared to that distance, the approximation holds. So yeah, I think lm/m^2 measured at an object's surface is perfectly fine. And I'm in agreement about less-supported lights being better included in a further extension. Area lights, hemisphere lights, etc. |
For spotlights, we should probably discuss the properties. I think I would expect just an angle for the light cone and then some sort of value to control the falloff at the edge of the spotlight. Physically, this falloff would be affected by the shape of the sheath around the light and even the amount that the light scatters through the atmosphere. It would probably get pretty complicated to try to define some simple, physically-based, properties for these things. Maybe this is why UE4 elects to use the |
It would be great if the extension could support IES profiles or does this go beyond the scope of this extension? |
That would be cool. However, like area lights and hemisphere lights, this is probably something best left to a further extension. |
I suppose maybe we should discuss whether flags for casting shadows should be included as part of a light. Certainly I'm not suggesting that we include details about shadow techniques or settings but what about a simple boolean? There will be a large amount of variance in the final rendering between engines but this would at least allow the glTF to inform the engine whether or not to render a shadow. The default would be false. |
@sebevan mentioned in my Babylon.js pull request (BabylonJS/Babylon.js#3579) that spotlights that don't include an |
As far as I can tell from docs, Unity doesn't have any concept of an
The comment on BabylonJS suggests inner should be optional, not outer, right? Do any engines implement gaussian falloff for spot lights? Asking engines to support two different falloff modes seems like a stretch if we want consistent implementations. I think I'd vote to leave shadows out of scope on this extension. |
Does Unity not have a property to adjust the way the light falls off? All I can see in the docs is the
I'm okay with simplifying spotlights to only have a single angle property if it helps this extension get accepted sooner. However, being able to control the falloff a bit more explicitly would be my preference, even if a couple of engines just approximate the behaviour. |
Okay, so after talking on the call this morning, it sounds like we're okay with For engines that don't support two angles, it would be expected that they would use |
+1 for Also, we plan to omit area lights from this extension, to ensure that the extension will have broad support. Area lights can be added in a future extension, perhaps alongside hemisphere lights or IBL, for more advanced lighting. Community members are welcome to initiate that discussion in a new PR or use custom vendor extensions for your needs in the meantime. |
New rendering pipelines (both "HD" and "Lightweight") in Unity 2018.1 (beta out now) support inner & outer spotlight cone angles.
The "HD" rendering pipeline in Unity 2018.1 does support realtime area lights (shadows from them would still be "punctual" though), largely implemented via Linearly Transfomed Cosines approximation. |
+1 for innerConeAngle. @MiiBond As for the "castShadow" property, it would be nice to extend this beyond lights to meshes. |
Thanks everyone for the great discussion here! Reviews are very welcome on the pull request for this by @MiiBond. |
I implemented COLLADA 1.4 and 1.5 lights in AssetKit I want to provide single interface for both COLLADA (1.4 and 1.5+) and glTF (2.0+) so I need to convert the extension to existing data structure which is (speaking for spot light for now): typedef struct AkSpotLight {
AkLightBase base;
float constAttn;
float linearAttn;
float quadAttn;
float falloffAngle;
float falloffExp;
} AkSpotLight; or as alternative I can update/upgrade this structure for new glTF design if it is possible to convert COLLADA structure to glTF's inner / outer angle or vice-versa. I couldn't see attenuation properties in proposed PR (#1223). Actually it explicitly says:
this solves the problem of converting I found a good tutorial which explains dual cone spot: http://ngreen.org/articles/quick-n-easy-dual-cone-spotlights-glsl.html and this: https://msdn.microsoft.com/en-us/library/windows/desktop/bb174697(v=vs.85).aspx seems like @McNopper's first proposal (or following ones) fits with my importer and renderer, if glTF will use new design I would like to know how to convert old design/structure ( single cone ) to new design/structure ( dual cone ) to provide single and better interface to users. I need to convert between them because some tools may use single cone (with linear, quadratic and constant attenuations) and some tools may use dual cone (inner / outer angle), is it possible to do that without losing any lighting information? |
The current KHR_lights proposal would remove those attenuation properties and (implicitly) expect physically-correct values to be used. So it is possible to convert glTF lights to your representation with explicit attenuation values, but physically impossible attenuations could not be represented in the glTF KHR_lights proposal.
The lights extension is still open for feedback, so we're glad to have more opinions on lights. But in general, beyond just lights, note that COLLADA will have many features that will never be included in glTF, and that is by design. So keeping a single interface may be difficult long-term. |
@donmccurdy thanks for your comments, I'm updating my data structures for glTF if necessary and sometimes this makes API more clear and fantastic. So I'll implement PBR in my importer and renderer after OIT transparency stuff finished. And I want to update my lights structures too for new design. Dual cone seems better alternative but I never used it before. So after updated my structures to glTF I need to convert COLLADA values to glTF structures. Or I need to create another Spot light type which I'm reluctant to do so. You said "it is possible to convert glTF lights to your representation", is it possible to do the opposite? Also how can I convert glTF to my representation as alternative, any formula? --
I'm aware and happy for that, I like both specs.
You are right, but single interface makes things easier for tools and engines. Maintaining single interface also makes codes re-usable in importer. For instance I'm not sure how many tools support COLLADA 1.5 because some libraries provides two interface... With single interface, tools/engines can support new version of COLLADA and glTF more quickly I think. Also I'm considering to provide some sub tools e.g. mesh optimizer... single interface will make things more easier for that, I hope. Currently while writing new render engine I'm only using single interface to load COLLADA 1.4, 1.5 and glTF 2.0 (not all features for now), so I can focus on render stuff instead of implementing different APIs/interfaces in render side. In the future some conflicts may occurs but COLLADA (and AssetKit) has technique/profile/extra elements which makes it very extensible. In the future any conflicts can be resolved with technique="gltf or collada" or profile="gltf or collada"... These are my thoughts, I hope I can achieve what I think :) |
I know I am very late to this discussion, but I just recently found out about adding lights to glTF. I looked through this issue but did not find anything related to an answer. Perhaps it is in this issue or another issue, if so, please point me that way. My question is what is the use case for including lighting in a glTF file. If the glTF file is to contain an efficient delivery of the model to the GPU, adding lights increases the size of the model to the limit of the lights and the scene manager needs to deal with something not directly under its control. If the glTF file contains an entire scene (or subscene), then isn't the nice partitioning effect of having interchangeable and reusable model files lost? |
Can I put in a request for documentation on how to use the lights data in a webgl shader? Especially helpful would be if there was a webgl reference implementation, like these but to handle lights: |
Updated three.js implementation of KHR_lights. |
@dakom Good suggestion, I think that would be put in glTF-WebGL-PBR if we add it. Filed an issue.
I don't think any determination has yet been made that glTF assets should represent a single model, rather than a scene, or (if so) where that line should be drawn. This might be better to raise in a new issue, perhaps. Lights existed in glTF 1.0 (not sure whether this issue was raised then), this PR is primarily updating the syntax for glTF 2.0 and PBR models. |
Also — I'm sure it's mentioned somewhere in this thread already, but a proposal for |
range should be default -1.0. If -1.0, there should be no range restrictions. If range >= 0.0, the the range restriction should apply. |
As the lights have to be extracted from the KHR_materials_common extension, here is a first try by example:
Directional, point and spot are obvious for PBR and non-PBR materials.
Regarding ambient and for PBR, this needs to be further discussed and explained. But I suggest to treat the value as if an environment map is used, which does have just this color.
The text was updated successfully, but these errors were encountered: