On Thu, 18 Jan 2024 15:33:49 GMT, Lukasz Kostyra <lkost...@openjdk.org> wrote:

>> Originally this issue showed the problem of Node being incorrectly rendered 
>> (clipped) when snapshotting, compared to a snapshot of the whole Scene. 
>> Later on there was another problem added - lights not being taken into 
>> account if they are added to a SubScene.
>> 
>> As it later turned out, the original problem from this bug report is a 
>> problem with ParallelCamera incorrectly estimating near/far clipping planes, 
>> which just happened to reveal itself while snapshotting a Node. During 
>> testing I found out you can make the Node clip regardless of snapshot 
>> mechanism. Clipping issue was moved to a separate bug report and this PR 
>> only fixes the inconsistency in lights being gathered for a snapshot.
>> 
>> `Scene.doSnapshot()` was expanded to also check if SubScene provided to it 
>> is non-null and to fetch lights assigned to it. Scenario was tested with 
>> added SnapshotLightsTest.
>> 
>> Rest of the tests were checked and don't produce any noticeable regressions.
>
> Lukasz Kostyra has updated the pull request incrementally with one additional 
> commit since the last revision:
> 
>   doSnapshot: Replace light accumulation code
>   
>   Uses suggested simpler implementation using Java's Streams.
>   
>   Needed an additional check in NGShape3D, otherwise IndexOutOfBounds was
>   thrown

This looks mostly correct except for the case where both the Scene and the 
SubScene have lights. It seems worth adding a test for this case as well.

modules/javafx.graphics/src/main/java/javafx/scene/Scene.java line 1353:

> 1351:         Stream<NGLightBase> lights = Stream.concat(
> 1352:             Optional.ofNullable(scene).stream().flatMap(s -> 
> s.lights.stream()).map(LightBase::getPeer),
> 1353:             Optional.ofNullable(subScene).stream().flatMap(s -> 
> s.getLights().stream()).map(LightBase::getPeer)

For a node in a SubScene this will apply the lights from both the Scene and 
SubScene, which is not the right behavior. It should apply the lights from 
`scene` only if `subScene` is null.

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

PR Review: https://git.openjdk.org/jfx/pull/1332#pullrequestreview-1841522831
PR Review Comment: https://git.openjdk.org/jfx/pull/1332#discussion_r1465002946

Reply via email to