Advertisement
romanilyin

SunGear Games/Lit/Special/Water Foam

Jan 30th, 2025
236
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)'
  2.  
  3. // Upgrade NOTE: commented out 'half4 unity_LightmapST', a built-in variable
  4. // Upgrade NOTE: commented out 'sampler2D unity_Lightmap', a built-in variable
  5. // Upgrade NOTE: replaced tex2D unity_Lightmap with UNITY_SAMPLE_TEX2D
  6.  
  7. Shader "SunGear Games/Lit/Special/Water Foam" {
  8.     Properties {
  9.         _MainTex ("Base (RGB)", 2D) = "white" {}
  10.         _Speed ("Speed", Float) = 1
  11.         _Speed2 ("Speed 2", Float) = 1
  12.         _Alpha ("Alpha", Range(0, 1)) = 1
  13.     }
  14.  
  15.     Category {
  16.         Tags { "Queue"="Transparent" "RenderType"="Transparent" }
  17.         LOD 250
  18.  
  19.         Offset -1, -1
  20.         ZWrite Off
  21.         BlendOp  Add
  22.         Blend One SrcAlpha
  23.  
  24.         SubShader {
  25.             Pass {
  26.                 Name "BASE"
  27.                 Tags {"LightMode" = "ForwardBase" "ForceNoShadowCasting"="True"}
  28.  
  29.                 CGPROGRAM
  30.                 #pragma vertex vert
  31.                 #pragma fragment frag
  32.                 #pragma fragmentoption ARB_precision_hint_fastest
  33.  
  34.                 #include "UnityCG.cginc"
  35.  
  36.                 struct appdata_t {
  37.                     float4 vertex : POSITION;
  38.                     half2 texcoord : TEXCOORD0;
  39.                     half2 lightmap_texcoord : TEXCOORD1;
  40.                 };
  41.  
  42.                 struct v2f {
  43.                     float4 pos : SV_POSITION;
  44.                     half2 uv1 : TEXCOORD0;
  45.                     half2 uv2 : TEXCOORD3;
  46.                     half2 lm : TEXCOORD1;
  47.                     half2 uvo : TEXCOORD2;
  48.                 };
  49.  
  50.                 uniform half4 _MainTex_ST;
  51.                 // uniform half4 unity_LightmapST;
  52.                 uniform half _Speed;
  53.                 uniform half _Speed2;
  54.                 uniform fixed _Alpha;
  55.  
  56.                 uniform sampler2D _MainTex;
  57.                 // uniform sampler2D unity_Lightmap;
  58.  
  59.                 v2f vert(appdata_t v)
  60.                 {
  61.                     half2 tx1 = v.texcoord;
  62.                     half2 tx2 = half2(2, 2.5) - v.texcoord;
  63.                     v2f o;
  64.                     o.pos = UnityObjectToClipPos(v.vertex);
  65.                     o.uv1 = TRANSFORM_TEX(tx1, _MainTex) + half2(-_Time.y * _Speed, 0);
  66.                     o.uv2 = TRANSFORM_TEX(tx2, _MainTex) + half2(-_Time.y * _Speed2, 0);
  67.                     o.lm = v.lightmap_texcoord.xy * unity_LightmapST.xy + unity_LightmapST.zw;
  68.                     o.uvo = v.texcoord;
  69.  
  70.                     return o;
  71.                 }
  72.  
  73.                 fixed4 frag (v2f i) : COLOR
  74.                 {
  75.                     fixed3 lightmap = DecodeLightmap(UNITY_SAMPLE_TEX2D(unity_Lightmap, i.lm));
  76.                     fixed alpha = (1 - abs(i.uvo.x - 0.5) * 2) * _Alpha;
  77.                     fixed4 color1 = tex2D(_MainTex, i.uv1);
  78.                     color1.a *= alpha;
  79.                     fixed4 color2 = tex2D(_MainTex, i.uv2);
  80.                     color2.a *= alpha;
  81.  
  82.                     fixed4 result;
  83.                     result.rgb = (color2.rgb * color2.a * (1 - color1.a) + color1.rgb * color1.a) * lightmap;
  84.                     result.a = (1 - color1.a) * (1 - color2.a);
  85.                     return result;
  86.                 }
  87.                 ENDCG  
  88.             }
  89.         }
  90.     }
  91.  
  92.     FallBack "VertexLit", 1
  93. }
  94.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement