FingerTipCursor.shader 7.1 KB

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