Gamma correction Implementation

Hello.
as a follow up to this post http://hub.jmonkeyengine.org/forum/topic/gamma-correction-woes/, I implemented Gamma correction in the engine.
This is available in the latest master

Here is the complete doc on how it works https://wiki.jmonkeyengine.org/legacy/doku.php/jme3:advanced:jme3_srgbpipeline

Please feel free to ask for precisions, I’ll gladly add some details in the doc.

without gamma correction

With gamma correction

With gamma correction and adjusted color and lights values

6 Likes

This is really cool. I read the article from nvidia a few months ago but didn’t know enough about shaders to do anything. Thank you!

I’ve tried it and its working really great, texture colors and light intensity are much more predictable now.

I’ve noticed two problems so far, first is that the material editor has a problem with the -LINEAR tag, it shows up as part of the parameter name, and tries to asign it to for example “NormalMap -LINEAR” (if i edit the linear part out in the source file the material works).

Second, your change to the clamping in ColorRGBA broke the layer painting in the terrain editor for me.

@Perjin said: I've noticed two problems so far, first is that the material editor has a problem with the -LINEAR tag, it shows up as part of the parameter name, and tries to asign it to for example "NormalMap -LINEAR" (if i edit the linear part out in the source file the material works).
Thanks, yeah the thing is the SDK does not use the version of JME with gamma correction so that'll be an issue until we get nightly back. Also I need to go through the SDK to handle gamma correction properly there too. The color pickers will use the set/getAsSRGB methods of ColorRGBA, and I'll make an option to enable gamma correction in the scene viewer.
@Perjin said: Second, your change to the clamping in ColorRGBA broke the layer painting in the terrain editor for me.
that's strange....you sure it's the clamping? maybe the change of interpolate to interpolateLocal?
that’s strange….you sure it’s the clamping? maybe the change of interpolate to interpolateLocal?

I just recompiled my sdk and the only thing i reverted from your commit was the change to the clamping method, and the painting does work now. I don’t know might this be some kind of rounding error from the int to float and back conversion?

i didnt know this was an issue, but after reading your explanation and seeing pictures i see the difference and i completely agree. thanks for spending the time to implement this!

I’m thrilled to see this. I can’t say it bothered me… but it made low lighting very difficult.

Really awesome work (as always)

1 Like

Very nice. It looks really great.