Yesssssss…
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.
A goal of mine, maybe this year, is to get back into volumetric clouds and fog using SDF with wgpu but, the economy.
But something like…
// Assume:
// vec3 fogColor; // Base fog color
// float density; // Fog density at point
// vec3 lightDir; // Direction from point to light
// vec3 viewDir; // Direction from camera to point
// vec3 sunColor; // RGB color of light
// Compute angle between light and view
float cosTheta = dot(normalize(lightDir), normalize(viewDir));
// Simple Rayleigh-ish phase function (forward/backward scattering)
float phase = 0.75 * (1.0 + cosTheta * cosTheta);
// Wavelength-dependent scattering (approx Rayleigh)
vec3 sigma = vec3(0.5, 0.8, 1.0); // R,G,B scattering coeffs
// Fog contribution
vec3 fogContribution = density * phase * sigma * sunColor;
// Blend with scene color (sceneColor comes from existing render)
vec3 finalColor = mix(sceneColor, sceneColor + fogContribution, density);
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.