Advertisement
noradninja

Depth contrast shader

Jun 20th, 2022
159
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.27 KB | None | 0 0
  1. Shader "Vita/VFX/Lightning_Contrast"
  2. {
  3. Properties
  4. {
  5. _TintColor ("Tint Color", Color) = (.5, .5, .5, .5)
  6. [IntRange] _StencilRef ("Stencil Ref", Range(0,255)) = 0
  7. }
  8. SubShader
  9. {
  10. Stencil{
  11. Ref [_StencilRef]
  12. Comp Equal
  13. Pass Replace
  14. }
  15. Tags { "Queue" = "Transparent" "IgnoreProjector" = "True"}
  16. // No culling or depth
  17. Cull Back ZWrite Off ZTest Always
  18. Blend SrcAlpha OneMinusSrcAlpha
  19. Pass
  20. {
  21. CGPROGRAM
  22. #pragma vertex vert
  23. #pragma fragment frag
  24.  
  25. #include "UnityCG.cginc"
  26.  
  27. struct appdata
  28. {
  29. float4 vertex : POSITION;
  30. float2 uv : TEXCOORD0;
  31. };
  32.  
  33. struct v2f
  34. {
  35. float2 uv : TEXCOORD0;
  36. float4 vertex : SV_POSITION;
  37. float4 projPos : TEXCOORD3;
  38. };
  39.  
  40. v2f vert (appdata v)
  41. {
  42. v2f o;
  43. o.vertex = UnityObjectToClipPos(v.vertex);
  44. o.uv = v.uv;
  45. o.projPos = ComputeScreenPos (o.vertex);
  46. COMPUTE_EYEDEPTH(o.projPos.z);
  47. return o;
  48. }
  49.  
  50. fixed4 _TintColor;
  51. UNITY_DECLARE_DEPTH_TEXTURE(_CameraDepthTexture);
  52. fixed4 frag (v2f i) : SV_Target
  53. {
  54. float sceneZ = LinearEyeDepth (SAMPLE_DEPTH_TEXTURE_PROJ(_CameraDepthTexture, UNITY_PROJ_COORD(i.projPos)));
  55. fixed4 col = _TintColor * sceneZ;
  56. return col;
  57. }
  58. ENDCG
  59. }
  60. }
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement