You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

64 lines
1.1 KiB

5 years ago
  1. Shader "Fog Volume/RT viewers/RT_DepthR"
  2. {
  3. Properties{
  4. _MainTex("Base", 2D) = "" {}
  5. _Intensity("Intensity", Range(1, 20)) = 1
  6. }
  7. SubShader
  8. {
  9. Tags { "RenderType"="Opaque" }
  10. LOD 100
  11. Pass
  12. {
  13. CGPROGRAM
  14. #pragma multi_compile _ _FOG_LOWRES_RENDERER
  15. #pragma vertex vert
  16. #pragma fragment frag
  17. #include "UnityCG.cginc"
  18. float _Intensity;
  19. struct appdata
  20. {
  21. float4 vertex : POSITION;
  22. float2 uv : TEXCOORD0;
  23. };
  24. struct v2f
  25. {
  26. float2 uv : TEXCOORD0;
  27. float4 vertex : SV_POSITION;
  28. };
  29. sampler2D RT_DepthR, _MainTex;
  30. float4 RT_DepthR_ST, _MainTex_TexelSize, _MainTex_ST;
  31. sampler2D _CameraDepthTexture;
  32. v2f vert (appdata v)
  33. {
  34. v2f o;
  35. o.vertex = UnityObjectToClipPos(v.vertex);
  36. o.uv = TRANSFORM_TEX(v.uv, RT_DepthR);
  37. return o;
  38. }
  39. fixed4 frag (v2f i) : SV_Target
  40. {
  41. // sample the texture
  42. float Depth = tex2D(RT_DepthR, i.uv).r;
  43. Depth *= 1000;
  44. return 1 / Depth*_Intensity;
  45. //#if UNITY_REVERSED_Z!=1
  46. // return float4(1, 0, 0, 1);
  47. //#else
  48. // return float4(0, 1, 0, 1);
  49. //#endif
  50. //return z.r;
  51. //return DecodeFloatRGBA(z)*50;
  52. }
  53. ENDCG
  54. }
  55. }
  56. }