源战役客户端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

78 lines
2.7 KiB

  1. // Upgrade NOTE: replaced '_Object2World' with 'unity_ObjectToWorld'
  2. // Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)'
  3. Shader "MyShader/Water"
  4. {
  5. Properties
  6. {
  7. _farColor("far-Color", Color) = (1,1,1,1)
  8. _ColorStrong ("Color-Change", Range (0.1, 2)) = 1
  9. _nearColor("near-Color", Color) = (1,1,1,1)
  10. _MainTex("zhezhao-R,wave-G,NoiseScale-B", 2D) = "white" {}
  11. _wave("waveScale-x,WaveSpeed-y NoiseScale-z,NoiseSpeed-w",vector)=(1.7,0.02,7.3,0.04)
  12. _transparent("transparent", Range(0.5, 1)) = 1
  13. _opaque("near-opaque", Range(0, 0.8)) = 0
  14. _EColor("EnvironmentalColor", Color) = (1,1,1,1)
  15. }
  16. SubShader
  17. {
  18. tags{"Queue" = "Transparent" "RenderType" = "Transparent" "IgnoreProjector" = "True"}
  19. Blend SrcAlpha OneMinusSrcAlpha
  20. Pass
  21. {
  22. CGPROGRAM
  23. #pragma vertex vert
  24. #pragma fragment frag
  25. #pragma multi_compile_fog
  26. #include "UnityCG.cginc"
  27. sampler2D _MainTex;
  28. fixed4 _MainTex_ST,_farColor,_nearColor,_EColor,_wave;
  29. fixed _ColorStrong,_transparent,_opaque;
  30. struct a2v {
  31. float4 vertex : POSITION;
  32. fixed4 color : COLOR;
  33. fixed4 texcoord : TEXCOORD0;
  34. };
  35. struct v2f {
  36. float4 pos : POSITION;
  37. fixed2 uv : TEXCOORD0;
  38. fixed4 color : COLOR;
  39. fixed diff : TEXCOORD1;
  40. UNITY_FOG_COORDS(2)
  41. };
  42. v2f vert(a2v v){
  43. v2f o;
  44. o.pos = UnityObjectToClipPos(v.vertex);
  45. o.uv = v.texcoord.xy;
  46. o.diff = 0.5;
  47. o.color = v.color;
  48. UNITY_TRANSFER_FOG(o,o.pos);
  49. return o;
  50. }
  51. half4 frag(v2f i):COLOR
  52. {
  53. 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);
  54. fixed2 ruv = float2(i.uv.x, 1 - i.uv.y) + waveOffset * 0.01;
  55. float4 tex = tex2D (_MainTex, ruv.xy*float2(_wave.x,_wave.x)+float2(0, _Time.y * _wave.y)) ;
  56. fixed3 near = i.diff * _ColorStrong;
  57. fixed3 far = max((1 - near), 0);
  58. fixed3 ap = i.diff*_opaque;
  59. float4 result;
  60. result.rgb = (far*_EColor*tex.g + far*_farColor + near*_nearColor);
  61. result.a = _transparent-ap;//
  62. float4 c = result*i.color;
  63. UNITY_APPLY_FOG(i.fogCoord, c);
  64. return c;
  65. }
  66. ENDCG
  67. }
  68. }
  69. }