Border.shader 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. //==========================================================
  2. //
  3. // Copyright (c) Guangzhou Shixiang Technology Co.,Ltd.
  4. // All rights reserved.
  5. //
  6. //==========================================================
  7. Shader "GxrSdk/Unlit/Border"
  8. {
  9. Properties
  10. {
  11. _MainTex ("Texture", 2D) = "white" {}
  12. _Color("Color",Color) = (1,1,0,1)
  13. _frameWidth("FrameWidth",float) = 0.03
  14. }
  15. SubShader
  16. {
  17. Tags { "RenderType"="Opaque" }
  18. LOD 100
  19. Pass
  20. {
  21. CGPROGRAM
  22. #pragma vertex vert
  23. #pragma fragment frag
  24. #pragma multi_compile_fog
  25. #include "UnityCG.cginc"
  26. struct appdata
  27. {
  28. float4 vertex : POSITION;
  29. float2 uv : TEXCOORD0;
  30. };
  31. struct v2f
  32. {
  33. float2 uv : TEXCOORD0;
  34. float4 vertex : SV_POSITION;
  35. };
  36. sampler2D _MainTex;
  37. float4 _MainTex_ST;
  38. float4 _Color;
  39. float _frameWidth;
  40. v2f vert (appdata v)
  41. {
  42. v2f o;
  43. o.vertex = UnityObjectToClipPos(v.vertex);
  44. o.uv = TRANSFORM_TEX(v.uv, _MainTex);
  45. return o;
  46. }
  47. fixed4 frag (v2f i) : SV_Target
  48. {
  49. // sample the texture
  50. fixed4 col = tex2D(_MainTex, i.uv);
  51. if (i.uv.x < _frameWidth || i.uv.x > (1 - _frameWidth)
  52. || i.uv.y < _frameWidth || i.uv.y > (1- _frameWidth))
  53. {
  54. return _Color;
  55. }
  56. else
  57. {
  58. return col;
  59. }
  60. }
  61. ENDCG
  62. }
  63. }
  64. }