4 comments

  • Ono-Sendai1 hour ago
    Coincidentally I just posted a blog post on fog rendering, in particular with exponential height fog, yesterday: <a href="https:&#x2F;&#x2F;forwardscattering.org&#x2F;post&#x2F;72" rel="nofollow">https:&#x2F;&#x2F;forwardscattering.org&#x2F;post&#x2F;72</a>
  • reactordev3 hours ago
    Yesssssss…<p>However, I’d push this a little further with light reflectance and scattering. Fog does some weird things to light when it’s dense. You mention this towards the end but even just a Rayleigh calc should be enough.<p>A goal of mine, maybe this year, is to get back into volumetric clouds and fog using SDF with wgpu but, the economy.<p>But something like…<p><pre><code> &#x2F;&#x2F; Assume: &#x2F;&#x2F; vec3 fogColor; &#x2F;&#x2F; Base fog color &#x2F;&#x2F; float density; &#x2F;&#x2F; Fog density at point &#x2F;&#x2F; vec3 lightDir; &#x2F;&#x2F; Direction from point to light &#x2F;&#x2F; vec3 viewDir; &#x2F;&#x2F; Direction from camera to point &#x2F;&#x2F; vec3 sunColor; &#x2F;&#x2F; RGB color of light &#x2F;&#x2F; Compute angle between light and view float cosTheta = dot(normalize(lightDir), normalize(viewDir)); &#x2F;&#x2F; Simple Rayleigh-ish phase function (forward&#x2F;backward scattering) float phase = 0.75 * (1.0 + cosTheta * cosTheta); &#x2F;&#x2F; Wavelength-dependent scattering (approx Rayleigh) vec3 sigma = vec3(0.5, 0.8, 1.0); &#x2F;&#x2F; R,G,B scattering coeffs &#x2F;&#x2F; Fog contribution vec3 fogContribution = density * phase * sigma * sunColor; &#x2F;&#x2F; Blend with scene color (sceneColor comes from existing render) vec3 finalColor = mix(sceneColor, sceneColor + fogContribution, density); </code></pre> Take that with a grain of salt but the idea is to blend the final color with a scattering coefficient for when light is trying to shine through.
  • kqr7 hours ago
    If, by chance, there are any fans of <i>Morrowind</i> here, there are shaders for the OpenMW source port that add volumetric fog and the game becomes absolutely stunning with them. I&#x27;m sure that was what the original developers intended but couldn&#x27;t achieve with the computers of the age.<p>Volumetric fog has a special place in my heart.
    • maximus_prime7 hours ago
      Shout-out to his incredible mod adds volumetric fog to GTA 4: <a href="https:&#x2F;&#x2F;fusionfix.io&#x2F;iv" rel="nofollow">https:&#x2F;&#x2F;fusionfix.io&#x2F;iv</a>
  • bee_rider7 hours ago
    This is pretty cool, and also seems pretty accessible for a “graphics thing.” Just a little calculus.<p>It would be kind of neat to have an example of a physical situation that produces each of the example functions (although I’m sure that isn’t always possible).<p>Can the effect of multiple fog emitters reasonably be modeled as the sum of their outputs? I guess for high densities, probably not (eventually the air will get saturated), but for low densities, probably yes…
    • Ono-Sendai58 minutes ago
      For simple models (constant incoming radiance), you can indeed just add the optical depths from the different fog &#x27;layers&#x27;. (90% sure but the maths is easy to check anyway, see <a href="https:&#x2F;&#x2F;forwardscattering.org&#x2F;post&#x2F;72" rel="nofollow">https:&#x2F;&#x2F;forwardscattering.org&#x2F;post&#x2F;72</a>)