Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)'
- // Upgrade NOTE: commented out 'half4 unity_LightmapST', a built-in variable
- // Upgrade NOTE: commented out 'sampler2D unity_Lightmap', a built-in variable
- // Upgrade NOTE: replaced tex2D unity_Lightmap with UNITY_SAMPLE_TEX2D
- Shader "SunGear Games/Lit/Special/Water Foam" {
- Properties {
- _MainTex ("Base (RGB)", 2D) = "white" {}
- _Speed ("Speed", Float) = 1
- _Speed2 ("Speed 2", Float) = 1
- _Alpha ("Alpha", Range(0, 1)) = 1
- }
- Category {
- Tags { "Queue"="Transparent" "RenderType"="Transparent" }
- LOD 250
- Offset -1, -1
- ZWrite Off
- BlendOp Add
- Blend One SrcAlpha
- SubShader {
- Pass {
- Name "BASE"
- Tags {"LightMode" = "ForwardBase" "ForceNoShadowCasting"="True"}
- CGPROGRAM
- #pragma vertex vert
- #pragma fragment frag
- #pragma fragmentoption ARB_precision_hint_fastest
- #include "UnityCG.cginc"
- struct appdata_t {
- float4 vertex : POSITION;
- half2 texcoord : TEXCOORD0;
- half2 lightmap_texcoord : TEXCOORD1;
- };
- struct v2f {
- float4 pos : SV_POSITION;
- half2 uv1 : TEXCOORD0;
- half2 uv2 : TEXCOORD3;
- half2 lm : TEXCOORD1;
- half2 uvo : TEXCOORD2;
- };
- uniform half4 _MainTex_ST;
- // uniform half4 unity_LightmapST;
- uniform half _Speed;
- uniform half _Speed2;
- uniform fixed _Alpha;
- uniform sampler2D _MainTex;
- // uniform sampler2D unity_Lightmap;
- v2f vert(appdata_t v)
- {
- half2 tx1 = v.texcoord;
- half2 tx2 = half2(2, 2.5) - v.texcoord;
- v2f o;
- o.pos = UnityObjectToClipPos(v.vertex);
- o.uv1 = TRANSFORM_TEX(tx1, _MainTex) + half2(-_Time.y * _Speed, 0);
- o.uv2 = TRANSFORM_TEX(tx2, _MainTex) + half2(-_Time.y * _Speed2, 0);
- o.lm = v.lightmap_texcoord.xy * unity_LightmapST.xy + unity_LightmapST.zw;
- o.uvo = v.texcoord;
- return o;
- }
- fixed4 frag (v2f i) : COLOR
- {
- fixed3 lightmap = DecodeLightmap(UNITY_SAMPLE_TEX2D(unity_Lightmap, i.lm));
- fixed alpha = (1 - abs(i.uvo.x - 0.5) * 2) * _Alpha;
- fixed4 color1 = tex2D(_MainTex, i.uv1);
- color1.a *= alpha;
- fixed4 color2 = tex2D(_MainTex, i.uv2);
- color2.a *= alpha;
- fixed4 result;
- result.rgb = (color2.rgb * color2.a * (1 - color1.a) + color1.rgb * color1.a) * lightmap;
- result.a = (1 - color1.a) * (1 - color2.a);
- return result;
- }
- ENDCG
- }
- }
- }
- FallBack "VertexLit", 1
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement