123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245 |
- Shader "Custom/DistortSelf"
- {
- Properties
- {
-
- [Header(Flag)]
- _MainTex("Texture", 2D) = "white" {}
- _Noise ("Noise", 2D) = "white" {}
- _distortFactorTime("FactorTime",Range(0,5)) = 0.5
- _distortFactor("factor",Range(0.04,1)) = 0
- [Space(20)]
- [Header(MainBackGround)]
- _2edTex ("Main Tex", 2D) = "white" {}
- //_Specular ("Specular", Color) = (1, 1, 1, 1)
- //_Gloss ("Gloss", Range(8.0, 256)) = 20
- [Space(20)]
- [Header(Cloud)]
- _3rdTex ("3edTexture", 2D) = "white" {}
- _Speed("Rotate Speed",Float)=1
- [Space(20)]
- [Header(Grass)]
- _4thTex ("Texture", 2D) = "white" {}
- _Noise2("Noise", 2D) = "black" {}
- _WindControl("WindControl(x:XSpeed y:YSpeed z:ZSpeed w:windMagnitude)",vector) = (1,0,1,0.5)
- //前面几个分量表示在各个轴向上自身摆动的速度, w表示摆动的强度
- _WaveControl("WaveControl(x:XSpeed y:YSpeed z:ZSpeed w:worldSize)",vector) = (1,0,1,1)
- //前面几个分量表示在各个轴向上风浪的速度, w用来模拟地图的大小,值越小草摆动的越凌乱,越大摆动的越整体
- [HDR]_Color("Color",Color) = (1,1,1,1)
- _XSpeed("XSpeed",Range(-1,1)) = 0
- _YSpeed("YSpeed",Range(-1,1)) = 0
- _AlphaScale("Alpha",Range(0,1)) =1
- [Space(10)]
- [Header(Water)]
- _WaterCol ("Color", Color) = (1,1,1,1)
- _WaterCol_ROOT ("Color ROOT", Color) = (1,1,1,1)
- _WaterCol_image5 ("Color image5", Color) = (1,1,1,1)
- _WaterCol_image5copy ("Color image5copy", Color) = (1,1,1,1)
- _WaterCol_image8 ("Color image8", Color) = (1,1,1,1)
- _WaterCol_image8copy ("Color image8copy", Color) = (1,1,1,1)
- _WaterCol_image15 ("Color image15", Color) = (1,1,1,1)
- _5thTex ("_5thTex", 2D) = "white" { }
- _wave ("_wave", 2D) = "white" { }
- _view_mask0 ("_view_mask0", 2D) = "white" { }
- _smoke ("_smoke", 2D) = "white" { }
- _viewWaterfall ("_viewWaterfall", 2D) = "white" { }
- _view2 ("_view2", 2D) = "white" { }
- _view_mask1 ("_view_mask1", 2D) = "white" { }
- _Speed2("Speed2",Float) = 1
- _Alpha("Alpha",Range(0,1))=1
- [MaterialToggle] PixelSnap ("Pixel snap", Float) = 0
- }
- SubShader
- {
- Tags { "Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent" "PreviewType"="Plane" "CanUseSpriteAtlas"="True"}
- LOD 100
- Blend SrcAlpha OneMinusSrcAlpha
- Cull Off Lighting Off ZWrite Off
-
-
-
-
-
-
- Pass
- {
- ZWrite Off
-
- CGPROGRAM
-
- #pragma vertex vert
- #pragma fragment frag
- #include "Lighting.cginc"
-
- fixed4 _Color;
- sampler2D _2edTex;
- float4 _2edTex_ST;
- fixed4 _Specular;
- float _Gloss;
-
- struct a2v {
- float4 vertex : POSITION;
- float3 normal : NORMAL;
- float4 texcoord : TEXCOORD0;
- };
-
- struct v2f {
- float4 pos : SV_POSITION;
- float3 worldNormal : TEXCOORD0;
- float3 worldPos : TEXCOORD1;
- float2 uv : TEXCOORD2;
- };
-
- v2f vert(a2v v) {
- v2f o;
- o.pos = UnityObjectToClipPos(v.vertex);
-
- o.worldNormal = UnityObjectToWorldNormal(v.normal);
-
- o.worldPos = mul(unity_ObjectToWorld, v.vertex).xyz;
-
- o.uv = v.texcoord.xy * _2edTex_ST.xy + _2edTex_ST.zw;
- // Or just call the built-in function
- // o.uv = TRANSFORM_TEX(v.texcoord, _2edTex);
-
- return o;
- }
-
- fixed4 frag(v2f i) : SV_Target {
- //fixed3 worldNormal = normalize(i.worldNormal);
- //fixed3 worldLightDir = normalize(UnityWorldSpaceLightDir(i.worldPos));
-
- // Use the texture to sample the diffuse color
- fixed4 albedo = tex2D(_2edTex, i.uv);
-
-
-
- return albedo;
- }
-
- ENDCG
- }
-
- Pass
- {
- Blend SrcAlpha OneMinusSrcAlpha
-
-
- CGPROGRAM
- #pragma vertex vert
- #pragma fragment frag
- #include "UnityCG.cginc"
-
- sampler2D _3rdTex;
- float4 _3rdTex_ST;
- float _Speed;
-
- struct a2v{
- float4 vertex:POSITION;
- float4 texcoord:TEXCOORD;
- };
- struct v2f{
- float4 pos:POSITION;
- float4 uv:texcoord;
- };
-
- v2f vert(a2v v){
- v2f o;
- o.pos=UnityObjectToClipPos(v.vertex);
- o.uv=v.texcoord;
- return o;
- }
-
- fixed4 frag(v2f i):SV_Target{
- /*//扭曲效果
- fixed2 uv = i.uv - fixed2(0.5,0.5);
- float angle = _Speed * 0.1745/(length(uv) + 0.1);//加0.1是放置length(uv)为0
- float angle2 = angle * _Time.y;
- uv = float2(uv.x*cos(angle2)-uv.y*sin(angle2),uv.y*cos(angle2)+uv.x*sin(angle2));
- uv+=fixed2(0.5,0.5);
- fixed4 c = tex2D(_3rdTex,uv);
- return c;
- */
-
- //缩放
- //float4 uv = i.uv;
- //uv.x*=_Speed;
- //uv.w=0.5;
- //return tex2D(_3rdTex,uv);
-
- //旋转
- //float2 uv=i.uv.xy-float2(0.5,0.5);
- //uv=float2(uv.x*cos(_Speed*_Time.y)-uv.y*sin(_Speed*_Time.y),uv.y*cos(_Speed*_Time.y) + uv.x*sin(_Speed*_Time.y));
- //uv+=float2(0.5,0.5);
- //fixed4 lateUV = tex2D(_3rdTex,uv);
- //return lateUV;
-
- //平移
- return tex2D(_3rdTex,i.uv - _Time.x*fixed2(2,0)* _Speed);
- }
-
- ENDCG
- }
- Pass
- {
- ZWrite off
- 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 _Noise;
- fixed _distortFactorTime;
- fixed _distortFactor;
- fixed4 _Color;
- float _XSpeed;
- float _YSpeed;
- v2f vert (appdata v)
- {
- v2f o;
- o.vertex = UnityObjectToClipPos(v.vertex);
- o.uv = TRANSFORM_TEX(v.uv, _MainTex);
- o.uv += float2(_XSpeed, _YSpeed)*_Time.y;
- return o;
- }
- fixed4 frag (v2f i) : SV_Target
- {
- // sample the texture
- fixed4 bias = tex2D(_Noise, i.uv+_Time.xy*_distortFactorTime);
- half4 color = tex2D(_MainTex, i.uv+bias.xy*_distortFactor);
- return color*_Color;
- }
- ENDCG
- }
-
-
-
-
-
- }
- }
|