Postprocess_blend.shader 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. //======= Copyright (c) Stereolabs Corporation, All rights reserved. ===============
  2. ///
  3. /// Blend the mesh to the ZED video
  4. ///
  5. Shader "Custom/Spatial Mapping/Postprocess Blend"
  6. {
  7. Properties
  8. {
  9. _MainTex ("Texture", 2D) = "white" {}
  10. _WireColor("Wire color", Color) = (1.0, 1.0, 1.0, 1.0)
  11. }
  12. SubShader
  13. {
  14. Tags { "RenderType"="Opaque" }
  15. ZWrite Off
  16. Pass
  17. {
  18. CGPROGRAM
  19. #pragma vertex vert
  20. #pragma fragment frag
  21. #include "UnityCG.cginc"
  22. struct appdata
  23. {
  24. float4 vertex : POSITION;
  25. float2 uv : TEXCOORD0;
  26. };
  27. struct v2f
  28. {
  29. float2 uv : TEXCOORD0;
  30. float4 vertex : SV_POSITION;
  31. };
  32. sampler2D _MainTex;
  33. sampler2D _ZEDMeshTex;
  34. float4 _ZEDMeshTex_ST;
  35. float4 _MainTex_ST;
  36. int _IsTextured;
  37. float4 _WireColor;
  38. v2f vert (appdata v)
  39. {
  40. v2f o;
  41. o.vertex = UnityObjectToClipPos(v.vertex);
  42. o.uv = TRANSFORM_TEX(v.uv, _MainTex);
  43. return o;
  44. }
  45. fixed4 frag(v2f i) : SV_Target
  46. {
  47. float4 meshColor = tex2D(_ZEDMeshTex, i.uv);
  48. if (_IsTextured == 0) {
  49. if (length(meshColor) < 0.1) {
  50. return tex2D(_MainTex, i.uv);
  51. }
  52. /*float4 m = clamp(tex2D(_MainTex, i.uv)*meshColor, float4(_WireColor.rgb - 0.05f,meshColor.a), float4(_WireColor.rgb + 0.05f, meshColor.a));
  53. #if !AWAY
  54. m = tex2D(_MainTex, i.uv) *(1 - meshColor.a) + (meshColor.a)* float4(_WireColor.rgb - 0.05f, meshColor.a);
  55. #endif
  56. return m;*/
  57. return meshColor;
  58. }
  59. else
  60. {
  61. return tex2D(_MainTex, i.uv);
  62. }
  63. if (meshColor.r != 0) {
  64. return meshColor;
  65. }
  66. return tex2D(_MainTex, i.uv);
  67. }
  68. ENDCG
  69. }
  70. }
  71. }