Like the photoshop saturation slider - I’m trying to find/make a shader that only changes the rgb values and preserves the original alpha channel value.
I’m new to shaders, trying to learn like crazy but just can’t find a way to work this!
Also, I’m aware of the greyscale image effect for the camera but we’re trying to affect the materials of individual objects rather than the whole screen. For a bit of reference, if you’re curios, I’ll stick up a very rough mock up of what we’re trying to do.
Any help or tips would be massively appreciated! Thank you for having a wee read!
I have a question about your Luminance(color.rgb).rrr splat. Does that just take the grayscale value of the R channel and repeat it in the g and b channels? Because that’s not quite the same thing. If there’s a lot more blue in the texture, for example, the result of an r splat would be darker than the expected one. I can’t find anything in the script reference about Luminance() to find out what it returns so that’s frustrating. There seem to be a lot of functions available in shader lab that aren’t documented.
The original line was doing a lerp between a scalar (result of luminance) and the original rgb color vector. Cg then decides to use the scalar overload of lerp and use only the red of original color (correct me if I’m wrong).
The corrected line turns the resulting luminance scalar into a vector with same components so the vector version of lerp is used.
I’d love more/better documentation on shader functions too. Anyway I keep the CGIncludes directory at hand as well as the cg docs.
Also note the assignment is done with .rgb masking/swizzling so alpha of color is unaffected.