// Upgrade NOTE: replaced '_Object2World' with 'unity_ObjectToWorld' // Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)' Shader "MyShader/Water" { Properties { _farColor("far-Color", Color) = (1,1,1,1) _ColorStrong ("Color-Change", Range (0.1, 2)) = 1 _nearColor("near-Color", Color) = (1,1,1,1) _MainTex("zhezhao-R,wave-G,NoiseScale-B", 2D) = "white" {} _wave("waveScale-x,WaveSpeed-y NoiseScale-z,NoiseSpeed-w",vector)=(1.7,0.02,7.3,0.04) _transparent("transparent", Range(0.5, 1)) = 1 _opaque("near-opaque", Range(0, 0.8)) = 0 _EColor("EnvironmentalColor", Color) = (1,1,1,1) } SubShader { tags{"Queue" = "Transparent" "RenderType" = "Transparent" "IgnoreProjector" = "True"} Blend SrcAlpha OneMinusSrcAlpha Pass { CGPROGRAM #pragma vertex vert #pragma fragment frag #pragma multi_compile_fog #include "UnityCG.cginc" sampler2D _MainTex; fixed4 _MainTex_ST,_farColor,_nearColor,_EColor,_wave; fixed _ColorStrong,_transparent,_opaque; struct a2v { float4 vertex : POSITION; fixed4 color : COLOR; fixed4 texcoord : TEXCOORD0; }; struct v2f { float4 pos : POSITION; fixed2 uv : TEXCOORD0; fixed4 color : COLOR; fixed diff : TEXCOORD1; UNITY_FOG_COORDS(2) }; v2f vert(a2v v){ v2f o; o.pos = UnityObjectToClipPos(v.vertex); o.uv = v.texcoord.xy; o.diff = 0.5; o.color = v.color; UNITY_TRANSFER_FOG(o,o.pos); return o; } half4 frag(v2f i):COLOR { fixed2 waveOffset =(tex2D(_MainTex, i.uv.xy*_wave.z + float2(0, _Time.y * _wave.w)).b + tex2D(_MainTex, i.uv.xy*_wave.z + float2(_Time.y * _wave.w, 0)).b); fixed2 ruv = float2(i.uv.x, 1 - i.uv.y) + waveOffset * 0.01; float4 tex = tex2D (_MainTex, ruv.xy*float2(_wave.x,_wave.x)+float2(0, _Time.y * _wave.y)) ; fixed3 near = i.diff * _ColorStrong; fixed3 far = max((1 - near), 0); fixed3 ap = i.diff*_opaque; float4 result; result.rgb = (far*_EColor*tex.g + far*_farColor + near*_nearColor); result.a = _transparent-ap;// float4 c = result*i.color; UNITY_APPLY_FOG(i.fogCoord, c); return c; } ENDCG } } }