NarReticleShader.shader 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. // Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)'
  2. // Copyright 2016 Nibiru. All rights reserved.
  3. //
  4. // Licensed under the Apache License, Version 2.0 (the "License");
  5. // you may not use this file except in compliance with the License.
  6. // You may obtain a copy of the License at
  7. //
  8. // http://www.apache.org/licenses/LICENSE-2.0
  9. //
  10. // Unless required by applicable law or agreed to in writing, software
  11. // distributed under the License is distributed on an "AS IS" BASIS,
  12. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. // See the License for the specific language governing permissions and
  14. // limitations under the License.
  15. Shader "NAR/Reticle" {
  16. Properties {
  17. _Color ("Color", Color) = ( 1, 1, 1, 1 )
  18. _InnerDiameter ("InnerDiameter", Range(0, 10.0)) = 1.5
  19. _OuterDiameter ("OuterDiameter", Range(0.00872665, 10.0)) = 2.0
  20. _DistanceInMeters ("DistanceInMeters", Range(0.0, 100.0)) = 2.0
  21. }
  22. SubShader {
  23. Tags { "Queue"="Overlay" "IgnoreProjector"="True" "RenderType"="Transparent" }
  24. Pass {
  25. Blend SrcAlpha OneMinusSrcAlpha
  26. AlphaTest Off
  27. Cull Back
  28. Lighting Off
  29. ZWrite Off
  30. ZTest Always
  31. Fog { Mode Off }
  32. CGPROGRAM
  33. #pragma vertex vert
  34. #pragma fragment frag
  35. #include "UnityCG.cginc"
  36. uniform float4 _Color;
  37. uniform float _InnerDiameter;
  38. uniform float _OuterDiameter;
  39. uniform float _DistanceInMeters;
  40. struct vertexInput {
  41. float4 vertex : POSITION;
  42. };
  43. struct fragmentInput{
  44. float4 position : SV_POSITION;
  45. };
  46. fragmentInput vert(vertexInput i) {
  47. float scale = lerp(_OuterDiameter, _InnerDiameter, i.vertex.z);
  48. float4 vert_out = float4(i.vertex.x * scale, i.vertex.y * scale, _DistanceInMeters, 1.0);
  49. fragmentInput o;
  50. o.position = UnityObjectToClipPos (vert_out);
  51. return o;
  52. }
  53. fixed4 frag(fragmentInput i) : SV_Target {
  54. fixed4 ret = _Color;
  55. return ret;
  56. }
  57. ENDCG
  58. }
  59. }
  60. }