Dirtmap


Shader Type: Texture
Output: Color (RGB) value
Performs spatial sampling of occlusion, to generate a distance-based dirt or ambient occlusion effect.

Basics


Output bent normals? Normally, the Dirtmap will directly output the occlusion information so you can easily use it in the render tree. If you enable this checkbox, it will instead generate so called "bent normals". A bent normal is a vector that points in the average unoccluded direction above a point. If you have a completely unoccluded surface, this will be equal to the surface normal (if you use enough samples), or the basis vector if it is in use.

The R, G and B components contain the X, Y and Z values of the vector (normalized, in the [-1, 1] range), while the Alpha component contains the amount of occlusion that occured.

You can easily use this mode for e.g. sampling the environment map with another plugin, or outputting the bent normals to disk.
Probe geometry? If ON (default), the shader will shoot out rays to gather occlusion information. You normally will only want to turn this off when making a separate enironment pass. There, however, you can turn it off (and "Probe environment" on) to get pure environment information, like in this example:



From left to right:
  • Ambient pass: Probe environment ON, probe geometry OFF.
  • Occlusion pass: Probe environment OFF, probe geometry ON.
  • Final: Simple multiply composite of the two passes.
Probe environment? Toggles if the base/dirt colors are output directly, or if they get multiplied with the environment color first. To get any visible results, you should first apply some kind of color or texture to the environment slot of the material or current render pass. If you now set the base color to white and the dirt color to black, and connect the dirtmap output to the ambient input of a surface shader node, you get a perfect ambient occlusion effect. Relatively open areas of the mesh, that aren't occluded, return the unmodified environment color, and "dirty" areas return black, therefore pulling ambience in those areas towards zero.
Here is an example scene, to illustrate the effect:



From left to right:
  • Without any dirtmap
  • With standard dirtmap, white base with black dirt
  • The same dirtmap, with "Multiply by Environment" checked
As you can see, the "Probe environment" can create an ambient occlusion effect (the environment map was not shown in the background). You can use it to quickly get a skylight effect without the need of final gathering.
Invisible to secondary illumination? If ON (default), the dirtmap will not do any sampling when hit by any secondary illumination rays, no matter if GI or Caustic photons, or Final Gather rays. Use this to greatly speed up Final Gathering in scenes where you are using the dirtmap. The visual difference is normally not noticable, the speed difference can be huge.


Color


Base Color Defines the base material color the dirt or occlusion effect gets applied to. You can, for example, map the output of a shading node into this input, to overlay a material with another color.
Dirt Color Defines the dirt color that gets overlaid on the base color.


Sampling


Spread The spread parameter sets the half-angle of the opening above the point that gets sampled. A value of 90 produces a hemisphere, while 0 results in completely sharp normal-reflections, and 180 samples a complete sphere (with about 50% of the samples normally hitting the mesh directly below the sample point).
Samples Sets the number of samples that get cast for each point. If you set this to 0, you effectively disable the Dirtmap, always returning the base color.


Attenuation


Near Sets the minimum range of a ray. For each ray that gets cast, if the distance to the first hit is below the Near Falloff distance, full dirt color gets applied.
Far Sets the maximum range of a ray. Every ray that doesn't hit an obstacle in less than the distance defined by Far Falloff causes full base color to be applied.
Gain This controls the falloff that gets applied if a ray hits an object in a distance between the near and far falloff. At 1, a linear falloff gets applied, while at 0.5 it is square (effectively reducing dirt density), and at 2 it is square-root (effectively increasing dirt density). Note that this gets applied per ray, and therefore might not yield the amount of change you want. To dramatically increase the dirt strength, either lower the dirt color to a value with negative luminance, or use a color correct node with negative gamma to modify the output color.


Direction


Basis Vector This lets you specify an arbitrary vector that gets used to send samples in. This serves as the base for the cone that samples get shot in. The angle of the opening of that cone can be modified via the spread parameter.
Take note that this vector is in internal space, and therefore might not immediately yield the results you expect. Connect a Vector_coordinate_converter node to the basis input to be able to specify the coordinate system of this vector.
Also take note that by default, the dirtmap uses the interpolated surface normals for computing it's effect. This is the same as putting a Vector_state node with "Normal Vector" into the basis vector slot.
Blend This controls the amount of mixing that occurs between the standard vector that gets used (the interpolated surface normal), and the basis vector. At 0, the surface normal is used, and at 1, only the basis vector gets used.



Render Tree Usage
The dirtmap shader is very versatile, and can be used for a variety of effects, like dirt, a quick fake skylight approach, or even faking sub surface scattering. The limit is your imagination.