FingerTipCursor.shader 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262
  1. // Copyright (c) Microsoft Corporation. All rights reserved.
  2. // Licensed under the MIT License. See LICENSE in the project root for license information.
  3. /// <summary>
  4. /// Note, this shader is generated from a tool and is not formated for user readability.
  5. /// </summary>
  6. Shader "ShadowSDK/FingerTipCursor" {
  7. Properties {
  8. [Header(Proximity)]
  9. _Proximity_Distance_("Proximity Distance", Range(0,1)) = 0.05
  10. _Fade_Near_Distance_("Fade Near Distance", Range(0,1)) = 0.1
  11. _Fade_Far_Distance_("Fade Far Distance", Range(0,1)) = 0.2
  12. _Shrink_Start_Distance_("Shrink Start Distance", Range(0,1)) = 0.1
  13. [Header(Shape)]
  14. _Near_Radius_Fraction_("Near Radius Fraction", Range(0,1)) = 0.5
  15. _Far_Center_Fraction_("Far Center Fraction", Range(0,1)) = 1
  16. _Near_Center_Fraction_("Near Center Fraction", Range(0,1)) = 0
  17. _Thickness_("Thickness", Range(0,1)) = 1
  18. [Header(Smooth Pulse)]
  19. _Rise_Start_("Rise Start", Range(0,1)) = 0
  20. _Rise_End_("Rise End", Range(0,1)) = 0.3
  21. _Fall_Start_("Fall Start", Range(0,1)) = 0.77
  22. _Fall_End_("Fall End", Range(0,1)) = 1
  23. _Start_Fall_Fade_("Start Fall Fade", Range(0,1)) = 0.05
  24. [Header(Colors)]
  25. _Edge_Color_("Edge Color", Color) = (0.188235,0.188235,0.188235,0.502)
  26. _Base_Color_("Base Color", Color) = (0.6,0.6,0.6,0.698)
  27. }
  28. SubShader {
  29. Tags{ "RenderType" = "Transparent" "Queue" = "Transparent"}
  30. Blend One OneMinusSrcAlpha
  31. LOD 100
  32. Pass
  33. {
  34. CGPROGRAM
  35. #pragma vertex vert
  36. #pragma fragment frag
  37. #pragma multi_compile_instancing
  38. #pragma target 4.0
  39. #include "UnityCG.cginc"
  40. float _Near_Radius_Fraction_;
  41. float _Far_Center_Fraction_;
  42. float _Near_Center_Fraction_;
  43. float _Thickness_;
  44. half _Rise_Start_;
  45. half _Rise_End_;
  46. half _Fall_Start_;
  47. half _Fall_End_;
  48. float _Start_Fall_Fade_;
  49. half4 _Edge_Color_;
  50. half4 _Base_Color_;
  51. bool _Right_Hand_;
  52. bool _Use_Local_Proximity_;
  53. float _Proximity_Distance_;
  54. float _Fade_Near_Distance_;
  55. float _Fade_Far_Distance_;
  56. float _Shrink_Start_Distance_;
  57. struct VertexInput {
  58. float4 vertex : POSITION;
  59. float2 uv0 : TEXCOORD0;
  60. UNITY_VERTEX_INPUT_INSTANCE_ID
  61. };
  62. struct VertexOutput {
  63. float4 pos : SV_POSITION;
  64. half4 normalWorld : TEXCOORD5;
  65. UNITY_VERTEX_OUTPUT_STEREO
  66. };
  67. // declare parm vars here
  68. //BLOCK_BEGIN Object_To_World_Pos 207
  69. void Object_To_World_Pos_B207(
  70. float3 Pos_Object,
  71. out float3 Pos_World )
  72. {
  73. Pos_World=(mul(unity_ObjectToWorld, float4(Pos_Object, 1)));
  74. }
  75. //BLOCK_END Object_To_World_Pos
  76. //BLOCK_BEGIN Resize 220
  77. void Resize_B220(
  78. float Distance,
  79. float Shrink_Start_Distance,
  80. float Far_Center_Fraction,
  81. float Near_Center_Fraction,
  82. float Near_Radius_Fraction,
  83. float3 Position,
  84. float2 UV,
  85. float Thickness,
  86. float Fade_Near,
  87. float Fade_Far,
  88. float Start_Fall_Fade,
  89. out float Center_Fraction,
  90. out float Radius_At_D,
  91. out float3 New_Position,
  92. out float Outer_Ring,
  93. out float Rim,
  94. out float Fade,
  95. out float Inner_Fade )
  96. {
  97. float k = saturate(Distance/Shrink_Start_Distance);
  98. Center_Fraction = lerp(Near_Center_Fraction, Far_Center_Fraction, k);
  99. Radius_At_D = lerp(Near_Radius_Fraction, 1.0, k);
  100. //Outer_Ring = length(Position.xy)<Ring_Middle ? 0 : 1;
  101. Rim = UV.x*2.0;
  102. if (false) {
  103. Outer_Ring = 1.0-UV.y;
  104. } else {
  105. Outer_Ring = UV.y;
  106. }
  107. float scale = lerp(Center_Fraction,Radius_At_D,Outer_Ring);
  108. New_Position = Position * float3(scale,scale,Thickness);
  109. Fade = 1.0-saturate((Distance-Fade_Near)/(Fade_Far-Fade_Near));
  110. Inner_Fade = saturate(k/Start_Fall_Fade);
  111. }
  112. //BLOCK_END Resize
  113. VertexOutput vert(VertexInput vertInput)
  114. {
  115. UNITY_SETUP_INSTANCE_ID(vertInput);
  116. VertexOutput o;
  117. UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
  118. float Center_Fraction_Q220;
  119. float Radius_At_D_Q220;
  120. float3 New_Position_Q220;
  121. float Outer_Ring_Q220;
  122. float Rim_Q220;
  123. float Fade_Q220;
  124. float Inner_Fade_Q220;
  125. Resize_B220(_Proximity_Distance_,_Shrink_Start_Distance_,_Far_Center_Fraction_,_Near_Center_Fraction_,_Near_Radius_Fraction_,vertInput.vertex.xyz,vertInput.uv0,_Thickness_,_Fade_Near_Distance_,_Fade_Far_Distance_,0.05,Center_Fraction_Q220,Radius_At_D_Q220,New_Position_Q220,Outer_Ring_Q220,Rim_Q220,Fade_Q220,Inner_Fade_Q220);
  126. float3 Pos_World_Q207;
  127. Object_To_World_Pos_B207(New_Position_Q220,Pos_World_Q207);
  128. // From_XYZ
  129. float3 Vec3_Q217 = float3(Rim_Q220,Fade_Q220,Inner_Fade_Q220);
  130. float3 Position = Pos_World_Q207;
  131. float3 Normal = Vec3_Q217;
  132. float2 UV = float2(0,0);
  133. float3 Tangent = float3(0,0,0);
  134. float3 Binormal = float3(0,0,0);
  135. float4 Color = float4(1,1,1,1);
  136. o.pos = UnityObjectToClipPos(vertInput.vertex);
  137. o.pos = mul(UNITY_MATRIX_VP, float4(Position,1));
  138. o.normalWorld.xyz = Normal; o.normalWorld.w=1.0;
  139. return o;
  140. }
  141. //BLOCK_BEGIN Scale_Color 215
  142. void Scale_Color_B215(
  143. half4 Color,
  144. half Scalar,
  145. out half4 Result )
  146. {
  147. Result = Scalar * Color;
  148. }
  149. //BLOCK_END Scale_Color
  150. //BLOCK_BEGIN To_XYZ 218
  151. void To_XYZ_B218(
  152. float3 Vec3,
  153. out float X,
  154. out float Y,
  155. out float Z )
  156. {
  157. X=Vec3.x;
  158. Y=Vec3.y;
  159. Z=Vec3.z;
  160. }
  161. //BLOCK_END To_XYZ
  162. //BLOCK_BEGIN Smooth_Pulse 219
  163. float ramp(float s, float e, float x)
  164. {
  165. return saturate((x-s)/(e-s));
  166. }
  167. void Smooth_Pulse_B219(
  168. half Rise_Start,
  169. half Rise_End,
  170. half Fall_Start,
  171. half Fall_End,
  172. half X,
  173. float Inner_Fade,
  174. out half Pulse )
  175. {
  176. //Pulse = smoothstep(Rise_Start,Rise_End,X)-smoothstep(Fall_Start,Fall_End,X);
  177. float x = abs(1.0-X);
  178. Pulse = ramp(Rise_Start,Rise_End,x)-ramp(Fall_Start,Fall_End,x)*Inner_Fade;
  179. }
  180. //BLOCK_END Smooth_Pulse
  181. //fixed4 frag(VertexOutput fragInput, fixed facing : VFACE) : SV_Target
  182. half4 frag(VertexOutput fragInput) : SV_Target
  183. {
  184. half4 result;
  185. float X_Q218;
  186. float Y_Q218;
  187. float Z_Q218;
  188. To_XYZ_B218(fragInput.normalWorld.xyz,X_Q218,Y_Q218,Z_Q218);
  189. half Pulse_Q219;
  190. Smooth_Pulse_B219(_Rise_Start_,_Rise_End_,_Fall_Start_,_Fall_End_,X_Q218,Z_Q218,Pulse_Q219);
  191. // Mix_Colors
  192. half4 Color_At_T_Q214 = lerp(_Edge_Color_, _Base_Color_,float4( Pulse_Q219, Pulse_Q219, Pulse_Q219, Pulse_Q219));
  193. half4 Result_Q215;
  194. Scale_Color_B215(Color_At_T_Q214,Y_Q218,Result_Q215);
  195. float4 Out_Color = Result_Q215;
  196. float Clip_Threshold = 0;
  197. result = Out_Color;
  198. return result;
  199. }
  200. ENDCG
  201. }
  202. }
  203. }