Corona Distance Shader - C4D
Corona Distance Shader 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 Shader applies different colors to a material based on the distance from one object to another. These colors can then be mapped to various material or object properties such as opacity, displacement, or scattering distribution, or can be used as masks, just like any other shader.
The Corona Distance Shader can be used with 2D textures (such as bitmaps or procedural shaders on the object's surface) and 3D volumes (such as objects using the Corona Volume material).
How is it any different from Corona AO Shader?
There are some major differences:
- Corona Distance Shader cannot be used within a single object.
Corona AO Shader can be used to colorize different parts of a single object or multiple objects based on their distance from each other (convex or concave areas). The Corona Distance Shader can only be used based on the distance between two or more different objects.
- Corona AO Shader is raytraced, so it is computed only during the actual rendering.
This means that the Corona AO Shader cannot be used, for example, as a distribution map to scatter instances using a Cloner object, as a displacement map, or as a bump map. The Corona Distance Shader can be used in such cases, and it will update in real-time, even in the viewport.
- The quality of the Corona AO Shader will improve progressively during rendering, so it will first appear noisy and will then gradually become noise-free with each subsequent render pass. The Corona Distance Shader is computed in one go and will immediately render noise-free.
The Corona Distance Shader is extremely versatile and can be used in various cases, depending on the needs. Here are only a few example 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 "rust" effect. In this case, the Corona Distance Shader is feeding the Opacity channel.
The material tag is stacked over the base material.
The material Rust_A measures the distance from the sides of the cylinder that acts as the Distance Object through the Corona Distance Shader. The material Rust_B measures the distance from the floor and feeds that info to the Corona Distance Shader.
Foam close to the shore:
A Noise shader is used to vary the distance scale, producing the "variation" at the edge of the foam. In this case, the Corona Distance Shader is feeding the Opacity channel.
The material tag is stacked over the base material. The foam material measures the distance from the landscape objects that act as the Distance Objects and feeds that info to the Corona Distance Shader.
Cutting-out objects with Corona Volume material applied:
In this case, it's a "boolean-like" example; there is an invisible object (Corona Renderer's logo) cutting through the volume. The Corona Distance Shader is used in the Absorption slot of the Corona Volume material to define the areas that should be transparent and those that should be solid.
The material tag is applied to the cloud object, and then the Corona Distance shader measures the distance between the Corona Renderer logo and the cloud, and it uses that info to cut out the cloud object.
Using the Distance shader to affect Cloner objects.
Objects and setup:
You can use the Corona Distance Shader to affect the result of a cloner.
The setup of the Corona Distance Shader is pretty straightforward.
Use a Shader Effector to affect the Cloner, then add the Corona Distance Shader using the
Custom Shader channel and modify the effector parameters.
Finally, add the objects to the Corona Distance Shader.