How to use only one color channel from texture?

Hi guys!

This is probably a total noob question but I have to ask it anyway since I was not able to find anything about this, whether in the docs nor the forum.

What I need to know is if and how I can get only one channel out of a texture without using a custom Cg shader but by using only standard ShaderLab functionality.

I need to get the Red, Green, Blue and Alpha channels seperately instead of all of them combined.

Is something like this possible?

An (probably not working) example of what I try to accomplish:

SetTexture [_MainTex] {
    constantColor [_Color]
    combine texture.r * constant
}

I know how to do this by using a custom Cg shader, but I would rather like to do this with standard ShaderLab functionality…

“Standard Shaderlab functionality” is basically equivalent to that of the fixed function pipeline. If you can’t do it without Cg, it’s usually a hardware limitation rather than simply a missing Shaderlab feature.

The closest thing I can think of to what you’re asking is the Colormask keyword. This allows you to make a pass only write to a specific combination of channels. However, you can’t change the mask in-between texture operations, so you might need four passes to treat all of your channels separately.

This Colormask sounds pretty much like what I’m looking for. Thank you for this hint, I’ll look into that. Thanks :smile:

Edit: Ok, my happyness was a bit premature, I guess. But thank you anyway, since I didn’t know the ColorMask keyword anyway. So at least I learned something new :wink:

Well then, I guess it has to be a Cg shader then. :slight_smile: