From 591a48f3d419d5f076a5b9901db13e5e353d4c46 Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Sun, 26 Mar 2017 10:23:17 +1100 Subject: [PATCH 1/2] Fixes the screen flipping on DirectX UV coordinates are reversed on DX-like platforms, this prevents the screen from flipping around. --- Assets/Shaders/AtmosphericScattering.shader | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Assets/Shaders/AtmosphericScattering.shader b/Assets/Shaders/AtmosphericScattering.shader index 2be7a9e..46347e4 100644 --- a/Assets/Shaders/AtmosphericScattering.shader +++ b/Assets/Shaders/AtmosphericScattering.shader @@ -254,6 +254,9 @@ Shader "Hidden/AtmosphericScattering" float4 fragDir(v2f i) : COLOR0 { float2 uv = i.uv.xy; +#ifdef UNITY_UV_STARTS_AT_TOP + uv.y = 1.0 - uv.y; +#endif float depth = SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, uv); float linearDepth = Linear01Depth(depth); From 10748dbf99fc31727c33d5653c326221e04eb622 Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Sun, 26 Mar 2017 10:33:27 +1100 Subject: [PATCH 2/2] Fixes bug with wrong depth texture Fixes the depth texture being flipped as a result of previous commit. --- Assets/Shaders/AtmosphericScattering.shader | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Assets/Shaders/AtmosphericScattering.shader b/Assets/Shaders/AtmosphericScattering.shader index 46347e4..3a0c26d 100644 --- a/Assets/Shaders/AtmosphericScattering.shader +++ b/Assets/Shaders/AtmosphericScattering.shader @@ -257,7 +257,7 @@ Shader "Hidden/AtmosphericScattering" #ifdef UNITY_UV_STARTS_AT_TOP uv.y = 1.0 - uv.y; #endif - float depth = SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, uv); + float depth = SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, i.uv.xy); float linearDepth = Linear01Depth(depth); float3 wpos = i.wpos;