Forum rules - please read before posting.

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

2»

Comments

  • edited January 2020

    What is your active colour space set to? And what's your render pipeline?

    It may be easier to just expose this setting as an Inspector control.

  • I'm using linear space, standard render pipeline. It's strange that it's working when explicitly setting linear space to false in the crossfadetexture, very counterintuitive. An inspector control setting would be helpful so we don't have to edit MainCamera.cs.

  • I wonder if the answer is instead to not specify any kind of colour data at all. Try replacing the line instead with:

    crossfadeTexture = new Texture2D (ACScreen.width, ACScreen.height);
    

    Certainly on my end, that seems to work for both colour spaces.

  • Hey all,

    have you solved this issue in any way?

    I am running AC 1.71.4 and Unity 2019.3.0f6 on a Mac in Linear Color Space using Universal Render Pipeline, and whenever I crossfade between scenes, the screenshot taken for the crossfade effect is far too light!

    It looks as if the screenshot gets rendered in additive mode on itself …

  • I wonder if that's down to the use of URP.

    Try replacing line 1970 of MainCamera.cs with either of the following:

    crossfadeTexture = new Texture2D (ACScreen.width, ACScreen.height, TextureFormat.RGBA32, false, true);
    

    and:

    crossfadeTexture = new Texture2D (ACScreen.width, ACScreen.height, TextureFormat.RGBA32, false, false);
    

    Do either of those remedy it?

  • edited June 2020

    deleted

  • edited June 2020

    No.
    Both options result in scene A cut to black and scene B fading in from black.
    The screenshot of the previous scene is not rendered at all.

    But that is true also for the original line 1970.

  • I was mistaken - the crossfade texture during a scene-switch is actually set in the TakeOverlayScreenshot function, line 638.

    It may be that it needs a specific TextureFormat value, too.

  • As I just noticed: currently crossfading does not work for me at all (after updating from 1.69.something to 1.71.4)

  • OK, after some testing I decided to open a separate thread: Crossfading scenes no longer seems to work

  • I finally got rid of the white flash on crossfades when building to Switch by enabling the Generate textures in Linear color space in the Settings, yay! (It worked without this when building to PC, so have to check if this affects PC builds now). However, screenshots when saving games appear too dark with this setting enabled, but it appears to be fixed by editing the SaveFileHandler from

    screenShot = new Texture2D (KickStarter.saveSystem.ScreenshotWidth, KickStarter.saveSystem.ScreenshotHeight, TextureFormat.RGB24, false);

    to

    screenShot = new Texture2D (KickStarter.saveSystem.ScreenshotWidth, KickStarter.saveSystem.ScreenshotHeight, TextureFormat.RGB24, false, true);

    Will do some more testing, but it looks like I'm finally getting closer to this working :)

  • Would this be a change to make for Switch only, or are save-game screenshots dark on PC as well?

  • Sorry for all the back and forth with this. I discovered that enabling Linear space textures in AC, while working fine on the Switch, caused a big slowdown when taking screenshots. This caused a very abrupt behaviour in my game when auto-saving, so I decided to disable Linear textures in AC.

    Instead I edited the TakeOverlayScreenshot function in MainCamera.cs and instead of checking the KickStarter.settingsManager.linearColorTextures value, I just wrap the SetPixel code in a #if UNITY_SWITCH conditional.

    I also reverted to the old line from my previous post in this thread.

    This means that the game still uses linear space textures for crossfades - without the pesky white flash - and while it takes a few seconds to render this screenshot it doesn't really matter so much since it's a transition effect.

    So, for the Switch version, I now have nice camera crossfades (though a little laggy, but that's par for course with a weak CPU) and snappy screenshots with correct colours working.

    The PC version also now works as it should, with linear crossfades working with no color shift and screenshots looking normal without any stutter.

    NOTE: You have to create builds on all platforms to check that this is working, in the editor it still looks terrible. And it's really annoying that Unity does not make this work out of the box. I've read other threads on linear space problems on different platforms, so this could well behave differently in some other build.

    I'm not sure if any changes should be done to AC itself, as my project is specific to both PC/Switch. Other PC developers should probably chime in and check how the game behaves in linear space with the Generate Linear Textures setting on and off.

  • I did some testing of my own on PC and it does seem that the extra "true" parameter should be there if you've enabled AC's own linear-space texture option. Please correct me if I'm wrong on that.

    The lag is - I suspect - due to the algorithm having to loop through every pixel in order to update its color space. But so far as I can see, there's no way to have Unity do this otherwise.

  • Yes, I believe the true parameter should probably be present on PC with linear-space texture option enabled - but it does introduce some lag when taking screenshots. I think you're correct in assuming the pixel looping is to blame, and there's probably no way around that.
    But what's weird is that linear space is seemingly working with the AC linear textures setting disabled, at least on my PC builds. I don't know how or why! :) Maybe I'll have some more time to investigate later on after my game has been released. I'll report any findings if it could be helpful, and others should probably chime in if they have any input.

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.