jmonkeyengine icon indicating copy to clipboard operation
jmonkeyengine copied to clipboard

fullscreen mode disables gamma correction

Open stephengold opened this issue 5 years ago • 15 comments

I've noticed visually that applications with gamma correction enabled look very different in windowed display modes than they do in fullscreen. Visual comparisons suggest this is because gamma correction isn't actually enabled in fullscreen mode.

Seen in both v3.2.4 and v3.3.0-alpha5 of jMonkeyEngine with both v2 and v3 of LWJGL.

stephengold avatar Nov 26 '19 18:11 stephengold

I can't reproduce this. Maybe there was something wrong in the code you were testing.

riccardobl avatar Oct 10 '20 16:10 riccardobl

I'll check again.

stephengold avatar Oct 10 '20 16:10 stephengold

I wasn't able to test on Linux due to issue #947. On Windows 7, a simple test with JME 3.3.2-stable and LWJGL 2.9.3 shows noticeable contrast between the viewport background and the stats background:

  1. in a 16bpp 640x480 window with isGamma=true
  2. in a 16bpp 640x480 fullscreen with isGamma=true
  3. in a 16bpp 640x480 fullscreen with isGamma=false

but no contrast (black-and-black) in a 16bpp 640x480 window with isGamma=false.

Here is the test app:

import com.jme3.app.SimpleApplication;
import com.jme3.font.BitmapText;
import com.jme3.math.ColorRGBA;

public class Main extends SimpleApplication {

    public static void main(String[] args) {
        Main app = new Main();
        app.start();
    }

    @Override
    public void simpleInitApp() {
        flyCam.setEnabled(false);
        
        ColorRGBA backgroundColor = new ColorRGBA(0.04f, 0.04f, 0.04f, 1f);
        viewPort.setBackgroundColor(backgroundColor);

        BitmapText statusText = new BitmapText(guiFont, false);
        statusText.setLocalTranslation(0f, cam.getHeight(), 0f);

        String message = 
                "   bpp=" + settings.getBitsPerPixel()
                + "   fullScreen=" + settings.isFullscreen() 
                + "   isGamma=" + settings.isGammaCorrection();
        statusText.setText(message);
        guiNode.attachChild(statusText);
    }
}

stephengold avatar Oct 11 '20 00:10 stephengold

That's the normal behavior. Writing to an sRGB framebuffer causes the color to be gamma corrected, they will look different unless they are linearized beforehand

        ColorRGBA backgroundColor = new ColorRGBA().setAsSrgb(0.04f, 0.04f, 0.04f, 1f);

Textures are linearized automatically

riccardobl avatar Oct 11 '20 07:10 riccardobl

I agree that colors should look different between isGamma=true and isGamma=false, but that's not what this issue is about. The issue is that they don't look different in fullscreen, even between isGamma=true and isGamma=false.

stephengold avatar Oct 11 '20 16:10 stephengold

I can't reproduce...could it be driver specific? Do you get the same issue even with 24bpp color depth?

riccardobl avatar Oct 13 '20 23:10 riccardobl

I suppose it could be a driver-specific issue.

I'm not finding any fullscreen modes with 24bpp color depth. However, I reproduced the issue with 32bpp 640x480 fullscreen.

stephengold avatar Oct 14 '20 04:10 stephengold

Can you try to use native resolution fullscreen with lwjgl3? Also, what drivers are you using, on which gpu?

riccardobl avatar Oct 14 '20 07:10 riccardobl

LWJGL 2.9.3 context running on thread jME3 Main
 * Graphics Adapter: nvd3dumx,nvwgf2umx,nvwgf2umx
 * Driver Version: 23.21.13.8873
 * Scaling Factor: 1
OpenGL Renderer Information
 * Vendor: NVIDIA Corporation
 * Renderer: GeForce GT 545/PCIe/SSE2
 * OpenGL Version: 4.6.0 NVIDIA 388.73
 * GLSL Version: 4.60 NVIDIA
 * Profile: Compatibility

I tested with LWJGL3 at the highest available resolutions and found good contrast:

  • in a 24 bpp 1914x1049 window with isGamma=true
  • in 32 bpp 1920x1080 fullscreen with isGamma=true

but poor contrast (black-and-black):

  • in a 24 bpp 1914x1049 window with isGamma=false
  • in 32 bpp 1920x1080 fullscreen with isGamma=false

In other words, the issue went away with high resolution and LWJGL3. Okay, that's interesting. Do you have a hypothesis that might explain all this?

stephengold avatar Oct 15 '20 01:10 stephengold

I can confirm I am also experiencing the same issue when trying to run full screen.

Since @riccardobl was unable to reproduce the issue, I should note that my device's GPU is a NvidiaGeForce GTX 1080. I still need to test this on my older device with an AMD but will report back with the results when I do.

yaRnMcDonuts avatar Apr 05 '21 06:04 yaRnMcDonuts

@yaRnMcDonuts any news on this issue?

stephengold avatar May 04 '21 17:05 stephengold

I can not reproduce this issue. I am testing with Linux and JME 3.6.0-beta1.

Tested with these GPUs:

INFO: OpenGL Renderer Information
 * Vendor: Intel Open Source Technology Center
 * Renderer: Mesa DRI Intel(R) HD Graphics 3000 (SNB GT2)
 * OpenGL Version: 3.3 (Core Profile) Mesa 20.0.8
 * GLSL Version: 3.30
 * Profile: Core

and

INFO: OpenGL Renderer Information
 * Vendor: X.Org
 * Renderer: AMD CEDAR (DRM 2.50.0 / 5.4.0-58-generic, LLVM 10.0.0)
 * OpenGL Version: 3.3 (Core Profile) Mesa 20.0.8
 * GLSL Version: 3.30
 * Profile: Core

LWJGL 2

fullscreen mode

lwjgl2-fullscreen-mode

window mode lwjgl2-window-mode

LWJGL 3

fullscreen mode lwjgl3-fullscreen-mode

window mode lwjgl3-window-mode

Ali-RS avatar Feb 10 '23 09:02 Ali-RS

And this is how it looks with gamma off:

no-gamma

Ali-RS avatar Feb 10 '23 09:02 Ali-RS

I've tested again on an RTX 2060s with 3.6.0-beta2 and i still can't reproduce :thinking:

riccardobl avatar Feb 14 '23 23:02 riccardobl

I reproduced the issue today, but it wasn't easy: I failed to repro it on Linux, nor could I repro it on my WIndows 11 laptop with an RTX 2070.

Here's what worked for me:

  1. Boot the Windows 7 Professional SP 1 partition on my desktop (the machine with the NVIDIA GeForce GT 545).
  2. Check "Fullscreen?" in the display settings.
  3. Visually compare the display, both with "Gamma correction" checked and unchecked.

After reproducing the issue (no visible difference between the displays) on 3.2.4-stable with LWJGL v2, I rebuilt the test app with 3.6.0-stable and jme3-awt-dialogs and ran it in the same environment. I was still able to repro the issue.

I was also able to reproduce the issue with LWJGL v3 instead of v2.

However, switching from fullscreen to windowed mode with LWJGL v2 made the issue go away: gamma correction had a visible effect.

My best guess would be it's a driver issue, but I can't prove it. The NVIDIA control panel displays the driver version as "388.73"

I'm leaving this issue open for now.

stephengold avatar Apr 09 '23 21:04 stephengold