imageworks/OpenShadingLanguage — pull request #166 by lgritz (2012-10-09 18:55:17+00:00)
Title: rayroughness()

This adds an OSL function rayroughness() (and from the point of view of a renderer, a new ShaderGlobals field with the same name, that the renderer is expected to set).

The exact meaning is purposely not well defined, and may be renderer-dependent, but the gist is that it represents a metric of how diffusely the scattering has been between the camera and the point being shaded -- 0 means a direct view or only coherent mirror-like reflection or refraction, 1 means it's totally incoherent and diffuse.

The gist is to allow shaders to take different kinds of shortcuts if they know they are shading points that won't be viewed coherently. For example, blurring texture lookups or leaving off high-detailed noise functions. The accumulated roughness is, in theory, a better way to based these things than simply the ray type (for example, a ray with "glossy" in its history may still have a very low roughness on that glossy scatter, and so it would be unwise for it to start losing noise octaves).