Gamma Correction (Issue) in Lemur

Good evening,

I have recently opened an old project - mainly just Lemur stuff right now - and updated to JME 3.4.
I was aware of the change to gamma correction as mentioned in forum and release note. I have also read info in the wiki.

With Gamma correction turned on my screens are washed out. If I turn it off, it looks as before.
To be honest I am not sure if I understood the wiki content about gamma correction at all…but for me it seems it would be an advantage to have gamma correction turned on.

In my lemur I am using styles and define them like

        Texture txt = getApplication().getAssetManager().loadTexture("/Pic/461223142.jpg");
        QuadBackgroundComponent bgc1 = new QuadBackgroundComponent(txt);


    private static final ColorRGBA txtfieldbgcolor = new ColorRGBA(137f/255f,180f/255f,255f/255f,0.2f); 
    private static final ColorRGBA textfieldcolor =  new ColorRGBA(ColorRGBA.LightGray);

After I found this post post saying things in JME might look messed up I wonder:

How can I - with gamma correction turned on - change my colors/settings in a way that it looks as before?
Currently I have all my styles/colors/pictures used in one AppState and its not to much (I hope) effort necessary to make the changes. If gamma correction on gives me advantages I am willing to implement changes now.

As usual I am open for suggestions and ready to learn new stuff.

1 Like

I have never solved this problem either and when I originally tried to track down the issue, I was stymied.

At first I thought maybe the hard-coded color values in the style needed to be passed into ColorRGBA.asSrgb() or whatever. But when I created a test app that would display my UIs over a black background for easy color comparison, I found no differences in the colors at all.

…which to me indicated that it might be a transparency difference. I never got a chance to look into it further and have just been leaving gamma off ever since.

In the intervening years, I started to wonder if the fact that alpha calculations in the shader would be done in linear color space could be the issue. Probably mixing two colors at alpha 0.5 produces different results if those colors are linear (and then gamma corrected) versus srgb.

That’s just a guess, though. And it sucks because it basically means that the picking of UI colors needs to be done from scratch and hand-tweaked to make them look right with gamma.

1 Like

I did some testing and checking in the morning, looking to ColorRGBA.class (calculating values by hand, comparing etc) and changing the values in my project.

When I had changed only a part of my “hard coded” styles I did not see a difference, if there was several layers on top of each other (e.g. a listbox with background and a selector). But I could see the difference if text was displayed over an image. I also realized that I had only a few colors with an Alpha <> 1.

Finally I changed all my colors like e.g.

    private static final ColorRGBA sliderbackgroundcolor = new ColorRGBA().setAsSrgb(137f/255f,180f/255f,255f/255f,0.6f);

For the moment I am not sure if there is an issue with Colors where Alpha <> 1!
It did not matter if I changed a color with Alpha 1 or <> 1. The difference is only visible if all colors are transformed. While rereading the gamma correction wiki entry I think thats all what I needed to do. Images are “auto” transformed for gamma correction when loaded with the asset loader and the label and text colors got correction via code.

I also read a bit more about gamma correction in general: Hope it wont bother me again and that the result look the same on all screens.

And finally I would say - I hopefully have solved the gamma correction issue in my case by just transforming all the Color entries as mentioned above…


I’m glad you got it working. I will keep this in mind the next time I look into the problem locally.

I also realized, that in the GuiGlobal.class gamma correction is already done!

I dont know what in the end the the Color is used for, but the function is called quiete often during the update loop.

I thought I’d played around with this before and it turns out I had. :slight_smile:

In my own case, converting all of my style colors to use srgbaColor() instead of color() didn’t seem to fix me issue (suspicion is that alpha also comes into play as said previously).

I don’t know why it’s called so often, though… unless you are creating components a lot I thought most things would only use it for styling scripts.