-
Notifications
You must be signed in to change notification settings - Fork 13
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
Lighting estimation for WebXR #1
Comments
I've seen a bunch of discussion about that API being removed (I think some browsers already have?). The issue (as with the devicemotion API) is that it can be accessed in the background without permission, and there were some crazy threat scenarios painted for how it can be abused. |
To clarify, I wasn't necessarily proposing using the ambient light api! Just pointing out that we needed to pay attention to it's existence. Do you have a link to the discussion about it being avoided? |
Ok, digging back in, it seems mostly a firefox dev mailing list discussion (e.g., here That said, when I read through the spec (https://w3c.github.io/ambient-light/), it feels like some of the concerns may be relevant if we enable this capability at the "lowest" level of permission. For example, a malicious script could potentially detect that multiple users are together by the ambient light sensing pattern, or even if they were in a certain place. These are the kind of threats that we need to be conscious of. Now, if we only enable estimation when users have granted access to "world knowledge" of some form, I think many of these threats are less compelling, since there is so much other information to leverage. |
I want to implement the "Lighting estimation for WebXR" for my contents, The LightEstimation of the AR platforms are tightly coupled with the "frame", So, why don't we make separated API for WebXR, that are related to the XRFrame ? |
@kyungtae I think that was the rough conclusion (that we probably needed a separate API from the Ambient Light API), for the reason you stated (tied with frame). |
IMHO, the LightEstimation API could be like below. Because we can estimate the light of the AR scene with the environment (camera preview ) of the scene, we can add "XRLightEstimation" attribute in XRFrame. [SecureContext, Exposed=Window] interface XRFrame { ... readonly attribute XRLightEstimation? lightEstimation; } Additionally, the XRLightEstimation consists of the intensity and the color, [SecureContext, Exposed=Window] interface XRLightEstimation { readonly attribute double intensity; readonly attribute double? color; }; |
When this came up before, the question raised was "are such simple values adequate"? Will platforms want to support this simple approach? Do we need to support a couple of variations or kinds of data? I would be in favor of having this be a separate repo with a proposal that could be worked on, and it would be good if some of the platform engineers could chime in. |
I think the simplicity of this proposal works as long as we specify that it's an ambient estimate. So if the above IDL is tweaked to say [SecureContext, Exposed=Window] interface XRLightEstimation {
readonly attribute double ambientIntensity;
readonly attribute double? ambientColor;
}; I think that implicitly makes the lighting estimation object more extensible in the future. I personally have questions about whether or not we'd want to have the color be a single double (in which case it should probably be |
I received feedback that it's better to keep proposal Issues in here for search purposes, so I'm moving them back until we can think through how to handle it. Ada, when you make the README for the repo, please add a link to this Issue. |
@TrevorFSmith Did you close this issue intentionally? I think it might be helpful for searchability to keep it open until it is converted to a README or other representation for this spec component. @toji about ambient color vs color temperature, I think an RGB ambient color seems strictly more powerful. A color temperature represents black body radiation that can be converted to RGB, i.e. via lookup tables or a calculation, but the inverse isn't really possible. For example, if the scene is lit with an unnatural light color such as green or purple, that can be represented as an RGB color, but color temperature is restricted to a one-dimensional red-to-white-to-blue path through the color space, so forcing it into that representation would potentially lose data. |
@klausw Yes, once we create a feature repo all conversation should happen there. So, I recommend creating a new Issue over there and if necessary refer back to this Issue. |
May I suggest that SH (Spherical Harmonics) be considered as part of the format to express the environment lighting in a directional dependent manner? https://en.wikipedia.org/wiki/Spherical_harmonics This has the advantage of being small (feasible to calculate and store hundreds on a mobile device), scalable (can easily access various levels of detail), and used ubiquitously in game engines for this purpose. |
For background on use in lighting specifically: |
Even more specifically, we could use PRT (Precomputed Radiance Transfer): https://en.wikipedia.org/wiki/Precomputed_Radiance_Transfer It should be possible to express a simple ambient / color temperature value in this format as well as extract such a value from PRT data that includes the higher frequency domain. |
There's already an API on the web for Lighting Estimation (https://w3c.github.io/ambient-light/) but it currently only supports getting the ambient intensity.
It would be useful for improving the realism of AR rendering to have slightly more information than that. For example the color temperature would be helpful and is generally available on the underlying XR platforms that would back WebXR. There are also other more advanced lighting options available on some platforms that would be worth investigating as optional features. One example is this from ARKit: https://developer.apple.com/documentation/arkit/arenvironmentprobeanchor
The text was updated successfully, but these errors were encountered: