Forum rules - please read before posting.

[Camera: crossfade] not working correctly in linear space.

The Texture2D created in "MainCamera.cs" for the Crossfade Action does not bypass the sRGB sampling; so it doen't look right in linear space.

The fix for this is very simple, you just have to set the bool "linear" of the texture to true. In the line 793 of MainCamera.cs change from
crossfadeTexture = new Texture2D (Screen.width, Screen.height, 0, 0, false)
to
crossfadeTexture = new Texture2D (Screen.width, Screen.height, 0, 0, false, true)

I thought I should share this information in case someone finds it useful. Aaand sorry for my english!

Comments

  • Thank you!  I would like to add this in officially - do you know if this change will affect the look in non-linear space?
  • It should not. I tested it and i'm certain it doesn't. However I'm not 100% sure if that is the case for platforms that don't support linear color space. If you want to make sure no problem will happen, you can check the color space the unity player is in with "QualitySettings.activeColorSpace == ColorSpace.Linear" and create the texture accordingly.
  • Good suggestion - look out a correction in v1.55.
  • Sorry for digging up an old corpse, but I just switched my project over to Linear space and now I get a bright flash whenever I do a Crossfade Action. Are there other settings that need to be adjusted for this to work? I'm on Unity 2018.3 and latest AC.

  • The latest AC does account for the active colour space when creating a crossfade texture. What colour space are you working in?

  • I changed my project to Linear Space. I realised I'm on AC 1.68.1, has there been any changes regarding this in the latest update?

  • No, none. I shall attempt a recreation.

  • So far as I can tell, this is an issue with Unity. The screenshot texture is linear, and there are threads on the Unity forums about issues with screenshots in linear space. None that I've found reveal a solution, unfortunately.

  • Ah, thanks. Always worrying when Unity itself is the culprit, they don't have the best reputation for fixing old issues.

  • I've found a workaround for this issue, I loop through the screentexture's pixels and set them to linear. This makes the white flash disappear when crossfading from one scene to the next!

    private IEnumerator ExitSceneWithOverlay ()
    {
    yield return new WaitForEndOfFrame ();
    Texture2D screenTex = new Texture2D (Screen.width, Screen.height, TextureFormat.RGB24, false);
    screenTex.ReadPixels (new Rect (0f, 0f, Screen.width, Screen.height), 0, 0, false);
    for (int y = 0; y < screenTex.height; y++)
    {
    for (int x = 0; x < screenTex.width; x++)
    {
    Color color = screenTex.GetPixel(x, y);
    screenTex.SetPixel(x, y, color.linear);
    }
    }
    screenTex.Apply ();
    SetFadeTexture (screenTex);
    KickStarter.sceneChanger.SetTransitionTexture (screenTex);
    FadeOut (0f);
    }

  • Nice work! Permission to integrate into AC proper?

  • Of course! Maybe this should be wrapped in a linear space check, I don't think it's needed if you work in gamma space.

  • Yes, indeed - however, it seems to only work on my end when replacing "color.linear" with "color.gamma" - even in linear space.

    This may be platform-dependent. So far I've tested with a Mac - are you using a PC?

  • Yes, I'm on PC, building for Switch at the moment.

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.
Do NOT follow this link or you will be banned from the site!