Saturation Shader

Hi there,

I’m pretty new to shaders, and am just looking for a fairly simple one: something that can impact saturation levels on a given object (I’d add a script that modifies the saturation level). Does anyone have anything like that that would also be mobile friendly? Did a search but couldn’t find anything.

There are functions here which could be used to do it directly with something along the lines of:

newColor = hsv2rgb(rgb2hsv(oldColor)*float3(1, saturationMultiplier, 1));

Depending on your definition of mobile-friendly they may not be suitable, though.

If the saturation levels aren’t changing frequently, you’d probably be better off creating a small lookup texture and using the unmodified RGB values as coordinates to sample a new color from that.

You couldn’t just add a script; you would need to edit the shader you are using for that object.

You could convert the final color to greyscale, and then lerp it with the original color. Something along the lines of:

float greyscale = dot(finalColor.rgb, fixed3(.222, .707, .071));  // Convert to greyscale numbers with magic luminance numbers
finalColor.rgb = lerp(float3(greyscale, greyscale, greyscale), finalColor.rgb, _Saturation);

Untested code, but the general idea should work. I’m not sure how accurate it would be compared to the color space conversion method, but it should be faster.