{"id":28459971,"url":"https://github.com/cinight/psblendmodes","last_synced_at":"2025-07-02T12:31:14.466Z","repository":{"id":289720655,"uuid":"956716481","full_name":"cinight/PSBlendModes","owner":"cinight","description":null,"archived":false,"fork":false,"pushed_at":"2025-04-25T09:32:49.000Z","size":8697,"stargazers_count":10,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"6000.0","last_synced_at":"2025-06-07T01:39:26.231Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cinight.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-03-28T18:25:45.000Z","updated_at":"2025-04-26T08:14:11.000Z","dependencies_parsed_at":"2025-04-24T18:38:39.536Z","dependency_job_id":"cadcb9b9-d714-4391-9818-19801c237ed2","html_url":"https://github.com/cinight/PSBlendModes","commit_stats":null,"previous_names":["cinight/psblendmodes"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/cinight/PSBlendModes","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cinight%2FPSBlendModes","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cinight%2FPSBlendModes/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cinight%2FPSBlendModes/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cinight%2FPSBlendModes/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cinight","download_url":"https://codeload.github.com/cinight/PSBlendModes/tar.gz/refs/heads/6000.0","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cinight%2FPSBlendModes/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263140242,"owners_count":23419842,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-06-07T01:39:27.802Z","updated_at":"2025-07-02T12:31:14.458Z","avatar_url":"https://github.com/cinight.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# CameraColorSpaceWorkaround\n\n\u003e [!NOTE]\n\u003e Unity 6.0+ and Universal Render Pipeline (URP) only. See branches for other versions.\n\n\u003cbr\u003e\n\n## What’s happened?\n\nAfter artists designed UI sprites in Photoshop, they exported the images into Unity and assembled the UI, the colors on the semi-transparent part looks different compared to how it looks like in Photoshop.\n\n![](ReadmeImages/post_intro.png)\n\n\u003cbr\u003e\n\n## Why?\n\nThis is because **color space** is not set up to work the same in Unity and Photoshop.\nSee below to find out what settings in both that need to match:\n\n| Description | Photoshop | Unity |\n| ----------- | --------- | ----- |\n| Settings Location | Edit \u003e Color Settings \u003e Advanced Controls \u003e Blend RGB Colors Using Gamma [1.00] | Edit \u003e Project Settings \u003e Player \u003e Other Settings \u003e Color Space |\n| Linear Settings Value | ON | Linear |\n| Gamma Settings Value | OFF | Gamma |\n\n![](ReadmeImages/post_settings_mapping.png)\n\n\u003cbr\u003e\n\n## Which combination of settings should you use?\n\nIt depnds on your **Unity project**.\n\nThe Unity project can be on `Gamma Color Space` if it’s a 2D game, or a 3D game with very simple shading. Using Gamma Color Space in this case can save some performance as Unity doesn’t need to do final gamma correction after rendering everything, since all colors are in gamma color space already.\n\nThe Unity project will need to be on `Linear Color Space` if it needs accurate lighting rendering. See [documentation](https://docs.unity3d.com/Manual/LinearRendering-LinearOrGammaWorkflow.html). Basically modern 3D game projects are recommended to be in Linear Color Space.\n\nTherefore, the ideal case is - either **from the beginning** of the production or **before artists merge the layers** and export the sprites, ask the artists to change the settings in Photopshop accordingly. But make sure they are aware this will affect how they paint:\n\nWhen Photoshop `Blend RGB Colors Using Gamma [1.00]` checkbox is:\n| ON | OFF |\n| ----------- | --------- |\n| ![](ReadmeImages/post_brush_linear.gif) | ![](ReadmeImages/post_brush_gamma.gif) |\n\n\u003cbr\u003e\n\n## But it’s too late… Any workaround?\n\n### 🙂 Yes:\n\nIf your UI objects only use **alpha blending** mode ([in Photoshop it is called “Normal”](https://helpx.adobe.com/photoshop/using/blending-modes.html)), you can apply Linear / Gamma blending in Unity by sacrificing some runtime performance.\n\nThe idea is to render the entire UI into a RenderTexture first, and then after 3D camera’s rendering, blend the UI and 3D camera’s content onto the screen manually.\n\n\nThe workaround code and set up can be found in the `CameraColorSpaceWorkaround` folder of this repository. The setup is basically:\n\n\u003e [!TIP]\n\u003e In U6, if you want to have post-processing for UI Camera, make sure to go to Render Pipeline Asset \u003e Post-processing \u003e enable Alpha Processing checkbox.\n\u003e The UI camera can of course also \"re-use\" the 3D camera's post-processing by setting blendEvent on the workaround component to make the 3D+UI blending happens before 3D camera renders post-processing (beforeRenderingPostProcessing).\n\n![](ReadmeImages/post_workaround_setup.jpg)\n\n\u003cbr\u003e\n\n### ☹️ No:\n\nIf the UI consists of many layers and each layer uses a **different** blending mode - there is no easy trick to workaround this. The best is still to ask artists to try their best modifying their images.\n\nThis is because the layers are supposed to be blended differently, if we apply the above workaround, let's say some semi-transparent parts that are supposed to be additive, some are alpha-blended, the additive parts will become dark as all these layers are “merged” into one and blended with only one blend mode (alpha blendiing).\n\nSpeaking of additive blending mode, the Photoshop blending mode `Linear Dodge (Add)` does not work entirely the same as any additive shader you find in Unity because it is limited by the GPU. The result of the additive color is always clamped before the layer blends with the one below in Photoshop. In Unity, the additive color is not clamped.\n\n| Photoshop Linear Dodge (Add) | Unity Additive shader |\n| ----------- | --------- |\n| ```colorAdditive = colorBase + colorTop;```\u003cbr\u003e```colorAdditive = saturate(colorAdditive);```\u003cbr\u003e```result = lerp(colorBase, colorAdditive, alpha);``` | ```colorAdditive = colorBase + colorTop;```\u003cbr\u003e\u003cbr\u003e```result = lerp(colorBase, colorAdditive, alpha);``` |\n| \u003cimg src=\"ReadmeImages/post_additive_ps.png\" width=\"150\" /\u003e | \u003cimg src=\"ReadmeImages/post_additive_unity.png\" width=\"150\" /\u003e |\n\nIn this repo there are some test shaders that you can play with. See the `Test` folder.\n\nSince if we blend the colors manually we can achieve the same result as Photoshop, but I don’t think having the entire UI blended additively is a common usecase therefore the above workaround I’ve only provided solution for alpha blending.\n\n\u003cbr\u003e\u003cbr\u003e\u003cbr\u003e\n\n\n# PhotoshopBlendModesAndUnity\n\nIn the `Test` folder, there are shaders that blends color `(0,0.5,1)` on top of `(0.5,0.5,0.5)`.\n\n| Description | Gamma | Linear |\n| ------------------------- | ------ | ------ |\n| Photoshop Color Settings | ![](ReadmeImages/Photoshop_gamma.JPG) | ![](ReadmeImages/Photoshop_linear.JPG) |\n| Photoshop | ![](Assets/Test/PhotoshopReference/PSBlendModes_Gamma.png) | ![](Assets/Test/PhotoshopReference/PSBlendModes_Linear.png) |\n| Unity Player Settings | ![](ReadmeImages/Unity_gamma.JPG) | ![](ReadmeImages/Unity_linear.JPG) |\n| Unity Shader Blend colors manually | ![](ReadmeImages/PSBlendModes_Gamma.PNG) | ![](ReadmeImages/PSBlendModes_Linear.PNG) |\n| Unity Simple transparent shader | ![](ReadmeImages/Transparent_Gamma.PNG) | ![](ReadmeImages/Transparent_Linear.PNG) |\n| Unity Default URP Particle shaders | ![](ReadmeImages/URPParticleShader_Gamma.PNG) | ![](ReadmeImages/URPParticleShader_Linear.PNG) |\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcinight%2Fpsblendmodes","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcinight%2Fpsblendmodes","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcinight%2Fpsblendmodes/lists"}