Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8096017

Depth buffer rendering issues

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P3
    • Resolution: Incomplete
    • Affects Version/s: fx2.0.2
    • Fix Version/s: None
    • Component/s: javafx

      Description

      In a Scene with depth buffering enabled, and perspective camera the scene flickers, hides part of the stuff.. sometimes does not render at all etc
      Without depth buffering all renders ok, but obviouly the objects in the scene overlap etc

      From the tests i made, it looks like the scene struggles with node resizing. If the objects are inside a container and that container is big enough to contain the scene in perspective, normally all looks ok. But when (due to layout resizing, and fitting) the scene is not big enough it starts the rendering issues above.

      I found two rendering issues until now and i built two junk code classes just to trigger them..

      On issue one, multiple Scenes on the same JFXPanel, dont render correctly.

      On issue two, the problem i have in my program appears.. without depth buffering all works, with depthbuffering all hell breaks loose.


      Issue 1
      import javafx.animation.KeyFrame;
      import javafx.animation.KeyValue;
      import javafx.animation.Timeline;
      import javafx.application.Platform;
      import javafx.embed.swing.JFXPanel;
      import javafx.scene.PerspectiveCamera;
      import javafx.scene.Scene;
      import javafx.scene.layout.Pane;
      import javafx.scene.shape.Rectangle;
      import javafx.scene.transform.Rotate;
      import javafx.util.Duration;
      import javax.swing.GroupLayout;
      import javax.swing.JFrame;
      import javax.swing.JPanel;
      import javax.swing.SwingUtilities;
       
      /**
       *
       * @author omega
       */
      public class Issue1 {
          
          public static void main(String[] args) {
              // Application.launch(WS_FXChart_API.class, args);
       
              SwingUtilities.invokeLater(new Runnable() {
                  @Override
                  public void run() {
                      JFrame a = new JFrame();
       
                      a.add(getTestPanel());
       
                      a.setVisible(true);
       
                      a.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
       
                  }
              });
          }
       private static JPanel getTestPanel() {
             
              JFXPanel tmp = createTestPanel();
              JFXPanel tmp2 = createTestPanel();
              JFXPanel tmp3 = createTestPanel();
       
              final JPanel panel = new JPanel();
              GroupLayout layout = new GroupLayout(panel);
              panel.setLayout(layout);
       
              layout.setHorizontalGroup(layout.createParallelGroup()
                      .addGroup(layout.createSequentialGroup()
                      .addComponent(tmp,300,300,300)
                      .addComponent(tmp2,300,300,300)
                      .addComponent(tmp3,300,300,300))
                      );
       
              layout.setVerticalGroup(layout.createSequentialGroup()
                      .addGroup(layout.createParallelGroup()
                      .addComponent(tmp,300,300,300)
                      .addComponent(tmp2,300,300,300)
                      .addComponent(tmp3,300,300,300)
                      )
                      );
       
       
              return panel;
          }
       
       
          private static JFXPanel createTestPanel() {
              final JFXPanel tmp = new JFXPanel();
              Platform.runLater(new Runnable() {
                  @Override
                  public void run() {
                      Pane pane = new Pane();
                      pane.setPrefSize(300, 300);
                      Rectangle rec = new Rectangle(200, 200);
                      pane.getChildren().add(rec);
       
                      Scene scene = new Scene(pane, 1000, 1000, true);
                      scene.setCamera(new PerspectiveCamera());
       
                      tmp.setScene(scene);
       
                      final Timeline timeline = new Timeline();
                      timeline.setAutoReverse(true);
                      timeline.setCycleCount(Timeline.INDEFINITE);
                      pane.setRotationAxis(Rotate.X_AXIS);
                      final KeyValue rotate = new KeyValue(pane.rotateProperty(), -65);
       
                      final KeyFrame rotateXKey = new KeyFrame(Duration.millis(500), rotate);
       
                      timeline.getKeyFrames().addAll(rotateXKey);
                      timeline.play();
                  }
              });
       
              return tmp;
       
       
          }
      }


      Issue 2

      import javafx.animation.KeyFrame;
      import javafx.animation.KeyValue;
      import javafx.animation.Timeline;
      import javafx.application.Platform;
      import javafx.embed.swing.JFXPanel;
      import javafx.geometry.Pos;
      import javafx.scene.PerspectiveCamera;
      import javafx.scene.Scene;
      import javafx.scene.layout.HBox;
      import javafx.scene.layout.Pane;
      import javafx.scene.layout.Priority;
      import javafx.scene.layout.VBox;
      import javafx.scene.shape.Rectangle;
      import javafx.scene.transform.Rotate;
      import javafx.util.Duration;
      import javax.swing.GroupLayout;
      import javax.swing.JFrame;
      import javax.swing.JPanel;
      import javax.swing.SwingUtilities;
       
      /**
       *
       * @author omega
       */
      public class Issue2 {
       
          public static void main(String[] args) {
       
              SwingUtilities.invokeLater(new Runnable() {
                  @Override
                  public void run() {
                      JFrame a = new JFrame();
       
                      a.add(getTestPanel());
       
                      a.setVisible(true);
       
                      a.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
       
                  }
              });
          }
       
          private static JPanel getTestPanel() {
       
              final JFXPanel tmp = new JFXPanel();
              Platform.runLater(new Runnable() {
       
                  @Override
                  public void run() {
          
              Pane p = createTestPane();
              Pane p2 = createTestPane();
              
              Rectangle rec = new Rectangle(200,200);
              Rectangle rec2= new Rectangle(200,200);
              
              VBox middle = new VBox();
              middle.setAlignment(Pos.CENTER);
              middle.getChildren().addAll(rec,rec2);
              VBox.setVgrow(rec, Priority.ALWAYS);
              VBox.setVgrow(rec2, Priority.NEVER);
              
              HBox footPane = new HBox();
              HBox.setHgrow(p, Priority.ALWAYS);
              HBox.setHgrow(p2, Priority.ALWAYS);
              HBox.setHgrow(middle, Priority.NEVER);
              middle.setPrefWidth(40);
              middle.setMinWidth(40);
               footPane.getChildren().addAll(p,middle,p2);
              
              Scene scene = new Scene(footPane,1000,1000,true);
              scene.setCamera(new PerspectiveCamera());
              
              tmp.setScene(scene);
                      }
              });
              
              final JPanel panel = new JPanel();
              GroupLayout layout = new GroupLayout(panel);
              panel.setLayout(layout);
       
              layout.setHorizontalGroup(layout.createParallelGroup()
                      .addGroup(layout.createSequentialGroup()
                      .addComponent(tmp)));
       
              layout.setVerticalGroup(layout.createSequentialGroup()
                      .addGroup(layout.createParallelGroup()
                      .addComponent(tmp)));
       
       
              return panel;
          }
       
          private static Pane createTestPane() {
              Pane pane = new Pane();
              pane.setPrefSize(300, 300);
              Rectangle rec = new Rectangle(200, 200);
              pane.getChildren().add(rec);
       
              final Timeline timeline = new Timeline();
              timeline.setAutoReverse(true);
              timeline.setCycleCount(Timeline.INDEFINITE);
              pane.setRotationAxis(Rotate.X_AXIS);
              final KeyValue rotate = new KeyValue(pane.rotateProperty(), -65);
       
              final KeyFrame rotateXKey = new KeyFrame(Duration.millis(500), rotate);
       
              timeline.getKeyFrames().addAll(rotateXKey);
              timeline.play();
       
              return pane;
          }
      }

        Attachments

          Activity

            People

            • Assignee:
              ckyang Chien Yang (Inactive)
              Reporter:
              duke J. Duke (Inactive)
            • Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Imported: