Corona Distance Map
Corona Distance Map lets you create “smart” materials that know how far away they are from objects in the scene. Use this to add waves around a coastline, wear-and-tear where objects meet, dirt and noise under window sills, and more.
How does it work?
The Corona Distance map applies different colors to a material based on the distance from one object to another. These colors can be then mapped to various material or object properties such as opacity, displacement, or scattering distribution, or can be used as masks, just as any other map.
The Corona Distance map can be used with both 2D textures (such as bitmaps or procedural maps on the object surface) and 3D volumes (such as OpenVDB grids loaded using the CoronaVolumeGrid, or objects using the Corona Volume material).
How is it any different from Corona AO map?
There are some major differences:
- Corona Distance map cannot be used within a single object.
CoronaAO map can be used to color different parts of a single object, or multiple objects, based on their distance from each other (convex or concave areas). The CoronaDistance map can only be used based on the distance between two or more different objects.
- CoronaAO is raytraced, so it is computed only during the actual rendering.
This means that the CoronaAO map cannot be used, for example, as a distribution map to scatter instances using CoronaScatter, as a displacement map, or as a bump map. CoronaDistance can be used in such cases, and it will update in real time, even in the viewport.
- The quality of the CoronaAO map will improve progressively during rendering, so it will first appear noisy, and will then gradually become noise-free with each subsequent render pass. CoronaDistance is computed in one go, and will immediately render noise-free.
The Corona Distance map is extremely versatile, and can be used in various cases depending on the needs. Here are only a few examples ideas, that can be developed further:
Wear and tear on objects which are close to each other:
A Noise map is used to vary the distance scale, producing the "dirt" texture. An Output map is used to increase the contrast of the CoronaDistance map.
Foam close to the shore:
Only a single CoronaDistance map is used to color the water surface object based on the distance from the shore.
Creating 3D waves around objects in sand or water:
The CoronaDistance map is plugged into the "Source Map" slot of a Gradient Ramp map. This way the "waves" crated using the Gradient Ramp will create circular shapes around the object.
Force field which opens when an objects gets close to it:
In this case the opacity of the forcefield material is controlled by the CoronaDistance map, which becomes black when the selected object is close to it.
Render-time booleans with very complex shapes:
This can be used to render complex boolean shapes without any kind of artifacts. Short tutorial on setting up a similar scene: [Corona Renderer Forum]
Volumetric fog close to the ground:
The displaced ground plane is contained within a box. That box has a CoronaVolume material applied with "inside volume" mode enabled. The CoronaDistance map has the ground plane selected as the "distance from" object, and is then plugged into the Absorption slot of the CoronaVolume material. This means that the volume will be dense closer to the ground object (black color), and thinner farther away from it (white color), until it becomes completely transparent. Additionally, a noise map is plugged into the Distance Scale of the CoronaDistance material to vary the density of the fog.
"Laser" cuts through volumes:
In this example there is a CoronaVolumeGrid object in the scene, with an OpenVDB file loaded. A similar method is used here as in the "booleans" example above - there is an invisible box object cutting through the volume. CoronaDistance map is then used in the Absorption slot of the CoronaVolumeGrid to define which areas should be transparent (white) and which should be solid (black). Additionally, the CoronaVolumeGrid's Emission is also mapped with a CoronaDistance map - so the it emits light close to the area where the invisible box intersects with the volume.