Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make depth buffer work for sub scene in JavaFX

I've created sub scene to display 3D objects and I've got some issue with depth buffer presented below.

Spheres are same size of course.

In fxml file I've got

<SubScene fx:id="subScene" depthBuffer="true">

and subScene.isDepthBuffer() returns true.

I event tried creating SubScene with

subScene = new SubScene(root, 800, 800, true, SceneAntialiasing.BALANCED);
pane.getChildren().set(0, subScene);

with no luck.

Would be grateful for any help. I also would like to know is it just some JavaFX bug or I'm doing, or understanding, something wrongly.
Thanks in advance.

like image 618
kcpr Avatar asked Oct 24 '25 19:10

kcpr


1 Answers

Finally I solved this problem. Depth buffer didn't work because I had

camera.setNearClip(Double.MIN_VALUE);

which was not my best idea. Changing it to

camera.setNearClip(0.01);

solved the issue.

like image 142
kcpr Avatar answered Oct 26 '25 07:10

kcpr