源战役客户端
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.

85 line
1.9 KiB

  1. // Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)'
  2. // Upgrade NOTE: replaced '_Object2World' with 'unity_ObjectToWorld'
  3. Shader "Unlit/DissolveEffect2"
  4. {
  5. Properties
  6. {
  7. _MainTex("Base (RGB)", 2D) = "white" {}
  8. //_ParentAlpha("_ParentAlpha", Float) = 15
  9. _ParentDist("_ParentDist", Float) = 0
  10. _ParentPos("ParentPos", Vector) = (0,0,0,0)
  11. _PlaneDir("PlaneDir", Vector) = (1,-0.6,0,0)
  12. }
  13. SubShader
  14. {
  15. //Tags
  16. //{
  17. //"Queue" = "Transparent"
  18. //"RenderType" = "Transparent"
  19. //}
  20. Pass
  21. {
  22. //Blend SrcAlpha OneMinusSrcAlpha
  23. CGPROGRAM
  24. #pragma vertex vert
  25. #pragma fragment frag
  26. #include "UnityCG.cginc"
  27. sampler2D _MainTex;
  28. float4 _MainTex_ST;
  29. uniform half _ParentDist;
  30. //uniform half _ParentAlpha;
  31. uniform half4 _ParentPos;
  32. uniform half4 _PlaneDir;
  33. struct v2f {
  34. half4 vertex : POSITION;
  35. float2 uv : TEXCOORD0;
  36. float3 posWorld : TEXCOORD1;
  37. };
  38. v2f vert(appdata_base v) {
  39. v2f o;
  40. o.posWorld = mul(unity_ObjectToWorld, v.vertex).xyz;
  41. o.vertex = UnityObjectToClipPos(v.vertex);
  42. o.uv = v.texcoord;
  43. return o;
  44. }
  45. fixed4 frag(v2f v) : COLOR
  46. {
  47. _ParentPos.x = -_ParentDist;
  48. half3 viewDirection = normalize(v.posWorld.xyz - _ParentPos.xyz);
  49. half angle = dot(_PlaneDir, viewDirection);
  50. _ParentPos.x = +_ParentDist;
  51. viewDirection = normalize(v.posWorld.xyz - _ParentPos.xyz);
  52. half angle2 = dot(_PlaneDir, viewDirection);
  53. half2 di = half2(_ParentDist/13, 0);
  54. if (angle2 < 0)
  55. {
  56. di.x = -_ParentDist/13;
  57. }
  58. if (angle > 0 && angle2 < 0)
  59. {
  60. clip(-1);
  61. }
  62. else
  63. {
  64. clip(1);
  65. }
  66. float2 uv = v.uv - di;
  67. fixed4 col = tex2D(_MainTex,TRANSFORM_TEX(uv,_MainTex));
  68. //fixed4 col = tex2D(_MainTex, v.uv);
  69. //col.a = 1 - _ParentDist / _ParentAlpha;
  70. return col;
  71. }
  72. ENDCG
  73. }
  74. }
  75. //FallBack "Diffuse"
  76. }