JDK-8309050 : Add support for multiple light source in Metal
Type:Enhancement
Component:javafx
Sub-Component:graphics
Affected Version:internal
Priority:P3
Status:Resolved
Resolution:Fixed
OS:os_x
CPU:generic
Submitted:2023-05-29
Updated:2023-06-15
Resolved:2023-06-07
The Version table provides details related to the release that this issue/RFE will be addressed.
Unresolved : Release in which this issue/RFE will be addressed. Resolved: Release in which this issue/RFE has been resolved. Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.
Currently we can add single point/ambient/directional/spot light in Metal.
We cant add more than once light source.
We need to add implementation for multiple/combination of light sources in Metal.
Comments
Changeset: 64d10a9b
Author: Jayathirth D V <jdv@openjdk.org>
Committer: aghaisas <ajitgh@gmail.com>
Date: 2023-06-07 15:07:51 +0000
URL: https://git.openjdk.org/jfx-sandbox/commit/64d10a9b5e379d059e4405414ac01f5a54ded32e
07-06-2023
Support for multiple light sources is tested using 3D lightening app.
07-06-2023
As of now we support 3 light sources in JavaFX 3D.
Updated passing of light data in single uniform, instead of using multiple setFragmentBytes, Added shader logic to calculate light color from 3 light sources.
In D3D and OpenGL implementation we pass calculated light attributes from vertex to fragment shaders using array of vectors. I tried doing the same in Metal but it doesnt allow us to create array of vectors and when i use array of vectors in a struct it throws the datatype is illegal. After this i updated the logic to calculate, store and pass light parameters using array of scalars, this also throws illegal type error when compiled. So i am passing light parameters from Vertex to Fragment shader using individual float3 vectors. I was trying to arrays so that the code can be easily extended when we want to support more than 3 light sources.
Apart from this i also tried calculating light color values in Vertex shader itself, but that shows color sampling issues. For initial fix to support 3 light sources we can use individual float3 vectors to pass data from Vertex to Fragment shader.