summaryrefslogtreecommitdiffstats
path: root/fog.cginc
diff options
context:
space:
mode:
authoryum <yum.food.vr@gmail.com>2024-10-15 16:02:34 -0700
committeryum <yum.food.vr@gmail.com>2024-10-15 16:02:34 -0700
commit28d5901b122e443e01f37acb021cdc22a7392ae7 (patch)
tree961c0dbf637c4f6bc677515f4fc56e3230043d1a /fog.cginc
parent1ff4045914b603c16f3e1b3339e1080b152825fb (diff)
Mitigate fog noise in desktop mode
Diffstat (limited to 'fog.cginc')
-rw-r--r--fog.cginc11
1 files changed, 10 insertions, 1 deletions
diff --git a/fog.cginc b/fog.cginc
index 8f81e09..3b41d7e 100644
--- a/fog.cginc
+++ b/fog.cginc
@@ -156,7 +156,16 @@ Fog00PBR getFog00(v2f i) {
// is visible with no factor.
float step_size = rcp(_Gimmick_Fog_00_Density) * _Gimmick_Fog_00_Step_Size_Factor;
step_size = clamp(step_size, 1E-2, 10);
- float dither = rand2(screen_uv*10) * step_size * _Gimmick_Fog_00_Ray_Origin_Randomization;
+ int2 screen_uv_round = floor(screen_uv * _ScreenParams.xy);
+ float dither_seed = rand2(float2(screen_uv_round.x, screen_uv_round.y)*.001);
+ // Smoothly vary over time. Use a triangle wave since it distributes points
+ // evenly. A sin wave would bunch points up at boundaries.
+ #if 1
+ dither_seed = frac(dither_seed + _Time[0]*2);
+ dither_seed *= 2; // Map onto [0, 2]
+ dither_seed = abs(dither_seed - 1); // Shape into triangle wave ranging from 0 to 1
+ #endif
+ float dither = dither_seed * step_size * _Gimmick_Fog_00_Ray_Origin_Randomization;
ro += rd * (0.1 + dither);
float world_pos_depth_hit_l = length(world_pos_depth_hit - ro);