diff options
| author | yum <yum.food.vr@gmail.com> | 2025-06-13 23:38:52 -0700 |
|---|---|---|
| committer | yum <yum.food.vr@gmail.com> | 2025-06-13 23:38:55 -0700 |
| commit | 60e1e2010ab5eaa01dfd00c30f91384f95a78aa2 (patch) | |
| tree | fd609dd3aa90937cd3f8f88d467fc3fdc167d0e3 /fog.cginc | |
| parent | 86ff834cec5a75f6e0a2636de03cf5f79050d7ae (diff) | |
Fix how fog dithering would cause overshoot
Diffstat (limited to 'fog.cginc')
| -rw-r--r-- | fog.cginc | 11 |
1 files changed, 6 insertions, 5 deletions
@@ -127,12 +127,13 @@ FogResult raymarched_fog(v2f i, FogParams p) [loop] for (uint ii = 0; ii < p.steps && traveled < max_dist; ++ii) { - // Clamp step size to avoid missing dense features - float current_step = min(step_size, 2.0 * p.mean_free_path); - // Apply dithering to this step - float dithered_step = current_step * (1.0 - dither + dither * 2.0); - + float cur_dither = frac(dither + (ii + 1) * PHI); + float dithered_step = step_size * (cur_dither + 0.5); + float remaining = max_dist - traveled; + remaining = max(remaining, 0.1); + dithered_step = min(dithered_step, remaining); + // Advance position pp += dithered_step * rd; traveled += dithered_step; |
