- Home /
Shader mask using greyscale instead of alpha?
I am completely new to writing shaders.
I found this simple shader which uses 2 textures, one main texture, and a second as a mask.
Shader "MaskedTexture"
{
Properties
{
_MainTex ("Base (RGB) Trans (A)", 2D) = "white" {}
_Mask ("Culling Mask", 2D) = "white" {}
_Cutoff ("Alpha cutoff", Range (0,1)) = 0.1
}
SubShader
{
Tags {"Queue"="Transparent" }
Lighting Off
ZWrite Off
Blend SrcAlpha OneMinusSrcAlpha
AlphaTest GEqual [_Cutoff]
Pass
{
SetTexture [_Mask] {combine texture}
SetTexture [_MainTex] {combine texture, previous * texture}
}
}
}
This works great. However for my application I need to be able to do the exact same effect, except base the masking on greyscale values instead of alpha values.
Can this be easily modified to do that?
What happens if you set the texture to "build alpha from grayscale" ?
I need the texture change dynamically, therefore I am using a RenderTexture. Can this be done with RenderTexture?
Check this conversation, maybe you can get something form it (shaders aren't my thing :D ) : link text
Your answer
Follow this Question
Related Questions
shader problem 0 Answers
Masking shader with alpha Color 1 Answer
Rewrite simple alphamask fixed function shader to surface or cg shader 2 Answers
How would I add an alpha mask to this shader? 1 Answer
Strange shader behaviour on UI component 0 Answers