Is a surface-based Atmospheric Perspective node possible?

I know very little about shading languages, so please forgive any apparent ignorance. I have been struggling with Volume Scatter (VS) in a vain attempt to produce a small amount of atmospheric perspective (aka haze) in a scene with wide expanses of open air between the principal objects in the scene. VS seems much too heavy-handed a solution and introduces swarms of fireflies.

It occurred to me that it might be possible to add a slight haze effect to surface shaders, as in many cases that is the only place the effect is noticeable, generally with a reduction in saturation, a hue shift based on the type of haze or time of day (for example), and an overall flattening of contrast. While these effects could likely be produced using existing nodes, I thought it more efficient to have a single node with a set of standard parameters, and geared to also take into account changes in distance between an object with this shader & the active camera, so it can automatically fade out its effect when the camera nears the subject.

Does this sound like something OSL might be able to tackle?

yes this is possible. I’ve used this for landscapes on occasion. Adding a slight lightening and bluing using distance as a factor to mix it in the material. I just used ordinary nodes. If you use OSL you would need to feed it with where you want the start position ( for distance) to be calculated from I suspect. I only occasionally use OSL so can’t comment much on that approach though.

Yep, that’s the factor that makes using standard nodes more difficult. For still renderings they more than suffice, but for animation, it would require using drivers that calculate camera-to-subject distance on the fly so the effect can be modulated as the camera moves. My thought is that incorporating this behavior as a part of a node’s default behavior would be more efficient.

The effects of atmospheric perspective also apply to the cumulative material result rather than a few channels alone (“channels” meaning in this case such nodes as Diffuse, Glossy, SSS, etc.). So rather than tweaking each of these individually (and having to use drivers tailored for each), a consolidated “Haze” FX node could be applied farther downstream in the material node tree, as a final node perhaps, or even as a new channel in the Material Output node, adjacent to Surface, Volume and Displacement. This latter concept would allow for using a separate node tree, and possibly new nodes to characterize the Haze effect (e.g., Dust, Smoke, Smog), to better define the overall look of the result.

Just speculating, of course, but it seems a useful idea to pursue since Volume Scattering by itself doesn’t seem to fill the bill.

I will need to look back in my blends and see exactly what a I used. I think I just used a distance from camera calculation which would of course account for the camera moving. I’m fairly sure though that I only applied the correction to color and didn’t use it to alter for example bump strength etc. Linking a range of factors to “haze” would be interesting. You have OSL skills?

None, though I have done a fair amount of scripting in various languages. But I’m not really fond of the idea of taking on another language at the moment, which is why I posted here, hoping to lure an accomplished OSL writer with a challenge :wink:

If we keep posting plaintiffly there’s bound to be one who comes along and who feels sorry for lost puppies, kittens and forlorn CG artists.

You could get a basic effect without OSL using the ray length output of a light path node (via one or more math nodes for control) to drive the saturation of the shader colour.

Here’s a regular node set up that uses the camera as a start point so it updates automatically as you move the camera. You can modify any number of things this way. My example modifies both color and glossiness.

None, though I have done a fair amount of scripting in various languages.