ZED_ComposeMask.shader 999 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. //======= Copyright (c) Stereolabs Corporation, All rights reserved. ===============
  2. //Composes a mask from the red canal and the alpha canal of another texture
  3. Shader "ZED/ZED ComposeMask"
  4. {
  5. Properties
  6. {
  7. _MainTex ("Texture", 2D) = "white" {}
  8. }
  9. SubShader
  10. {
  11. Tags { "RenderType"="Opaque" }
  12. Pass
  13. {
  14. CGPROGRAM
  15. #pragma vertex vert
  16. #pragma fragment frag
  17. #include "UnityCG.cginc"
  18. struct appdata
  19. {
  20. float4 vertex : POSITION;
  21. float2 uv : TEXCOORD0;
  22. };
  23. struct v2f
  24. {
  25. float2 uv : TEXCOORD0;
  26. float4 vertex : SV_POSITION;
  27. };
  28. sampler2D _MainTex;
  29. float4 _MainTex_ST;
  30. sampler2D _Mask;
  31. v2f vert (appdata v)
  32. {
  33. v2f o;
  34. o.vertex = UnityObjectToClipPos(v.vertex);
  35. o.uv = TRANSFORM_TEX(v.uv, _MainTex);
  36. return o;
  37. }
  38. fixed4 frag (v2f i) : SV_Target
  39. {
  40. fixed4 col = tex2D(_Mask, i.uv).r + (tex2D(_MainTex, i.uv).a);
  41. return col;
  42. }
  43. ENDCG
  44. }
  45. }
  46. }