Glow with Diffusion Module

Its the inverse square law for how light from a source falls of relative to the distance to your lens

But that’s completely unrelated… Glow is a 2D phenomenon happening in the (x, y) plane of the image. Distance between source and lens is along the z dimension, thus the inverse square law applies on 1D intensities in the direction orthogonal to the image plane. All pixels of the image are affected the same by this effect, it has nothing to do with how they will bleed on each other.

Well, real-life glow is a 3D scattering process (think street light in fog). So the exact effect depends on the size of the scattering particles, the observation angle and the frequency of the light (very diluted milk has a blueish tint when the light is behind it, a yellowish tint when the light is in front).
Another natural occuring scattering effect is the halo that can appear around the moon.

I had to use scattering once (some analysis techniques use it to determine molecular mass, or rather molecular size), and on looking into the theory behind it, I decided that the exact mathematical details could stay with the specialists. It was certainly not an inverse square law…

1 Like

Interesting image. I am not convinced by any of the attempts at it: keep trying!

As with most things in life, multiple things are affecting the light and causing it to look this way. Of course, there are dominant contributions and patterns. That is what we should keep in mind when editing…

Notice that the diffusion in itself is already producing an exponential fall-off.

Yeah, and that’s great. The Problem is the masking process and the fact that we don’t process the glow isolated which results in the background mixing in. Combining the glow with the background should be done by compositing the layer back (adding).

Ok, you have no idea what you are talking about.

Maybe not about physics, but I most likely know more about compositing than you do. So would you mind calming down? I work as a professional in the vfx industry. We do care more about the look and not too much about physics.

really have their way of triggering me

Do you even read what I’m writing? What I call a hack is masking. I really like the diffusion model. I wouldn’t have started this thread otherwise.

The fact that you created the parameter for luminance masking clearly shows that you are aware that post masking is not the solution here. But at the moment luminance masking is just producing a hard mask which is not really useful.

No need to be triggered. You did great work with the diffusion model and it is potentially perfect for creating an awesome glow effect. The only problem is the masking part. Which can be fixed quite easily. All that it needs is to make all pixels black that are below the luminance threshold. That’s our mask then, because adding back will not change anything. Then diffusion can do its magic operating on all pixels including the black once to get a smooth falloff. Finally we can add the result back to the original image. Perfect falloff, smooth mixing with the background, no unwanted luminance shift.

I think you’re looking for something like this, where you have a gentle glow emanating from the source. I tried drawing a mask around the brightest part of the flame and then applied some pretty agressive feathering to gently taper the effect off. Then I darkened the room with an inverse of that raster mask to strengthen the effect:

PC060579.ORF.xmp (15.4 KB)

1 Like

The luminance masking in diffuse and sharpen is meant to reconstruct highlights and acts at the input of the module, I was talking about masking the output of D&S with the general darktable’s masking feature. It’s a completely different use case where we propagate gradients into damaged areas.

Yeah but if the particles size is small enough and the concentration is high enough, scattering tends to diffusion, no ? Given that we already have some sort of wavelengths binning when going from light spectrum to RGB, that should be close enough ?

Otherwise, we go full Manuka and render a scattering process in spectral (poke @hanatos).

I think you’re right about the diffusion approximation, but, like I said, I found the math daunting enough that I decided to skip the details (mainly due to the wavelength-depency of the scattering angle). I do know that the size of the particles relative to the wavelength plays an important role. And in extreme cases you can end up with things like rainbows (refraction in droplets) or rings around the moon (reflection/refraction from clouds).

But I think what’s relevant here is that scattering/glow is not just a simple inverse square law, and that there is perhaps not one right way to model the appearance in an image.

Also, if there’s enough matter in the air to make a glow appear around the flame, wouldn’t you see an effect on the overall sharpness, especially of the glass object? Which would perhaps also receive a bit mire diffuse light (as the apparent light source becomes larger)?

1 Like

hehe yes only that this kind of volume isn’t really super fast even if you do it in 3d rendering…

you’d usually approximate mie scattering with some multi-lobe henyey greenstein and assume that the orientation of crystals (if any) is random enough to resolve rainbows into blur.

interestingly the solutions are often distinctly non-gaussian even after very many bounces. more like sum of exponentials if you have to approximate it closed form.

for the kind of glow you guys are talking about you’d probably need very forward scattering phase functions (mean cosine far > 0.9) and low order scattering (not many bounces).

oh yes. i really like this subtle softness (photographing over some distance through moist air/sea).

for fixed distance and known scattering kernel you can totally approximate the effect in screen space if you want. neglecting all interesting occlusion on the way. also deep screen space operations with per-pixel varying blur kernel sizes take some substantial processing time too. i guess i’m saying you might as well do the full 3d render… if you want more than a cheap bloom anyways.

1 Like