Gamma / Linear confusion

(note: I’m using 5.3beta, but I believe it has been the same for previous versions)

I’m in the process of upgrading a forward/gamma project to Unity 5 and while I had a bit of success, certain scenes look really washed out. So I’ve been doing a bit of testing between Unity 4 and Unity 5, to see how much light bounces, testing the fall offs etc

Here is a comparison image:

First row, images are very similar! Falloff and amount of bounced light seems to be identical. Second row shows Unity 5 having a lot more bounced light but so does Unity 4 (just somewhat less),they are still “close”-ish.

So what is the problem/confusion?

Let me show you which image is which color space.

So… Uhm? What?

Why is the behaviour in 5 reverse of 4?

Why is Gamma in 5 so extremely washed out?

(no wonder I can’t get my Unity 4 Forward/Gamma project to look remotely the same in 5!).

Is this expected? It doesn’t make sense at all for me. At the very least one of those behaviours must be a bug, right?

Yep, I have found the exact same thing. Lightmapping in gamma is broken, ie. the baked lights looks linear to me. Very little difference between the two.
My post is here http://forum.unity3d.com/threads/lightmapper-uses-linear-color-mapping-when-set-to-gamma.336658/
The lightmap does not match the realtime lights/probes at all…so, sadly, lighting in gammaspace is broken, and has been for a long long time. One of many many serious issues with lighting.
There was a fix done to lightprobes in the 5.3 beta related to gamma. So, if we’re lucky it could be fixed there. I will check that now actually.

Unity should give us a license discount, we are all part of their qa staff :confused:

Update:
So, yep, the problem is still there in the latest 5.3. Realtime lights looks like they are in gammaspace, while the baked version of that light looks very different, something close to linear. The actual color of the light looks correct now though.

Baked gamma is broken in Unity 5… despite being essential for mobile. I’m guessing that during the development of Unity 5, the baking and lighting systems were closely coupled. I suppose UT chose to go ahead and implement PBR on platforms that support it and play catch up with mobile (surely they were aware of the gamma baking issues on release…?). I’m patiently awaiting a fix as well. I have discussed the issue at length:

Problem, in short, is that the baked gamma lighting looks like baked linear lighting.

The bug is listed on the tracker (681444). I can only assume that they are still working on it? From what I understand, the fix is not trivial and touches quite a few source files. I had initially expected a fix as of version 5.3, but testing the 5.3 beta yields the same results. Perhaps we will see it fixed before the end of the year, or maybe in 5.4. Until the issue is fixed, i’m focused on 2d projects only :(.

EDIT: I apparently have a bad memory, you participated in that thread too

Yep :slight_smile: This was my attempt to bring the issue back to forefront and also post my new findings (also it’s not 100% the same issue, but it falls under the general category of Gamma space lightmaps are kinda broken). I also sent a big-ish scene as a bug report to them trying to explain the issue.

Hi! We are aware of the bug and we will look into it, probably for the 5.4 timeframe. 5.3 is too close to release at this point to accept big changes like that because of stability concerns. Once we have a fix in trunk, we can look into backporting it.

2 Likes

Thank you @KEngelstoft

Just a super friendly reminder, now that we are past 5.3 and maybe the time to get this issue fxed is approaching: This is the problem:

Since this is a mobile game, I pretty much have to use Forward and Gamma. Here are pics from Unity 4&5.

Unity 4:

This is a wip, but I’m already quite happy with it. I like the cloudy mood, and the lightmapping has nice details and shadowing in corners even though I have AO disabled. I still have a lot of work to do, but it’s already taking shape.

Unity 5:

I… This took the same time as the Unity 4 version to bake. I can probably bring some detail back, by adding some baked AO (although I really dislike adding AO to the lighting) and maybe enabling final gather (although then it’ll become an overnight bake), but I literally have no idea what I can do to bring some contrast to the lighting. Why is everything this washed out shade of blue? The precompute resolution is at 1.5, which is not enough for details, but it’s definitely enough to get a feel for the general contrast. Where did the dark areas go (and where did the bright areas go? everything is lit by a blue shade of “meh”)? Why is the bottom side of those shades so bright?

And that’s why I can’t move to Unity 5.

I will have to spend a month redoing the lighting everywhere, which, ok whatever, upgrading takes time, if I need to do it, I’ll do it, but then it will also look like THAT?

3 Likes
  1. Can we know what decodeInstructions.xy are?

I’m making my own UnityCG.cginc.

I replaced this line:

return (decodeInstructions.x * pow(data.a, decodeInstructions.y)) * data.rgb;

with:

return pow(data.a,2.2)32data.rgb;

which results in:


Which is not quite there yet, but it’s better than the previous results. Although I am guessing I broke lighting coming from actual lights now.

  1. Also, what are LIGHTMAP_RGBM_SCALE and EMISSIVE_RGBM_SCALE used for?

  2. Also, are the Luminance and/or UnityEncodeRGBM called when lightmapping happens? (does tweaking those affect how lightmaps are saved?)

I experienced exactly the same thing when upgrading a 4.6 project making heavy use of baked lighting. Everything became washed out in Unity 5. The worst thing about the new baked lighting (ok, second worst thing, since the worst thing is its slowness) is how objects no longer appear “planted” in the ground. Your short cylindrical posts/pillars illustrate that perfectly: they look solidly in the ground in the first shot, but then like they’re detached from the ground in the Unity 5 shots – as if they were photoshopped into the image. This means I can’t upgrade to Unity 5 either.

I just retried with the latest Unity 5.4b21.

I’m giving up. Ambient light still has no contrast at all and spreads around uncontrollably, washing out any hint of detail or contrast. The exterior is just as bright as the interior in Unity 5 which makes no sense at all. I’m certain it’s a linear/gamma mix up.

what happens when you raise bounce boost and lower ambient intensity in lighting panel?

I’ll try it (I believe I have in the past), but I think what is needed it the opposite (stronger ambient, but pretty low bounce boost). Bounce Boost doesn’t go below 1 though.

I’ll do more tests tomorrow. I have a couple more things I need to try.

Stronger ambient will just increase the blue-ness and make it more washed out?

I want some blueness that doesn’t bounce too much. 1st bounce should be visible then they should fall off pretty quickly. So strong-ish ambient and low boost/intensity.

Low Ambient but high boost/intensity would just bounce a bit of blue everywhere which is not what I want.

Sooooo… Instead of sleeping, I thought I’d really try to push enlighten to get good results. Sadly I don’t have anything to show. Because 1) I didn’t get any good results 2) I tried to really push the settings, so that enlighten has enough cluster res to produce corner and contact shadows.

But after an hour and a half Unity crashed… so… Awesome…

So I downloaded Stingray.

This is what I got from its lightmapper (not Beast btw… (!) ) after a few seconds.

And you might say that doesn’t look that great. And I might agree. I mean it looks better than enlighten, but that doesn’t say much. It looks a little rough. But it has the right contrast and enough corner shadows. Also, I don’t know what I’m doing in stingray.

Also, in case you missed it in the sentence above the image, this is what I got after SECONDS of baking. SECONDS. Like a few dozen SECONDS

I don’t see why you can’t get that in Enlighten. Give us that wood block model.

But stingray’s lightmapper is beast.

Stingray currently has 2 Lightmapper mate. There is “Beast” and the new Progressive Lightmapper that is currently in Beta stage. I just recently had to use Stingray myself because Unity’s “Enlighten” is severely broken. You would think that it would be in a better state four dot releases into the 5.x cycle but apparently things seem to be getting worse.

I see, well of all the shots above, Unity 4 / beast looks the best to my eyes. Quality matters.