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.

61 lines
1.9 KiB

5 years ago
  1. // Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)'
  2. Shader "Hidden/FogVolumeDensityFilter" {
  3. Properties{ _MainTex("", any) = "" {} }
  4. CGINCLUDE
  5. #include "UnityCG.cginc"
  6. struct v2f {
  7. float4 pos : SV_POSITION;
  8. half2 uv : TEXCOORD0;
  9. half2 taps[4] : TEXCOORD1;
  10. };
  11. sampler2D _MainTex;
  12. half4 _MainTex_TexelSize;
  13. half4 _BlurOffsets;
  14. half FOV_compensation;
  15. //half _Distortion = -0.01;
  16. sampler2D RT_FogVolumeConvolution, RT_FogVolume, _source;
  17. v2f vert(appdata_img v) {
  18. v2f o;
  19. o.pos = UnityObjectToClipPos(v.vertex);
  20. o.uv = v.texcoord - _BlurOffsets.xy * _MainTex_TexelSize.xy; // hack, see BlurEffect.cs for the reason for this. let's make a new blur effect soon
  21. o.taps[0] = o.uv + _MainTex_TexelSize * _BlurOffsets.xy*FOV_compensation;
  22. o.taps[1] = o.uv - _MainTex_TexelSize * _BlurOffsets.xy*FOV_compensation;
  23. o.taps[2] = o.uv + _MainTex_TexelSize * _BlurOffsets.xy * half2(1, -1)*FOV_compensation;
  24. o.taps[3] = o.uv - _MainTex_TexelSize * _BlurOffsets.xy * half2(1, -1)*FOV_compensation;
  25. return o;
  26. }
  27. half4 frag(v2f i) : SV_Target{
  28. //distortion experiment
  29. /*half4 FV = tex2D(RT_FogVolumeConvolution, i.uv);
  30. half4 TexturedFogVolumes = tex2D(RT_FogVolume, i.uv);
  31. half Distortion = FV.a * _Distortion * TexturedFogVolumes.a + 1;
  32. half4 color = tex2D(_MainTex, (i.taps[0]-0.5)* Distortion + 0.5);
  33. color += tex2D(_MainTex, (i.taps[1] - 0.5)* Distortion + 0.5);
  34. color += tex2D(_MainTex, (i.taps[2] - 0.5)* Distortion + 0.5);
  35. color += tex2D(_MainTex, (i.taps[3] - 0.5)* Distortion + 0.5);*/
  36. half4 color = tex2D(_MainTex, i.taps[0]);
  37. color += tex2D(_MainTex, i.taps[1]);
  38. color += tex2D(_MainTex, i.taps[2]);
  39. color += tex2D(_MainTex, i.taps[3]);
  40. return color *.25;
  41. }
  42. ENDCG
  43. SubShader {
  44. Pass{
  45. ZTest Always Cull Off ZWrite Off
  46. CGPROGRAM
  47. #pragma vertex vert
  48. #pragma fragment frag
  49. ENDCG
  50. }
  51. }
  52. Fallback off
  53. }