1

In JavaFX, when accidentally two surfaces of two shapes are overlapping, their rendering is somehow dirty, trying to use both materials.

enter image description here

I tried to avoid it by adding 1 pixel extra height of one of the shapes which works as long as I don't zoom out and the 1 pixel difference dissolves. Then the effect reappears. It is more distracting as this "pattern" flashes when I move the objects.

Is there a way to avoid this behaviour?

Balage1551
  • 1,037
  • 1
  • 10
  • 28
  • Did you configure the JavaFX 3D environment correctly? Have a look at the class SubScene and its contructor. – mipa May 15 '19 at 11:31
  • @mipa With respect, it is not clear what I should see in the constructor. If you try to give me the hint to enable depth buffer and AA, both are done. The problem appears when two objects has the same plane for one of their side, meaning either of them could be the one visible. It wouldn't be a problem, but it seems that when the distance (corrected by zoom) gets too close, the same happend, in spite one of the object faces are clearly "above" than the other. – Balage1551 May 15 '19 at 14:22
  • Yes, that's what I meant. You should also check your near and far clipping pane. From the docs: "Don't set the near clipping value to a smaller value than is needed or the far clipping value to a larger value than is needed because strange visual artifacts may start appearing." – mipa May 15 '19 at 20:18
  • I've always used this approach of moving both contacting surfaces a small distance away. Not sure if this could be a bug, but it is also hard to say which surface should be rendered on top. – José Pereda May 26 '19 at 17:40
  • @José: I use this approach too, it isn't hard to do and works quite well, as long as I don't zoom out enough that the distance between the surfaces reduces under a threshold. Then the two surfaces would overlap again. I have an option to subtract the two shapes which wouldn't be too hard and would work as long as I only operate with boxes only. With circular shapes this wouldn't be so easy. – Balage1551 May 27 '19 at 06:35

0 Answers0