I’m attempting to follow this Medium article: Always Be Linear - Medium Article Following this method instead of switching the project to Linear as I need UI to stay Gamma.
This article however is a little outdated compared to my current Unity version (2022.3/URP 14), and I’ve gotten pretty close but there’s still a couple minor lighting issues. The article works fairly well up until the “Lighting.HLSL” file, and thats where the URP versions diverge from what I can tell. I’ve been bumbling around the “GlobalIllumination.HLSL”, but that’s where I’ve lost the trail for fixing this.
My biggest issue is this newer version of URP, the lighting HLSLs are greatly updated, and I can’t find where all I need to update the code, or if it’s more complicated than just shoving in “if gamma, pow 2.2” in a new location.
Images below are both the default URP Lit shader, with a metal value of 1 and smoothness of .5. The surface lighting and gradients just aren’t nice/soft enough like Linear.
(Gamma vs Linear)
Hi, I think you are on the wrong path here. The changes described in the medium article are a workaround only justifiable for devices that don’t support floating point textures (ie only supporting OpenGL ES 2.0, ie prehistoric devices). Even if you were successful in implementing it, it would bring you a new world of issues (among them, color space problems with transparent surfaces, lack of lighting precision).
What you might want to do is to either modify your UI shader code to counteract the gamma correction, or composite your UI on top of the framebuffer once the rendering is complete. It might also have to do with your texture import settings.
I tried a first pass of changing the UI but ran into some issues. If it’s not worth going down the path I am now though, I’ll give the UI another try. There are some other lighting complications that I didn’t think about till yesterday, so fixing Linear UI is starting to sound like the better path. I’ll do some more work and see what happens to me then…
Thanks for the reply!