Created
October 27, 2013 08:13
-
-
Save craigmjohnston/7179065 to your computer and use it in GitHub Desktop.
Slight modification to the Texture Mask shader on the Unity3D wiki (http://wiki.unity3d.com/index.php?title=Texture_Mask). It multiplies the main texture's alpha channel with the mask's, so it preserves any transparency your main texture has.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Shader "MaskedTexture" | |
{ | |
Properties | |
{ | |
_MainTex ("Base (RGB)", 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} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I wish github had shaderlab syntax highlighting :(