summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoryum <yum.food.vr@gmail.com>2025-06-05 22:15:00 -0700
committeryum <yum.food.vr@gmail.com>2025-06-05 22:15:00 -0700
commitd888c25cfcf0da223bfa9e8312d825183a65122a (patch)
tree3c7310b658ceaec35b6e685da12a985900311fba
parent8b7ae8db808d76ddea503f94e142c7d37c1b43d3 (diff)
fix fog in vr
-rw-r--r--fog.cginc7
1 files changed, 2 insertions, 5 deletions
diff --git a/fog.cginc b/fog.cginc
index 6955de8..7f34795 100644
--- a/fog.cginc
+++ b/fog.cginc
@@ -39,11 +39,8 @@ FogResult raymarched_fog(v2f i, FogParams p)
const float ro_epsilon = 1E-3;
ro += rd * ro_epsilon;
- // TODO maybe we can accelerate this?
- float perspective_divide = 1.0f / i.pos.w;
- float perspective_factor = length(i.eyeVec.xyz * perspective_divide);
-
- const float2 screen_uv = (i.pos.xy + 0.5) / _ScreenParams.xy;
+ float4 clipPos = UnityObjectToClipPos(i.objPos);
+ float2 screen_uv = ComputeScreenPos(clipPos) / clipPos.w;
float zDepthFromMap = SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, screen_uv);
float linearZ =