RingShader.shader 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. Shader "ZED/Planetarium/Rings" {
  2. Properties {
  3. _Color ("Color", Color) = (1,1,1,1)
  4. }
  5. SubShader
  6. {
  7. Tags{ "RenderType" = "Transparent" "Queue"="Transparent" }
  8. Blend SrcAlpha OneMinusSrcAlpha
  9. Pass
  10. {
  11. Stencil{
  12. Ref 148
  13. Comp Always
  14. Pass replace
  15. }
  16. CGPROGRAM
  17. #pragma vertex vert
  18. #pragma fragment frag
  19. #include "UnityCG.cginc"
  20. struct appdata
  21. {
  22. float4 vertex : POSITION;
  23. float2 uv : TEXCOORD0;
  24. };
  25. struct v2f
  26. {
  27. float2 uv : TEXCOORD0;
  28. float4 vertex : SV_POSITION;
  29. float dist : TEXCOORD1;
  30. };
  31. sampler2D _MainTex;
  32. float4 _MainTex_ST;
  33. float4 _Color;
  34. v2f vert(appdata v)
  35. {
  36. v2f o;
  37. o.vertex = UnityObjectToClipPos(v.vertex);
  38. o.uv = TRANSFORM_TEX(v.uv, _MainTex);
  39. o.dist = length(ObjSpaceViewDir(v.vertex));
  40. return o;
  41. }
  42. float4 frag(v2f i) : SV_Target
  43. {
  44. float4 color = _Color;
  45. //#if AWAYS
  46. color.a = 10 / (0.1 + i.dist*i.dist);
  47. color.a = _Color.a;
  48. //#endif
  49. return color;
  50. }
  51. ENDCG
  52. }
  53. }
  54. Fallback off
  55. }