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.

86 lines
1.8 KiB

5 years ago
  1. // Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)'
  2. //Shader "Hidden/LowResReplace"
  3. Shader "Hidden/Fog Volume/Surrogate"
  4. {
  5. SubShader{
  6. Tags{
  7. "Queue" = "Transparent" "IgnoreProjector" = "True"
  8. // "RenderType" = "Opaque"
  9. }
  10. LOD 100
  11. //Blend One OneMinusSrcAlpha
  12. // Blend SrcAlpha OneMinusSrcAlpha
  13. Blend[_SrcBlend] OneMinusSrcAlpha //One OneMinusSrcAlpha works best with noise
  14. Fog{ Mode Off }
  15. Cull Front
  16. Lighting Off
  17. ZWrite Off
  18. ZTest [_ztest]
  19. //ZTest LEqual
  20. Pass
  21. {
  22. CGPROGRAM
  23. #pragma vertex vert
  24. #pragma fragment frag
  25. #include "UnityCG.cginc"
  26. #pragma shader_feature _EDITOR_WINDOW
  27. #define red float4(1, 0,0,1)
  28. #define green float4(0, 1,0,1)
  29. int _SrcBlend, _ztest;
  30. sampler2D RT_FogVolume, RT_FogVolumeR;
  31. struct appdata_t {
  32. float4 vertex : POSITION;
  33. float2 texcoord: TEXCOORD0;
  34. };
  35. struct v2f {
  36. float4 vertex : SV_POSITION;
  37. float4 projPos : TEXCOORD0;
  38. //float2 uv : TEXCOORD1;
  39. };
  40. v2f vert(appdata_t v)
  41. {
  42. #if UNITY_UV_STARTS_AT_TOP
  43. float scale = -1.0;
  44. #else
  45. float scale = 1.0;
  46. #endif
  47. v2f o;
  48. o.vertex = UnityObjectToClipPos(v.vertex);
  49. o.projPos = ComputeScreenPos(o.vertex);
  50. return o;
  51. }
  52. half4 frag(v2f i) : SV_Target
  53. {
  54. float4 coords = 0, FV;
  55. coords = UNITY_PROJ_COORD(i.projPos);
  56. float2 screenUV = coords.xy / coords.w;
  57. #if UNITY_SINGLE_PASS_STEREO
  58. float4 scaleOffset = unity_StereoScaleOffset[unity_StereoEyeIndex];
  59. screenUV = (screenUV - scaleOffset.zw) / scaleOffset.xy;
  60. #endif
  61. if (unity_StereoEyeIndex == 0)
  62. {
  63. FV = tex2D(RT_FogVolume, screenUV)/**red*/;
  64. }
  65. else
  66. {
  67. FV = tex2D(RT_FogVolumeR, screenUV)/**green*/;
  68. }
  69. #ifdef _EDITOR_WINDOW
  70. FV = 0;
  71. // FV= float4(1, 0, 0, 1)*FV;
  72. #endif
  73. return FV;
  74. return float4(1, 0, 0, 1)*FV;
  75. }
  76. ENDCG
  77. }
  78. }
  79. }