Last active
March 6, 2016 13:17
-
-
Save EsProgram/683eb267815d27f647b6 to your computer and use it in GitHub Desktop.
それぞれ同じようなエフェクト(もとのマスク画像を加算するかどうかの違い)
This file contains hidden or 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 "MBL/UI/UIFade" | |
{ | |
Properties | |
{ | |
[HideInInspector] | |
_MainTex ("Texture", 2D) = "white" {} | |
_BGTex("BGTexture", 2D) = "white" {} | |
_Clip ("Clip", Range(0,1)) = 0 | |
_SrcCol ("SourceColor", Color) = (0,0,0,1) | |
_DstCol ("DestinationColor", Color) = (1,1,1,1) | |
_Blend ("Blend", Float) = 0.5 | |
} | |
SubShader | |
{ | |
Blend SrcAlpha OneMinusSrcAlpha | |
Tags{"Queue"="Transparent" "PreviewType"="Plane"} | |
Pass | |
{ | |
CGPROGRAM | |
#pragma vertex vert | |
#pragma fragment frag | |
#include "UnityCG.cginc" | |
struct appdata | |
{ | |
float4 vertex : POSITION; | |
float2 uv : TEXCOORD0; | |
}; | |
struct v2f | |
{ | |
float2 uv : TEXCOORD0; | |
float4 vertex : SV_POSITION; | |
}; | |
sampler2D _MainTex; | |
float4 _MainTex_ST; | |
sampler2D _BGTex; | |
float _Clip; | |
float4 _SrcCol; | |
float4 _DstCol; | |
float _Blend; | |
v2f vert (appdata v) | |
{ | |
v2f o; | |
o.vertex = mul(UNITY_MATRIX_MVP, v.vertex); | |
o.uv = TRANSFORM_TEX(v.uv, _MainTex); | |
return o; | |
} | |
fixed4 frag (v2f i) : SV_Target | |
{ | |
float4 mask = tex2D(_MainTex, i.uv); | |
float4 bg = tex2D(_BGTex, i.uv); | |
clip(mask.a - _Clip); | |
float4 col = lerp(_SrcCol, _DstCol, i.uv.x * i.uv.y); | |
mask += (col * bg) * _Blend; | |
mask.a = 1 - _Clip; | |
return mask; | |
} | |
ENDCG | |
} | |
} | |
} |
This file contains hidden or 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 "MBL/UI/UIFade" | |
{ | |
Properties | |
{ | |
[HideInInspector] | |
_MainTex ("Texture", 2D) = "white" {} | |
_BGTex("BGTexture", 2D) = "white" {} | |
_Clip ("Clip", Range(0,1)) = 0 | |
_SrcCol ("SourceColor", Color) = (0,0,0,1) | |
_DstCol ("DestinationColor", Color) = (1,1,1,1) | |
_Blend ("Blend", Float) = 0.5 | |
} | |
SubShader | |
{ | |
Blend SrcAlpha OneMinusSrcAlpha | |
Tags{"Queue"="Transparent" "PreviewType"="Plane"} | |
Pass | |
{ | |
CGPROGRAM | |
#pragma vertex vert | |
#pragma fragment frag | |
#include "UnityCG.cginc" | |
struct appdata | |
{ | |
float4 vertex : POSITION; | |
float2 uv : TEXCOORD0; | |
}; | |
struct v2f | |
{ | |
float2 uv : TEXCOORD0; | |
float4 vertex : SV_POSITION; | |
}; | |
sampler2D _MainTex; | |
float4 _MainTex_ST; | |
sampler2D _BGTex; | |
float _Clip; | |
float4 _SrcCol; | |
float4 _DstCol; | |
float _Blend; | |
v2f vert (appdata v) | |
{ | |
v2f o; | |
o.vertex = mul(UNITY_MATRIX_MVP, v.vertex); | |
o.uv = TRANSFORM_TEX(v.uv, _MainTex); | |
return o; | |
} | |
fixed4 frag (v2f i) : SV_Target | |
{ | |
float4 mask = tex2D(_MainTex, i.uv); | |
float4 bg = tex2D(_BGTex, i.uv); | |
clip(mask.a - _Clip); | |
float4 col = lerp(_SrcCol, _DstCol, i.uv.x * i.uv.y); | |
mask = (col * bg) * _Blend; | |
mask.a = 1 - _Clip; | |
return mask; | |
} | |
ENDCG | |
} | |
} | |
} |
Author
EsProgram
commented
Mar 6, 2016
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment