JDK-8303818 : Implement Ambient light feature 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-03-08
Updated:2023-06-15
Resolved:2023-03-08
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.
We support only single point light after https://bugs.openjdk.org/browse/JDK-8303439
Add support for Ambient light also for 3D primitives.
Comments
Changeset: 62f22ac0
Author: Jayathirth D V <jdv@openjdk.org>
Committer: aghaisas <ajitgh@gmail.com>
Date: 2023-03-08 17:20:53 +0000
URL: https://git.openjdk.org/jfx-sandbox/commit/62f22ac08080347aed1354a8cfe8b6e87f60f23c
08-03-2023
I am also refactoring how we send different uniforms to Vertex and Fragment shader under this bug.
Sample code to use Ambient light:
import javafx.application.Application;
import javafx.geometry.Point3D;
import javafx.scene.AmbientLight;
import javafx.scene.Group;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.paint.Color;
import javafx.scene.paint.PhongMaterial;
import javafx.scene.shape.Box;
import javafx.scene.shape.Cylinder;
import javafx.stage.Stage;
public class AmbientLight_3D extends Application {
final int SCENE_WIDTH = 600;
final int SCENE_HEIGHT = 600;
public Parent createContent() throws Exception {
int denom = 4;
Box testBox = new Box(SCENE_WIDTH/denom, SCENE_HEIGHT/denom, SCENE_WIDTH/denom);
testBox.setLayoutX(SCENE_HEIGHT/2 + 100);
testBox.setLayoutY(SCENE_HEIGHT/2);
testBox.setRotationAxis(new Point3D(1,1,1));
testBox.setRotate(45);
testBox.setMaterial(new PhongMaterial(Color.RED));
Cylinder testCylinder = new Cylinder(100.0, 200.0);
testCylinder.setLayoutX(SCENE_WIDTH/4);
testCylinder.setLayoutY(SCENE_HEIGHT/2);
testCylinder.setRotationAxis(new Point3D(1,1,1));
testCylinder.setRotate(45);
testCylinder.setMaterial(new PhongMaterial(Color.BLUE));
AmbientLight ambientLight =
new AmbientLight(Color.color(0.2, 0.2, 0.2));
Group root = new Group();
root.getChildren().add(testBox);
root.getChildren().add(testCylinder);
root.getChildren().add(ambientLight);
return root;
}
@Override
public void start(Stage primaryStage) throws Exception {
Scene scene = new Scene(createContent(), SCENE_WIDTH, SCENE_HEIGHT);
primaryStage.setScene(scene);
primaryStage.show();
}
/**
* Java main for when running without JavaFX launcher
*/
public static void main(String[] args) {
launch(args);
}
}