How to change Unity saturation?
Hi. I'm making a game in 2019.3 (2D) Pixel art and in cert zones (triggers) i want to make saturation = 0;
Is there any way to get that effect? Example: https://www.howtogeek.com/wp-content/uploads/2018/07/howtoblackandwhite.jpg
Answer by streeetwalker · Apr 03, 2020 at 10:02 AM
Hi @dragon_script, You might check the assets store for a plugin that will do want you want to individual textures. If nothing is there, perhaps the easiest way to do this just import a grayscale version of each image and switch it out at runtime, or hide and show it.
If you don't want to do it that way, you can find the code for a grayscale shader (do a google search on 'unity grayscale shader', and then switch shaders in response to your trigger (search for that too.)
and if you don't want to do that you can actually copy all the pixels from your texture to a new texture, and retain only the gray values of each pixel. Here is a bit of code I pulled off a search that does that:
function Start () {
var texClone = Instantiate (renderer.material.mainTexture);
renderer.material.mainTexture = texClone;
MakeGrayscale (texClone);
}
function MakeGrayscale (tex : Texture2D) {
var texColors = tex.GetPixels();
for (i = 0; i < texColors.Length; i++) {
var grayValue = texColors[i].grayscale;
texColors[i] = Color(grayValue, grayValue, grayValue, texColors[i].a);
}
tex.SetPixels(texColors);
tex.Apply();
}
So, there are lots of ways of doing it. Search around and you'll find many that have had the same question.
Your answer
Follow this Question
Related Questions
Color Grading: Some Curves don't affect color shifts made using Linear Trackballs 0 Answers
Post Processing bloom and vignette are pixelated and squared 2 Answers
Post-Processing Stack V2 has no effect 1 Answer
Post processing not working(Unity 2018.1.0f2) 0 Answers
Anyone kwon how to make this Post processing step by step? 0 Answers