FrameFade.shader 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. // Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)'
  2. Shader "Virtence/FrameFade" {
  3. Properties {
  4. _Color ("Color" ,color) = (0.8, 0.7, 0.1)
  5. _TopLimit ("Top limit", Range(0.5, 1.0)) = 0.9
  6. _TopFade ("Top fade", Range(0.1, 1.0)) = 0.8
  7. }
  8. SubShader {
  9. Tags { "Queue" = "Overlay"}
  10. Pass {
  11. Lighting Off
  12. ZWrite Off
  13. ZTest Always
  14. Blend SrcAlpha OneMinusSrcAlpha
  15. Fog { Mode Off }
  16. // Blend Zero SrcAlpha
  17. CGPROGRAM
  18. #pragma vertex vert
  19. #pragma fragment frag
  20. #include "HLSLSupport.cginc"
  21. float _TopLimit;
  22. float _TopFade;
  23. fixed3 _Color;
  24. struct vin {
  25. float4 v : POSITION;
  26. };
  27. struct vout {
  28. float4 p : SV_POSITION;
  29. float yss : TEXCOORD0;
  30. };
  31. vout vert(vin IN)
  32. {
  33. vout OUT;
  34. float4 sp = UnityObjectToClipPos(IN.v);
  35. OUT.p = sp;
  36. // to range 0..1
  37. if(_ProjectionParams.x < 0.0) {
  38. OUT.yss = 1.0-(sp.y/sp.w+1.0)*0.5;
  39. } else {
  40. OUT.yss = (sp.y/sp.w+1.0)*0.5;
  41. }
  42. return OUT;
  43. }
  44. fixed4 frag(vout IN) : COLOR {
  45. fixed alpha = 1.0f;
  46. float screenY = IN.yss;
  47. if(screenY > _TopFade) {
  48. if(screenY > _TopLimit) {
  49. alpha = 0.01;
  50. // return fixed4(0.0, 0.0, 1.0, alpha);
  51. discard;
  52. } else {
  53. float delta = _TopLimit-_TopFade;
  54. alpha = 1.0-((screenY-_TopFade)/delta);
  55. // return fixed4(0.0, 1.0, alpha, alpha);
  56. }
  57. // return fixed4(0.0, screenY, alpha, 1.0);
  58. }
  59. // return fixed4(0.0, screenY, alpha, 1.0);
  60. return fixed4(_Color, alpha);
  61. }
  62. ENDCG
  63. }
  64. }
  65. }