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

79 lines
2.5 KiB

  1. // Upgrade NOTE: replaced '_Object2World' with 'unity_ObjectToWorld'
  2. // Upgrade NOTE: replaced '_World2Object' with 'unity_WorldToObject'
  3. Shader "Unlit/shadow2"
  4. {
  5. Properties
  6. {
  7. _MainTex("Base (RGB)", 2D) = "white" {}
  8. _ShadowCol("Color", color) = (0,0,0,1)
  9. _ShadowAlpha("ShadowAlpha", Float) = 0.5
  10. _StencilID("StencilID", Int) = 0
  11. _Plane("Plane", vector) = (0,1,-0.6,0)
  12. _LightDir("LightDir", vector) = (1,-1,-0.1,0)
  13. }
  14. SubShader
  15. {
  16. Tags{ "RenderType" = "Transparent" "Queue" = "Transparent" }
  17. Pass
  18. {
  19. Name "Shadowpass"
  20. Stencil{
  21. Ref [_StencilID]
  22. Comp NotEqual
  23. Pass replace
  24. }
  25. zwrite off
  26. blend srcalpha oneminussrcalpha
  27. offset -1,-1
  28. CGPROGRAM
  29. #pragma vertex vert
  30. #pragma fragment frag
  31. #pragma multi_compile_fog
  32. #include "UnityCG.cginc"
  33. struct appdata
  34. {
  35. float4 vertex : POSITION;
  36. };
  37. struct v2f
  38. {
  39. // UNITY_FOG_COORDS(0)
  40. float4 vertex : SV_POSITION;
  41. fixed4 col : COLOR;
  42. //float2 uv : TEXCOORD0;
  43. };
  44. sampler2D _MainTex;
  45. fixed4 _ShadowCol;
  46. fixed _ShadowAlpha;
  47. float4 _Plane;
  48. float4 _LightDir;
  49. v2f vert (appdata v)
  50. {
  51. v2f o;
  52. float4 worldPos = mul(unity_ObjectToWorld, v.vertex);
  53. half t = (_Plane.w - dot(worldPos.xyz, _Plane.xyz)) / dot(_LightDir.xyz, _Plane.xyz);
  54. worldPos.xyz = worldPos.xyz + t*_LightDir.xyz;
  55. o.vertex = mul(unity_MatrixVP, worldPos);
  56. _ShadowCol.a = _ShadowAlpha;
  57. o.col = _ShadowCol *step(0, t);
  58. //UNITY_TRANSFER_FOG(o,o.vertex);
  59. // o.uv = v.texcoord;
  60. return o;
  61. }
  62. fixed4 frag (v2f i) : SV_Target
  63. {
  64. //fixed4 col = tex2D(_MainTex, i.uv);
  65. //fixed4 col2 = i.col;
  66. //col2.a = col2.a*col.a;
  67. // UNITY_APPLY_FOG(i.fogCoord, col2);
  68. return i.col;
  69. //return col2;
  70. }
  71. ENDCG
  72. }
  73. }
  74. }