Skip to content

Instantly share code, notes, and snippets.

@asus4
Created June 29, 2014 20:03
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save asus4/1c949f2f653f9faccf23 to your computer and use it in GitHub Desktop.
Save asus4/1c949f2f653f9faccf23 to your computer and use it in GitHub Desktop.
Play Movie Texture with Mask
Shader "Custom/MaskedSprite" {
Properties {
_MainTex ("Base (RGB)", 2D) = "white" {}
}
SubShader {
Tags {
"Queue"="Transparent"
"IgnoreProjector"="True"
"RenderType"="Transparent"
"PreviewType"="Plane"
}
LOD 100
Alphatest Greater 0
Cull Off
Lighting Off
ZWrite Off
Fog { Mode Off }
Blend SrcAlpha OneMinusSrcAlpha
ColorMask RGB
Pass {
Blend SrcAlpha OneMinusSrcAlpha
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#pragma multi_compile DUMMY PIXELSNAP_ON
#include "UnityCG.cginc"
struct appdata_t
{
float4 vertex : POSITION;
float4 color : COLOR;
float2 texcoord : TEXCOORD0;
};
struct v2f
{
float4 vertex : SV_POSITION;
fixed4 color : COLOR;
half2 texcoord : TEXCOORD0;
};
v2f vert(appdata_t IN)
{
v2f OUT;
OUT.vertex = mul(UNITY_MATRIX_MVP, IN.vertex);
OUT.texcoord = IN.texcoord;
OUT.color = IN.color;
#ifdef PIXELSNAP_ON
OUT.vertex = UnityPixelSnap (OUT.vertex);
#endif
return OUT;
}
sampler2D _MainTex;
half4 frag (v2f IN) : SV_Target
{
half2 mask_uv = IN.texcoord;
mask_uv.y /= 2;
half2 base_uv = mask_uv;
base_uv.y += 0.5;
fixed3 base = tex2D (_MainTex, base_uv);
fixed3 mask = tex2D (_MainTex, mask_uv);
return fixed4(base, mask.r);
}
ENDCG
}
}
FallBack "Diffuse"
}
@asus4
Copy link
Author

asus4 commented Jun 29, 2014

Need Movie like below

Screen Shot 2014-06-30 at 4.52.04.png

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment