Gamma colorspace supported?

Our game was created with the built-in render pipeline and Gamma color space, and we’re seeing some pretty big color differences on the device when compared to the Editor. It actually looks closer to Linear colorspace on device, even though we built with Gamma. Do you intend to support Gamma?

For example, here is a black to white gradient using gamma mode in editor:

When viewed on device, it looks like this:

For comparison, here is the exact same scene in editor with linear colorspace (note the gradient is crushed to the left side):

And here is linear on device:

On device, it seems both versions are nearly the same…

We’d really like to be able to use Gamma mode if possible, otherwise we have to retune all our shaders. Is there another way to get the exact look of our Gamma color treatment? I have tried Unity’s built-in GammeToLinear shader function, but it also doesn’t look the same for us (tho a little closer). Any guidance would be much appreciated!

I forgot to mention, when you run on device in Gamma mode, you see this printed in the console:

Requested RenderTexture with sRGB format. sRGB formats are not supported in gamma mode, fallback to a UNorm format. Use a UNorm format instead of sRGB to silence this warning.

Maybe related to why it doesn’t look as expected?

Gamma mode is not supported. This is basically a limitation of visionOS’s MaterialX/lighting support, and I’m not aware of any plans on Apple’s side to support gamma mode.

That said, if you explain further what you’re actually trying to achieve with gamma mode (apart from “match the output of Unity’s gamma mode”), maybe I can help with specific conversions. For example, when you say “here’s a black to white gradient using gamma mode,” do you mean a texture? Vertex colors? Values generated in a shader graph? Rendered in visionOS using an unlit material? A shader graph material? Color space conversions happen at many places in the pipeline, so I would need a lot more context. If it helps, you can submit a bug report with an example project to show exactly what you’re doing.

For instance, you mention using a RenderTexture. If you were just rendering to that RenderTexture in a Unity gamma mode project, and wanted to display it in visionOS in the correct color space, you could render it in an Unlit shader graph material that samples the texture and raises the result to the power of 2.2 (to convert from gamma to linear). There is a Colorspace Conversion node in shader graph, but PolySpatial currently doesn’t support the RGB/linear conversions from it (though that’s something I will put on the list to add soon).

Thanks for getting back to us on this. First, I want to mention that we don’t use PolySpatial, and instead use the legacy Metal rendering backend (i.e. fully immersive with the built-in render pipeline and custom shaders not built using the Unity Shader Graph). Does this mean that, in theory, gamma mode could be supported like it is on other iOS Metal-rendered apps?

The look of our game is highly stylized and relies mostly on Unlit shaders (with shadows disabled) that produce smooth gradients in a variety of ways (and built in Amplify Shader Editor). In the example I showed, that was displaying the U texture coordinate as a color. We often make gradients from UVs, world position, and occasionally by sampling textures. Often there are power functions and multipliers in these shaders to slide into just the right place to get a particular look, likely compensating for the behavior of color in gamma space. At the moment, I don’t believe we have any specific effects that use render-to-texture (other than what Unity would do for VR rendering).

We’ve tried temporarily installing a color grading post effect to see if we can find a global conversion that gets close to the look in gamma mode, but have been struggling. We have hundreds of hand tuned shaders built over years, so its daunting to find a path to get the game looking good again without reworking all of them.

We can start to break out some more specific examples if it helps, but before we do that, I’m hoping my comments about using the legacy Metal rendering might help our case?!

Oh, sorry, I didn’t realize. Yes, I would expect gamma mode to be fully supported with the Metal backend (though that’s not my particular area of expertise). If that’s not working, it’s probably worth submitting a minimal repro case (perhaps that gradient example) as a bug report. The “fallback to UNorm format” error maybe makes more sense to me in this context; if the Metal backend is interpreting the UNorm texture (containing colors that are actually in gamma space–that is, sRGB) as linear, it could be applying gamma correction (i.e., raising it to 1/2.2). That would result in colors being “blown out” (e.g., a value of 0.5 would end up being 0.73), which seems to match what you’re seeing. I notice that your gradients are also not reaching 1.0 (that is, fully white) on device, which suggests to me that tone mapping is being applied.

@mtschoen might be able to help more with the immersive mode issues.

This gives us hope, thanks!! I’ll create a simple repro project in the morning for @mtschoen

OK @mtschoen , I’ve created a repro project here:

I also uploaded a bug report (with the repro project attached), with the bug #: IN-58458

In the editor, the test scene looks like this:

But on device it looks like this:

Thanks, help is much appreciated!

Hey there!

Gamma color space is not supported by our XR SDK provider in VR mode. We’ve added a project validation rule for this which will be present in the next release.

Thanks for getting back to us. Can you provide any more context here? Is this technically not possible due to constraints on Apple’s side, or is it something that could be implemented on the Unity side in the future? Thanks :slight_smile:

1 Like