ZED_Unlit_PostProcessing.shader 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. //Example of Unlit using the stencil buffer for the post-processing
  2. // Should be used in deferred only
  3. Shader "ZED/ZED_Unlit_PostProcessing"
  4. {
  5. Properties
  6. {
  7. _MainTex ("Texture", 2D) = "white" {}
  8. }
  9. SubShader
  10. {
  11. Tags { "RenderType"="Opaque" }
  12. LOD 100
  13. //Used in deferred only for the post processing
  14. Stencil{
  15. ref 148
  16. Pass replace
  17. }
  18. Pass
  19. {
  20. CGPROGRAM
  21. #pragma vertex vert
  22. #pragma fragment frag
  23. // make fog work
  24. #pragma multi_compile_fog
  25. #include "UnityCG.cginc"
  26. struct appdata
  27. {
  28. float4 vertex : POSITION;
  29. float2 uv : TEXCOORD0;
  30. };
  31. struct v2f
  32. {
  33. float2 uv : TEXCOORD0;
  34. UNITY_FOG_COORDS(1)
  35. float4 vertex : SV_POSITION;
  36. };
  37. sampler2D _MainTex;
  38. float4 _MainTex_ST;
  39. v2f vert (appdata v)
  40. {
  41. v2f o;
  42. o.vertex = UnityObjectToClipPos(v.vertex);
  43. o.uv = TRANSFORM_TEX(v.uv, _MainTex);
  44. UNITY_TRANSFER_FOG(o,o.vertex);
  45. return o;
  46. }
  47. fixed4 frag (v2f i) : SV_Target
  48. {
  49. // sample the texture
  50. fixed4 col = tex2D(_MainTex, i.uv);
  51. // apply fog
  52. UNITY_APPLY_FOG(i.fogCoord, col);
  53. return col;
  54. }
  55. ENDCG
  56. }
  57. }
  58. }