JDK-8305804 : 3D primitives are not shown in Ensemble8
  • Type: Enhancement
  • Component: javafx
  • Sub-Component: graphics
  • Affected Version: internal
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: os_x
  • CPU: generic
  • Submitted: 2023-04-10
  • Updated: 2023-06-15
  • Resolved: 2023-04-13
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.

To download the current JDK release, click here.
Other
internalFixed
Related Reports
Blocks :  
Description
Currently 3D primitives are shown only in standalone programs and when we try to render 3D primitives in demo apps like Ensemble8 they are not seen.

Find what wrong state is causing this issue and make appropriate change.
Comments
Changeset: f7a0fb07 Author: Jayathirth D V <jdv@openjdk.org> Committer: aghaisas <ajitgh@gmail.com> Date: 2023-04-12 21:38:54 +0000 URL: https://git.openjdk.org/jfx-sandbox/commit/f7a0fb078e898cfd69a352c0b05bc485214e31fa
13-04-2023

When "SceneAntialiasing.BALANCED" is used we try to create MSAA texture and use it as an intermediate texture to draw the 3D primitive and then blit the MSAA texture to FBO. Currently we dont have MSAA support in Metal pipeline, but the main issue here is intermediate texture blit logic. We dont have implementation of Texture to Texture blitting in MTLContext, we are just printing the log like below : MTLContext.blit() :srcRTT = com.sun.prism.mtl.MTLRTTexture@7390b89b [format=BYTE_BGRA_PRE physicalWidth=640 physicalHeight=640 contentX=0 contentY=0 contentWidth=600 contentHeight=600 wrapMode=CLAMP_TO_ZERO linearFiltering=true], dstRTT = com.sun.prism.mtl.MTLRTTexture@17714910 [format=BYTE_BGRA_PRE physicalWidth=640 physicalHeight=640 contentX=0 contentY=0 contentWidth=600 contentHeight=600 wrapMode=CLAMP_TO_ZERO linearFiltering=true], srcX0 = 0, srcY0 = 0, srcX1 = 600, srcY1 = 600, dstX0 = 0, dstY0 = 0, dstX1 = 600, dstY1 = 600 We need to add this blit implementation.
12-04-2023

Attached Standalone and Ensemble8 rendering logs from the point where 3D rendering starts. This was used to compare differences between Standalone and Ensenbme8 rendering.
11-04-2023

Root cause: In Ensemble Simple3DBoxApp we are setting subScene.setFill(Color.TRANSPARENT) thats why it is getting cleared with RGBA (0, 0, 0, 0). Also we set subscene antialiasing to "SceneAntialiasing.BALANCED" in case of Ensemble and this is main reason why we are not seeing Simple3DBox in Ensemble. If we pass null to subscene antialiasing Simple3DBox shows up in Ensemble.
11-04-2023

Update: Created standalone program to replicate Ensemble 3D box drawing, we need to use SubScene and enable depthBuffer on the same and then add PerspectiveCamera. Sample program : import javafx.application.Application; import javafx.scene.Group; import javafx.scene.Parent; import javafx.scene.PerspectiveCamera; import javafx.scene.Scene; import javafx.scene.SubScene; import javafx.scene.paint.Color; import javafx.scene.paint.PhongMaterial; import javafx.scene.shape.Box; import javafx.scene.transform.Rotate; import javafx.scene.transform.Translate; import javafx.stage.Stage; public class Perspective3D extends Application { public Parent createContent() throws Exception { // Box Box testBox = new Box(5, 5, 5); testBox.setMaterial(new PhongMaterial(Color.RED)); // Create and position camera PerspectiveCamera camera = new PerspectiveCamera(true); camera.getTransforms().addAll ( new Rotate(-20, Rotate.Y_AXIS), new Rotate(-20, Rotate.X_AXIS), new Translate(0, 0, -15)); // Build the Scene Graph Group root = new Group(); root.getChildren().add(camera); root.getChildren().add(testBox); // Use a SubScene SubScene subScene = new SubScene(root, 300,300, true, null); subScene.setFill(Color.ALICEBLUE); subScene.setCamera(camera); Group group = new Group(); group.getChildren().add(subScene); return group; } @Override public void start(Stage primaryStage) throws Exception { primaryStage.setResizable(false); Scene scene = new Scene(createContent()); primaryStage.setScene(scene); primaryStage.show(); } /** * Java main for when running without JavaFX launcher */ public static void main(String[] args) { launch(args); } } In this program if i enable log i can see that we are first we clearRTT without depthBuffer enabled and then draw the 3D Box with depthBuffer. All the data related to projViewMatrix, WorldMatrix are same as Ensemble 3D Box and the 3D box gets drawn without any issues. Compared logs between this sample Program and Ensemble 3D Box and i see the same clearRTT with (0, 0, 0, 0) in case of Ensemble8. Looks like in case of Ensemble8 there is no color present in NGSubScene.fillPaint and we end up using transparent (0, 0, 0, 0) color for background fill. Also there are differences like using "FillPgram_Color" in case of Ensemble clearRTT which is dont see in standalone program. WIP.
11-04-2023

Observation: Ran Ensemble with both java and native prism debug logs and went through the logs to see what we are doing differently only in case of simple 3D box drawing in Ensemble8. Parameters that looked different only for 3D are: 1) projViewMatrix values only for 3D rendering have big delta compared to 2D matrices. So i printed these values in OpenGL also and they look same, so this should not be an issue. 2) clear RTT has (0,0,0,0) RGBA values for clear color. Forced opaque alpha value and didnt see any change. Also we dont enable depth buffer clearing while clearing RTT. Also in case of standalone 3D rendering program i see clear color used is (1,1,1,1). Ensemble8: 2023-04-11 10:00:07.100 java[19283:371755] -> Native: MTLGraphics_nClear 2023-04-11 10:00:07.100 java[19283:371755] >>>> MetalContext.clearRTT() 0.000000 0.000000 0.000000 0.000000 2023-04-11 10:00:07.100 java[19283:371755] MetalContext.clearRTT() clearing whole rtt 2023-04-11 10:00:07.100 java[19283:371755] MetalContext.clearRTT() scissorRect.x = 0, scissorRect.y = 0, scissorRect.width = 0, scissorRect.height = 0, color = 0 Standalone program: 2023-04-11 10:56:50.736 java[20524:398935] -> Native: MTLGraphics_nClear 2023-04-11 10:56:50.736 java[20524:398935] >>>> MetalContext.clearRTT() 1.000000 1.000000 1.000000 1.000000 2023-04-11 10:56:50.736 java[20524:398935] MetalContext.clearRTT() clearing whole rtt 2023-04-11 10:56:50.736 java[20524:398935] MetalContext.clearRTT() scissorRect.x = 0, scissorRect.y = 0, scissorRect.width = 0, scissorRect.height = 0, color = 4294967295 3) Only in case of 3D box rendering in Ensemble8 we have perspective projection with depth test. In case of standalone program where i can see 3D primitives we have ParallelCamera without depth test. Ensemble8: MTLContext.updateRenderTarget() :target = com.sun.prism.mtl.MTLRTTexture@4a4c6dbb [format=BYTE_BGRA_PRE physicalWidth=640 physicalHeight=640 contentX=0 contentY=0 contentWidth=600 contentHeight=600 wrapMode=CLAMP_TO_ZERO linearFiltering=true], camera = com.sun.javafx.sg.prism.NGPerspectiveCamera@1d0182c8, depthTest = true Standalone program: MTLContext.updateRenderTarget() :target = com.sun.prism.mtl.MTLRTTexture@612037d5 [format=BYTE_BGRA_PRE physicalWidth=1216 physicalHeight=1216 contentX=0 contentY=0 contentWidth=1200 contentHeight=1200 wrapMode=CLAMP_NOT_NEEDED linearFiltering=true], camera = com.sun.javafx.sg.prism.NGParallelCamera@5c9d19ff, depthTest = false Need to anlayse further from clearRTT and depth testing point of view.
11-04-2023