Advertisement
Guest User

cone shader

a guest
Oct 31st, 2018
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.34 KB | None | 0 0
  1. Shader "Unlit/DangerOverlay"
  2. {
  3. Properties
  4. {
  5. _MainTex ("Texture", 2D) = "white" {}
  6. _Color ("Color", Color) = (1,1,1,1)
  7. _Stencil("Stencil ID", Float) = 0
  8. _SpecularAmount("Specular Amount", Float) = 1
  9. _AmbientAmount("Ambient Amount", Float) = .4
  10. }
  11. SubShader
  12. {
  13. Tags {
  14. "RenderType"="Transparent"
  15. "Queue"="Transparent"
  16. "LightMode"="ForwardBase"
  17. }
  18. LOD 100
  19.  
  20. Pass
  21. {
  22. Stencil {
  23. Ref [_Stencil]
  24. Comp Always
  25. Pass Replace
  26. ZFail Replace
  27. }
  28. Cull Back
  29. Blend SrcAlpha OneMinusSrcAlpha
  30.  
  31. CGPROGRAM
  32. #pragma vertex vert
  33. #pragma fragment frag
  34.  
  35. #include "UnityCG.cginc"
  36. #include "UnityLightingCommon.cginc"
  37.  
  38. struct appdata
  39. {
  40. float4 vertex : POSITION;
  41. float2 uv : TEXCOORD0;
  42. float3 normal : NORMAL;
  43. };
  44.  
  45. struct v2f
  46. {
  47. float2 uv : TEXCOORD0;
  48. float4 vertex : SV_POSITION;
  49. float4 diff : COLOR0;
  50. };
  51.  
  52. sampler2D _MainTex;
  53.  
  54. float4 _MainTex_ST;
  55. float4 _Color;
  56. float _SpecularAmount;
  57. float _AmbientAmount;
  58.  
  59. v2f vert(appdata v)
  60. {
  61. v2f o;
  62. o.vertex = UnityObjectToClipPos(v.vertex);
  63. o.uv = TRANSFORM_TEX(v.uv, _MainTex);
  64.  
  65. half3 worldNormal = UnityObjectToWorldNormal(v.normal);
  66. half nl = max(0, dot(worldNormal * 2, _WorldSpaceLightPos0.xyz));
  67. o.diff = nl * nl * _LightColor0;
  68.  
  69. return o;
  70. }
  71.  
  72. fixed4 frag(v2f i) : SV_Target
  73. {
  74. fixed4 col = tex2D(_MainTex, i.uv) * _Color * 1.25 * i.diff + _Color * _AmbientAmount;
  75. col.a = _Color.a;
  76. return col;
  77. }
  78. ENDCG
  79. }
  80.  
  81. Pass
  82. {
  83. Stencil {
  84. Ref [_Stencil]
  85. Comp NotEqual
  86. }
  87. Cull Front
  88. Blend SrcAlpha OneMinusSrcAlpha
  89. ZTest Always
  90.  
  91. CGPROGRAM
  92. #pragma vertex vert
  93. #pragma fragment frag
  94.  
  95. #include "UnityCG.cginc"
  96.  
  97. struct appdata
  98. {
  99. float4 vertex : POSITION;
  100. float2 uv : TEXCOORD0;
  101. };
  102.  
  103. struct v2f
  104. {
  105. float2 uv : TEXCOORD0;
  106. float4 vertex : SV_POSITION;
  107. };
  108.  
  109. sampler2D _MainTex;
  110. float4 _MainTex_ST;
  111. float4 _Color;
  112.  
  113. v2f vert(appdata v)
  114. {
  115. v2f o;
  116. o.vertex = UnityObjectToClipPos(v.vertex);
  117. o.uv = TRANSFORM_TEX(v.uv, _MainTex);
  118. return o;
  119. }
  120.  
  121. fixed4 frag(v2f i) : SV_Target
  122. {
  123. fixed4 col = tex2D(_MainTex, i.uv) * _Color;
  124. col.a *= .35;
  125. return col;
  126. }
  127. ENDCG
  128. }
  129. }
  130. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement