RFR: 8234920: Add SpotLight to the selection of 3D light types [v9]

Kevin Rushforth kcr at openjdk.java.net
Fri Apr 9 19:05:22 UTC 2021


On Fri, 26 Mar 2021 13:58:30 GMT, Nir Lisker <nlisker at openjdk.org> wrote:

>> I think I corrected the GL pipeline issue. The dot product should have used the negative light direction. It worked for me because I was testing in the -1 z direction instead of the +1. I still don't know why Mac and Linux would have given different results. This is what I get after the commit:
>> 
>> ![Screenshot from 2021-03-25 03-59-57](https://user-images.githubusercontent.com/37422899/112407458-c941cc80-8d1e-11eb-85c2-468508e5018a.png)
>
> If you want to test aiming the light with transforms instead of a direction vector, I modified the `NGSpotLight` and `AttenLightingSample` files to use the rotation transforms.
> 
> [transforms.zip](https://github.com/openjdk/jfx/files/6212221/transforms.zip)

The problem with the hole in the spotlight on Mac is fixed. The remaining problems seem to be related to the way range is treated. Maybe there is a problem with a scale somewhere? This is on a retina display with 2x scaling. Here are two sample pictures that illustrate what I mean. The first is on Windows, and the second is on Mac.

![SpotLight-range-Windows](https://user-images.githubusercontent.com/34689748/114226633-ade2de00-9928-11eb-8d24-0efcaf7f059a.png)
<img width="1212" alt="SpotLight-range-macOS" src="https://user-images.githubusercontent.com/34689748/114226651-b2a79200-9928-11eb-9231-ed9d58ef891e.png">


Also, I still see some unrelated problems on Linux, but since it is a VirtualBox guest running on my Windows host, I'm not sure how valid a test it is. I have to set `-Dprism.forceGPU=true` to get any 3D on that machine. @arapte was going to try it on a different system (also a VM image, but different system and graphics card). I'm less worried about this one as long as physical Linux box that actually reports 3D support works correctly.

So I think we're down to the range and/or scaling being wrong on Mac. Possibly in retina mode only.

As for setting the spot light direction using rotation, I think there are three API choices, and I don't like the third since it is inconsistent, so really two choices.

1. No direction property in the SpotLight API. A vector of `(0,0,1)` is transformed from the local coordinate space of the light into world coordinates and used as the direction.
2. Add a direction property to the SpotLight API, with a default of `(0,0,1)`. That direction vector is transformed from the local coordinate space of the light into world coordinates and used as the direction.
3. Add a direction property to the SpotLight API, with a default of `(0,0,1)`. That vector is use as the direction without regard to any transforms.

Option 2 is the most flexible. I think option 1 is fine, since we can always compatibly add a direction vector in the future (giving us option 2 later). As I mentioned, option 3 is inconsistent, so let's not do that one.

-------------

PR: https://git.openjdk.java.net/jfx/pull/334


More information about the openjfx-dev mailing list