diff options
| author | yum <yum.food.vr@gmail.com> | 2024-10-15 16:02:34 -0700 |
|---|---|---|
| committer | yum <yum.food.vr@gmail.com> | 2024-10-15 16:02:34 -0700 |
| commit | 28d5901b122e443e01f37acb021cdc22a7392ae7 (patch) | |
| tree | 961c0dbf637c4f6bc677515f4fc56e3230043d1a | |
| parent | 1ff4045914b603c16f3e1b3339e1080b152825fb (diff) | |
Mitigate fog noise in desktop mode
| -rw-r--r-- | fog.cginc | 11 | ||||
| -rw-r--r-- | interpolators.cginc | 2 | ||||
| -rw-r--r-- | tooner_lighting.cginc | 4 |
3 files changed, 14 insertions, 3 deletions
@@ -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); diff --git a/interpolators.cginc b/interpolators.cginc index 57b78e4..43e69e9 100644 --- a/interpolators.cginc +++ b/interpolators.cginc @@ -84,7 +84,9 @@ struct v2f float2 uv7 : TEXCOORD7; #endif float2 fogCoord: TEXCOORD8; +#if !defined(LIGHTMAP_ON) unityShadowCoord4 _ShadowCoord : TEXCOORD9; +#endif float3 normal : TEXCOORD10; float4 tangent : TEXCOORD11; float3 worldPos : TEXCOORD12; diff --git a/tooner_lighting.cginc b/tooner_lighting.cginc index 093a5af..f771f4a 100644 --- a/tooner_lighting.cginc +++ b/tooner_lighting.cginc @@ -174,7 +174,7 @@ v2f vert(appdata v) o.tangent = float4(UnityObjectToWorldDir(v.tangent.xyz), v.tangent.w); o.uv0 = v.uv0; o.uv1 = v.uv1; -#if defined(_WORLD_INTERPOLATORS) +#if defined(LIGHTMAP_ON) o.uv2 = v.uv2 * unity_LightmapST.xy + unity_LightmapST.zw; UNITY_TRANSFER_LIGHTING(o, v.uv2); #else @@ -547,7 +547,7 @@ float2 get_uv_by_channel(v2f i, uint which_channel) { case 1: return i.uv1; break; -#if !defined(_WORLD_INTERPOLATORS) +#if !defined(LIGHTMAP_ON) case 2: return i.uv2; break; |
