Enabling GammaCorrection on the canvas causes the scene to darken

Recently I turned on GammaCorrection for my game.
I also use canvas mode.
When GammaCorrection is enabled on the canvas, the entire game screen becomes very black.
When disabled, the screen is the same as the regular window.
This looks like a bug.


Gamma correction is enabled on the regular window


Gamma correction is enabled on the canvas

I searched the forum but nothing helped.
So I tried to solve this problem myself.
After I compared the differences between LwjglCanvas and LwjglDisplay.

I found that LwjglDisplay sets GammaCorrection after “Display.create”
But LwjglCanvas is set before it.

So I copied the GammaCorrection setting and placed it after “Display.create” like this:

Luckily, this code works!

But I don’t know if this is the right way to handle this problem,
I’m not familiar with LWJGL, but I hope this helps someone else.

My test environment:
win10, openjdk-11, RTX3060, jme3.6.1, lwjgl2

2 Likes

What does it look like without gamma correction turned on?

1 Like

well, im not specialist here, but GammaCorrection or rather sRGB as far as i know is new standard now.

and now its default in JME since some version i remember.

you no need do this 2 lines on screenshot (maybe you did setup them incorrectly before, because i belive gamma correction setting should setup SRGB itself)

linearize setting even if not true, it know if fix color or not.

But the thing you need to be carefull about is providing custom color.

like

new ColorRGBA().setAsSrgb(

About textures JME automatically convert them,

unless you have -LINEAR in j3md that you need use for normalmaps/etc. (-LINEAR skip conversion)

Previously! I had GammaCorrection turned off by default due to some compatibility reasons, but recently I decided to turn it on and discovered this issue.

I don’t know if I’m the only one having this problem, maybe I didn’t do enough testing.

With GammaCorrection turned off, the scene looks the same.
You can see the image below.


Gamma correction is disabled on the regular window.


Gamma correction is disabled on the canvas.