EyeOpeningEffect.shader 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. // Unity built-in shader source. Copyright (c) 2016 Unity Technologies. MIT license (see license.txt)
  2. Shader "FairyGUI/EyeOpeningEffect"
  3. {
  4. Properties
  5. {
  6. _MainTex("Base (RGB), Alpha (A)", 2D) = "black" {}
  7. _StencilComp("Stencil Comparison", Float) = 8
  8. _Stencil("Stencil ID", Float) = 0
  9. _StencilOp("Stencil Operation", Float) = 0
  10. _StencilWriteMask("Stencil Write Mask", Float) = 255
  11. _StencilReadMask("Stencil Read Mask", Float) = 255
  12. _ColorMask("Color Mask", Float) = 15
  13. [Toggle(UNITY_UI_ALPHACLIP)] _UseUIAlphaClip("Use Alpha Clip", Float) = 0
  14. [Space(100)]
  15. _Param("Param", vector) = (0.6, 0.3, 1, 1)
  16. }
  17. SubShader
  18. {
  19. Tags
  20. {
  21. "Queue" = "Transparent"
  22. "IgnoreProjector" = "True"
  23. "RenderType" = "Transparent"
  24. "PreviewType" = "Plane"
  25. "CanUseSpriteAtlas" = "True"
  26. }
  27. Stencil
  28. {
  29. Ref[_Stencil]
  30. Comp[_StencilComp]
  31. Pass[_StencilOp]
  32. ReadMask[_StencilReadMask]
  33. WriteMask[_StencilWriteMask]
  34. }
  35. Cull Off
  36. Lighting Off
  37. ZWrite Off
  38. ZTest[unity_GUIZTestMode]
  39. Blend SrcAlpha OneMinusSrcAlpha
  40. ColorMask[_ColorMask]
  41. Pass
  42. {
  43. Name "Default"
  44. CGPROGRAM
  45. #pragma vertex vert
  46. #pragma fragment frag
  47. #pragma target 2.0
  48. #include "UnityCG.cginc"
  49. #include "UnityUI.cginc"
  50. #pragma multi_compile __ UNITY_UI_CLIP_RECT
  51. #pragma multi_compile __ UNITY_UI_ALPHACLIP
  52. struct appdata_t
  53. {
  54. float4 vertex : POSITION;
  55. float4 color : COLOR;
  56. float2 texcoord : TEXCOORD0;
  57. UNITY_VERTEX_INPUT_INSTANCE_ID
  58. };
  59. struct v2f
  60. {
  61. float4 vertex : SV_POSITION;
  62. fixed4 color : COLOR;
  63. float2 texcoord : TEXCOORD0;
  64. float4 worldPosition : TEXCOORD1;
  65. UNITY_VERTEX_OUTPUT_STEREO
  66. };
  67. sampler2D _MainTex;
  68. fixed4 _Color;
  69. fixed4 _TextureSampleAdd;
  70. float4 _ClipRect;
  71. float4 _MainTex_ST;
  72. half3 _Param;
  73. v2f vert(appdata_t v)
  74. {
  75. v2f OUT;
  76. UNITY_SETUP_INSTANCE_ID(v);
  77. UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(OUT);
  78. OUT.worldPosition = v.vertex;
  79. OUT.vertex = UnityObjectToClipPos(OUT.worldPosition);
  80. OUT.texcoord = TRANSFORM_TEX(v.texcoord, _MainTex);
  81. OUT.color = v.color * _Color;
  82. return OUT;
  83. }
  84. fixed4 frag(v2f IN) : SV_Target
  85. {
  86. //half4 color = (tex2D(_MainTex, IN.texcoord) + _TextureSampleAdd) * IN.color;
  87. half4 color = IN.color;
  88. half x = IN.texcoord.x - 0.5;
  89. half y = IN.texcoord.y - 0.5;
  90. half oval = x * x / (_Param.x * _Param.x) + y * y / (_Param.y * _Param.y);
  91. color.a = oval;
  92. #ifdef UNITY_UI_CLIP_RECT
  93. color.a *= UnityGet2DClipping(IN.worldPosition.xy, _ClipRect);
  94. #endif
  95. #ifdef UNITY_UI_ALPHACLIP
  96. clip(color.a - 0.001);
  97. #endif
  98. return color;
  99. }
  100. ENDCG
  101. }
  102. }
  103. }