GxrQuitDialogImage.shader 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. //==========================================================
  2. //
  3. // Copyright (c) Guangzhou Shixiang Technology Co.,Ltd.
  4. // All rights reserved.
  5. //
  6. //==========================================================
  7. // Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)'
  8. Shader "GxrSdk/QuitDialog/Image"
  9. {
  10. Properties
  11. {
  12. [PerRendererData] _MainTex("Sprite Texture", 2D) = "white" {}
  13. _Color("Tint", Color) = (1,1,1,1)
  14. [MaterialToggle] PixelSnap("Pixel snap", Float) = 0
  15. _MaskLayer("Culling Mask",2D) = "white"{}//混合的图片,设置为白色的图片,任何颜色与白色混合,其颜色不变
  16. _radius("radius",float) = 2
  17. }
  18. SubShader
  19. {
  20. Tags
  21. {
  22. "RenderType" = "Transparent"
  23. "Queue" = "Transparent"
  24. "IgnoreProjector" = "True"
  25. "PreviewType" = "Plane"
  26. "CanUseSpriteAtlas" = "True"
  27. }
  28. Cull Off //关闭背面剔除
  29. Lighting Off //关闭灯光 Opaque
  30. //ZWrite Off //关闭Z缓冲
  31. ZTest Always
  32. Blend SrcAlpha OneMinusSrcAlpha //混合源系数one(1) 目标系数OneMinusSrcAlpha(1-one=0)
  33. Pass
  34. {
  35. CGPROGRAM
  36. #pragma vertex vert
  37. #pragma fragment frag
  38. #pragma multi_compile _ PIXELSNAP_ON //告诉Unity编译不同版本的Shader,这里和后面vert中的PIXELSNAP_ON对应
  39. #pragma shader_feature ETC1_EXTERNAL_ALPHA
  40. #include "UnityCG.cginc"
  41. struct appdata_t //vert输入
  42. {
  43. float4 vertex : POSITION;
  44. float4 color : COLOR;
  45. float2 texcoord : TEXCOORD0;
  46. };
  47. struct v2f //vert输出数据结构
  48. {
  49. float4 vertex : SV_POSITION;
  50. fixed4 color : COLOR;
  51. float2 texcoord : TEXCOORD0;
  52. };
  53. fixed4 _Color;
  54. v2f vert(appdata_t IN)
  55. {
  56. v2f OUT;
  57. OUT.vertex = UnityObjectToClipPos(IN.vertex);
  58. OUT.texcoord = IN.texcoord;
  59. OUT.color = IN.color * _Color;
  60. #ifdef PIXELSNAP_ON
  61. OUT.vertex = UnityPixelSnap(OUT.vertex);
  62. #endif
  63. return OUT;
  64. }
  65. sampler2D _MainTex;
  66. sampler2D _AlphaTex;
  67. sampler2D _MaskLayer;
  68. float _radius;
  69. fixed4 SampleSpriteTexture(float2 uv)
  70. {
  71. fixed4 color = tex2D(_MainTex, uv);
  72. //#if ETC1_EXTERNAL_ALPHA //etc1没有透明通道,从另一图中取a值
  73. // // get the color from an external texture (usecase: Alpha support for ETC1 on android)
  74. // //color.a = tex2D(_AlphaTex, uv).r;
  75. //#endif //ETC1_EXTERNAL_ALPHA
  76. return color;
  77. }
  78. fixed4 frag(v2f IN) : SV_Target
  79. {
  80. fixed4 c = SampleSpriteTexture(IN.texcoord) * IN.color;
  81. //c.rgb *= 1;
  82. return c;
  83. }
  84. ENDCG
  85. }
  86. }
  87. }