This simple fog shader operates on the result color provided by a previously running shader (typically from a material shader at the far end of the ray) and fades it toward a fog color based on ray length. Fading occurs within a maximum distance, otherwise the fog color is considered solid. The fog color is allowed to have an alpha value which limits the maximum opacity of the fog. Attaching the fog color to a texture shader, for example, creates transparent volume effects such as smoke or fire (set max to 0 to avoid fading).
Except where otherwise noted, this work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License