Spine-Outline-Pass.cginc 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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 _OutlineMipLevel;
  15. int _OutlineReferenceTexWidth;
  16. #ifdef SKELETON_GRAPHIC
  17. float4 _ClipRect;
  18. #endif
  19. struct VertexInput {
  20. float4 vertex : POSITION;
  21. float2 uv : TEXCOORD0;
  22. float4 vertexColor : COLOR;
  23. UNITY_VERTEX_INPUT_INSTANCE_ID
  24. };
  25. struct VertexOutput {
  26. float4 pos : SV_POSITION;
  27. float2 uv : TEXCOORD0;
  28. float vertexColorAlpha : COLOR;
  29. #ifdef SKELETON_GRAPHIC
  30. float4 worldPosition : TEXCOORD1;
  31. #endif
  32. UNITY_VERTEX_OUTPUT_STEREO
  33. };
  34. #ifdef SKELETON_GRAPHIC
  35. VertexOutput vertOutlineGraphic(VertexInput v) {
  36. VertexOutput o;
  37. UNITY_SETUP_INSTANCE_ID(v);
  38. UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
  39. o.worldPosition = v.vertex;
  40. o.pos = UnityObjectToClipPos(o.worldPosition);
  41. o.uv = v.uv;
  42. #ifdef UNITY_HALF_TEXEL_OFFSET
  43. o.pos.xy += (_ScreenParams.zw - 1.0) * float2(-1, 1);
  44. #endif
  45. o.vertexColorAlpha = v.vertexColor.a;
  46. return o;
  47. }
  48. #else // !SKELETON_GRAPHIC
  49. VertexOutput vertOutline(VertexInput v) {
  50. VertexOutput o;
  51. UNITY_SETUP_INSTANCE_ID(v);
  52. UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
  53. o.pos = UnityObjectToClipPos(v.vertex);
  54. o.uv = v.uv;
  55. o.vertexColorAlpha = v.vertexColor.a;
  56. return o;
  57. }
  58. #endif
  59. float4 fragOutline(VertexOutput i) : SV_Target {
  60. float4 texColor = computeOutlinePixel(_MainTex, _MainTex_TexelSize.xy, i.uv, i.vertexColorAlpha,
  61. _OutlineWidth, _OutlineReferenceTexWidth, _OutlineMipLevel,
  62. _OutlineSmoothness, _ThresholdEnd, _OutlineColor);
  63. #ifdef SKELETON_GRAPHIC
  64. texColor *= UnityGet2DClipping(i.worldPosition.xy, _ClipRect);
  65. #endif
  66. return texColor;
  67. }
  68. #endif // SPINE_OUTLINE_PASS_INCLUDED