The importance of gamma correction

I just played around with this options for spoxel:

It is going to require a lot of color re-balancing I think, but I like that it is lighter. Would be nice to have some control over the amount of gamma correction though.

I should note that I do not say it blindly. Remy’s credentials are such that i possess no argument to counter it. Its his field :stuck_out_tongue:

1 Like

You might be misunderstanding what the gamma checkbox does. It basically makes lighting interpolation linear as regular image textures are then properly converted from sRGB into linear space.

The ‘gamma setting’ that some games use to essentially control brightness is a separate issue, I think.

Basically, lighting is not correct if it’s done in srgb space… which is what non-gamma does. The linear interpolations that are done can’t be correct… even if some of us enjoyed that effect and included it as part of our aesthetic.

1 Like

I’m guessing you also rolled your own lighting shaders and/or spent a lot of time tweaking how things get darker in the non-lit voxels. Mythruna has a similar issue with gamma.

These are the cases where a proper gamma pipeline will totally screw things up… for those of us who have carefully crafted our lighting curves (in my case based on many man-weeks of tweaking and trial an error). This is why I will just leave gamma off in Mythruna. It ruins it, basically.

Yea, I pretty much handle lighting completely through my own shaders. Most of my textures are “lighter” to account for this. I like the scene being “lighter” so I may re-balance things anyways. We’ll see. Either way it is just a flag so it doesn’t bother me if the default changes.

After reading all these posts I can’t help but think: “If these are the most gamma-correction-educated monkeys, then what about the rest?”

So yeah… go on and remove the switch. It definitely is the lesser evil.

The opengl pipeline gamma correction feature doesn’t allow to tweak the gamma correction value.
That’s the only caveat of the system.
However… do you tweak the gamma value when you save your PNGs? I doubt it. You take whatever default there is which is most probably around 2.2. That’s what opengl uses.
The point of this is not to adjust display colors, it’s to ensure a linear color space in the rendering pipeline, and to output as srgb on the monitor.

If you want to tweak visuals, you can use a contrast/colorbalance filter. I could even provide one in the engine… we’ll see

@glh3586 To me the main issue here is your sky. If it’s a backround color and not a texture, you can just use the setAsSrgb method of the ColorRGBA class, it will convert to color to linear space and you should have the same color than without gamma correction.

Yeah that’s why it’s important to use it from the start to avoid this issue…
And that’s why it will stay as a commutable option.

1 Like

I think the best approach is to have your textures in linear space already. Then as for the final linear to gamma conversion, a simple post process will do eg. “pow(colLinear, vec3(1.0 / gamma));”.

I will enable gamma correction by default in jMB as well :wink:

I don’t know if it is related, but I’ve seen that scenes look differently in the engine and the SceneComposer. In the SceneComposer the contrast seems to be higher (or maybe actually, the scene looks darker). Is this related to gamma correction? Is the SceneComposer running with gamma correction on?

sounds more like a lack of ambient light, to me.

I cant tell you if the sdk is using Gamma Correction or not, but I do know that the blender importer throws some warnings about Color Spaces at times.

However Paul might be right. The Light bulb in the sdk is only a point Light which follows the camera iirc

I have my lights in the scene, so I doubt it. But maybe I’m imagining things and it’s due to filters or something. I just took another look and now it doesn’t look so different.

Yeah, I just know the first thing I do in my scenes in my game is add a directional light and an ambient light and make sure all of the materials have ambient colors. The SDK doesn’t do that… so my in-game scenes will always look brighter on the back sides, etc…

I think I added gamma correction in the SDK back then but I think it can be disabled in the option dialog.

but the Scene Editor in jMB shows the same result as in your game :wink:

I see, hm well why was there an option to turn it on/off at all? I mean it’s not like anything could ever use incorrect rendering.

Shouldn’t it just…not effect unshaded stuff then? Since it’s about lighting in the first place?


https://i.imgur.com/P9OwH11.png

https://i.imgur.com/1ufd2Qe.png

It’s like somebody used a can of bleach hah. Also all blue stuff is now cyan because reasons.

Hey I can just set the gamma filter to max and get about the same thing.

https://i.imgur.com/2CmlNFn.png

1 Like

Well because there is legacy. Before 2014 we didn’t have gamma correction.

Well… depends. A color you set in the engine by doing new ColorRGBA(0.5,0.5,0.5,1.0) is considered in linear space when you use gamma correction. But this color will be converted to srgb when rendered on screen, so it will look brighter than you expect. To resolve this ether you turn gamma correction off, either you set it on and you do
new ColorRGBA().setAsSrgb(0.5,0.5,0.5,1.0). this will Linearise the color and then it will be converted back to srgb when rendered on screen. so you will have exactly a 0.5,0.5,0.5 color on screen.
So it can affect unshaded yes.

Again… this is not about having a “nice image output” or having “almost the same result”, it’s about having linear colors to work with in the lighting shaders. and then convert these colors back in a space that the monitor expects.

I’m gonna put an end to this discussion because I’m getting a bit tired to re explain things again and again.
Gamma correction will be enabled by default in 3.3.
Why? : Because it doesn’t makes sense for any new project to not have it especially when you use any lighting model like PBR or phong. I don’t want to see people doing a new project with fancy PBR models and not have gamma correction on because “I didn’t know what it did so I didn’t check the box”.

If you started your game month/years ago without gamma correction and you have tweaked your visuals so that it looks good to you, just disable it and you’ll be fine. Nobody will complains that’s the lighting is wrong anyway since you tweaked your lighting so that it’s not obvious.

8 Likes

Finally I understand why that quad wasn’t colored the way I wanted…:expressionless: