1
0

SteamVR_AlphaOut.shader 962 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. //======= Copyright (c) Valve Corporation, All rights reserved. ===============
  2. // UNITY_SHADER_NO_UPGRADE
  3. Shader "Custom/SteamVR_AlphaOut" {
  4. Properties { _MainTex ("Base (RGB)", 2D) = "white" {} }
  5. CGINCLUDE
  6. #include "UnityCG.cginc"
  7. sampler2D _MainTex;
  8. struct v2f {
  9. float4 pos : SV_POSITION;
  10. float2 tex : TEXCOORD0;
  11. };
  12. v2f vert(appdata_base v) {
  13. v2f o;
  14. #if UNITY_VERSION >= 540
  15. o.pos = UnityObjectToClipPos(v.vertex);
  16. #else
  17. o.pos = mul(UNITY_MATRIX_MVP, v.vertex);
  18. #endif
  19. o.tex = v.texcoord;
  20. return o;
  21. }
  22. float luminance(float3 color)
  23. {
  24. return 0.2126 * color.r + 0.7152 * color.g + 0.0722 * color.b;
  25. }
  26. float4 frag(v2f i) : COLOR {
  27. float4 color = tex2D(_MainTex, i.tex);
  28. float a = saturate(color.a + luminance(color.rgb));
  29. return float4(a, a, a, a);
  30. }
  31. ENDCG
  32. SubShader {
  33. Pass {
  34. ZTest Always Cull Off ZWrite Off
  35. Fog { Mode Off }
  36. CGPROGRAM
  37. #pragma vertex vert
  38. #pragma fragment frag
  39. ENDCG
  40. }
  41. }
  42. }