Skip to content

Commit e7bd23b

Browse files
committed
Added the shader file
1 parent 9205721 commit e7bd23b

File tree

1 file changed

+83
-0
lines changed

1 file changed

+83
-0
lines changed
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
// Created by Jafar Abdulrasoul
2+
3+
// Special thanks to Dan http://danjohnmoran.com
4+
5+
6+
Shader "Effects/TransitionShaderWithTexture"
7+
{
8+
Properties
9+
{
10+
_MainTex ("Texture", 2D) = "white" {} //Main Texture, leave empty
11+
_TranTex ("Transition Texture", 2D) = "black" {} //Transition texture. Leave blank if using color
12+
_PatternTex ("Pattern Texture", 2d) = "white" {} //The pattern transition texture
13+
_Cutoff("Progress", Range (0, 1)) = 0 //Cut off slider
14+
_Color("Color", Color) = (0,0,0,0) //defaults to black
15+
[MaterialToggle] _UseColor("Use Color", Float) = 0 //color or texture toggle
16+
}
17+
SubShader
18+
{
19+
// No culling or depth
20+
Cull Off ZWrite Off ZTest Always
21+
22+
Pass
23+
{
24+
CGPROGRAM
25+
#pragma vertex vert
26+
#pragma fragment frag
27+
28+
#include "UnityCG.cginc"
29+
30+
struct appdata
31+
{
32+
float4 vertex : POSITION;
33+
float2 uv : TEXCOORD0;
34+
};
35+
36+
struct v2f
37+
{
38+
float2 uv : TEXCOORD0;
39+
float2 uv1 : TEXCOORD1;
40+
float4 vertex : SV_POSITION;
41+
};
42+
43+
sampler2D _MainTex;
44+
sampler2D _TranTex;
45+
sampler2D _PatternTex;
46+
float _Cutoff;
47+
fixed4 _Color;
48+
float _UseColor;
49+
50+
v2f vert (appdata v)
51+
{
52+
v2f o;
53+
o.vertex = mul(UNITY_MATRIX_MVP, v.vertex);
54+
o.uv = v.uv;
55+
o.uv1 = v.uv;
56+
57+
//because shaders are complicated, this adjusts coordinates
58+
#if UNITY_UV_STARTS_AT_TOP
59+
if (_MainTex_TexelSize.y < 0)
60+
o.uv1.y = 1 - o.uv1.y;
61+
#endif
62+
63+
return o;
64+
}
65+
66+
fixed4 frag(v2f i) : SV_Target
67+
{
68+
fixed4 transit = tex2D(_PatternTex, i.uv);
69+
//checks the blue attribute of the pattern and cuts off in respect to that
70+
if(transit.b < _Cutoff){
71+
// if _UseColor is enabled, use color instead
72+
if(_UseColor > 0)
73+
return _Color;
74+
// _Use color is not enabled, use the _TranTex
75+
return tex2D(_TranTex, i.uv);
76+
}
77+
// return the original texture aka don't do anything
78+
return tex2D(_MainTex, i.uv);
79+
}
80+
ENDCG
81+
}
82+
}
83+
}

0 commit comments

Comments
 (0)