Spine-Outline-Pass.cginc 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. #ifndef SPINE_OUTLINE_PASS_INCLUDED
  2. #define SPINE_OUTLINE_PASS_INCLUDED
  3. #include "UnityCG.cginc"
  4. #ifdef SKELETON_GRAPHIC
  5. #include "UnityUI.cginc"
  6. #endif
  7. #include "../../CGIncludes/Spine-Outline-Common.cginc"
  8. sampler2D _MainTex;
  9. float _OutlineWidth;
  10. float4 _OutlineColor;
  11. float4 _MainTex_TexelSize;
  12. float _ThresholdEnd;
  13. float _OutlineSmoothness;
  14. float _OutlineOpaqueAlpha;
  15. float _OutlineMipLevel;
  16. int _OutlineReferenceTexWidth;
  17. #ifdef SKELETON_GRAPHIC
  18. float4 _ClipRect;
  19. #endif
  20. struct VertexInput {
  21. float4 vertex : POSITION;
  22. float2 uv : TEXCOORD0;
  23. float4 vertexColor : COLOR;
  24. UNITY_VERTEX_INPUT_INSTANCE_ID
  25. };
  26. struct VertexOutput {
  27. float4 pos : SV_POSITION;
  28. float2 uv : TEXCOORD0;
  29. float vertexColorAlpha : COLOR;
  30. #ifdef SKELETON_GRAPHIC
  31. float4 worldPosition : TEXCOORD1;
  32. #endif
  33. UNITY_VERTEX_OUTPUT_STEREO
  34. };
  35. #ifdef SKELETON_GRAPHIC
  36. VertexOutput vertOutlineGraphic(VertexInput v) {
  37. VertexOutput o;
  38. UNITY_SETUP_INSTANCE_ID(v);
  39. UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
  40. o.worldPosition = v.vertex;
  41. o.pos = UnityObjectToClipPos(o.worldPosition);
  42. o.uv = v.uv;
  43. #ifdef UNITY_HALF_TEXEL_OFFSET
  44. o.pos.xy += (_ScreenParams.zw - 1.0) * float2(-1, 1);
  45. #endif
  46. o.vertexColorAlpha = v.vertexColor.a;
  47. return o;
  48. }
  49. #else // !SKELETON_GRAPHIC
  50. VertexOutput vertOutline(VertexInput v) {
  51. VertexOutput o;
  52. UNITY_SETUP_INSTANCE_ID(v);
  53. UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
  54. o.pos = UnityObjectToClipPos(v.vertex);
  55. o.uv = v.uv;
  56. o.vertexColorAlpha = v.vertexColor.a;
  57. return o;
  58. }
  59. #endif
  60. float4 fragOutline(VertexOutput i) : SV_Target {
  61. float4 texColor = computeOutlinePixel(_MainTex, _MainTex_TexelSize.xy, i.uv, i.vertexColorAlpha,
  62. _OutlineWidth, _OutlineReferenceTexWidth, _OutlineMipLevel,
  63. _OutlineSmoothness, _ThresholdEnd, _OutlineOpaqueAlpha, _OutlineColor);
  64. #ifdef SKELETON_GRAPHIC
  65. texColor *= UnityGet2DClipping(i.worldPosition.xy, _ClipRect);
  66. #endif
  67. return texColor;
  68. }
  69. #endif // SPINE_OUTLINE_PASS_INCLUDED