I get situations where if I move the camera, then stop moving, I will frequently see ghost images of my models quite close to where the actual models are. If I disable the multi-sampling, there is no ghosting. The ghost images also disappear the next time my canvas repaints (i. e. the ghosts are only visible for a few moments right after stopping the camera movement).
As far as I can tell, I clear the depth and color buffers correctly. Are there additional buffers I need to clear when using multi-sampling, or am I missing something else? I'm using version 2.1.5-01.
At first, we only maintain the very latest version, which is currently JOGL 2.3.2. We won't backport any bug fix into an older version. I don't remember a bug report about multi sampling but don't take the risk of wasting time on a bug we have already fixed. I won't investigate any further if you stick to an obsolete version.
I can't help you without seeing the whole source code, please post a SSCCE.
I advise you to look at our unit tests and to run your code by using different canvases in order to eliminate some possible root causes. For example, if you already use a GLJPanel, try to disable the vertical flip and the build-in GLSL shader first, then try to run your code with GLCanvas or GLWindow.
Thanks for the pointers. I tried upgrading to 2.3.2, making only the necessary changes to compile (import statements, setSurfaceWidth instead of setWidth). The ghosting issue still occurred, but worse than that is that MSAA seems to have stopped working (at least for items that are farther away).
In the hopes that pictures help, here is the ghosting effect using 2.1.5:
and here is both the ghosting effect, and the lack of anti-aliasing, using 2.3.2:
I'm using GL3 and GLJPanel. I will try your other hints to see if I can find out more. In the meantime, does the change in MSAA ring a bell? I looked through the change logs, but couldn't find any indication that I should be doing anything different. I did try adding "gl3.glEnable(GL3.GL_MULTISAMPLE);" but without success.
Ok I see what you mean by "ghosting effect" now. Some states are lost when using GLJPanel (bug 842, mentioned in the Java documentation of this class), this class has some limitations, making at least a try with GLCanvas or GLWindow should help a bit. Anyway, I can't help a lot without seeing a SSCCE.
Edit.: Please give us much more information about your hardware, GPU, driver version number, ...
Switching to GLCanvas did solve the ghosting issue, but introduced the same anti-aliasing issue I got when upgrading to 2.3.2. The issue occurs both with 2.1.5 and 2.3.2 when using GLCanvas, and with 2.3.2 when using GLJpanel (i.e. the only combination where MSAA works well is 2.1.5 with GLJpanel).
Here is another image that shows the anti-aliasing issue:
Note the horrible look where the white walls meet the grey ceiling. The issue occurs only where two different models come together, but only if the camera is far away (if I move the camera towards the wall the junction becomes a nice smooth line). When using 2.1.5 with GLJPanel, everything looks smooth regardless of distance to the camera.
I'm using Intel(R) HD Graphics 530 (driver version 184.108.40.20673) on an Intel Core i7-6700K, Windows 10, java 1.8.0_74, 32GB memory. Everything is running at factory speeds.
I did find a way to solve the ghosting issue using 2.1.5 and GLJPanel based on your original response. I originally enabled depth testing and blending in the init method of GLEventListener. I now changed it so that I enable them at the start of the display method and disable them at the end of display method.
I will learn how to use FBOs, and in general learn more about jogl / opengl, and hopefully at some point figure out what I am doing wrong with the MSAA so I can upgrade to the latest version and start using GLCanvas. Thanks for the help.
Yes your solution to the ghosting problem is correct, good job :) It's even better than switching to another canvas as you don't suffer of any other GLJPanel's limitation as far as I know.
I suspect that your problem with MSAA comes from a regression in JOGL, please reproduce it with one of our unit tests or with a SSCCE in order to confirm or not my supposition. If it's confirmed, maybe we'll plan to fix it in JOGL 2.3.3 or 2.4.0. Do you reproduce this problem on different hardware? Please can you try with a completely different GPU under Windows 10? If you provide a tiny example to reproduce your problem, I'll give it a try on other machines.