The RayDistance shader has a variety of uses. For example, it can be used to generate fog by applying it to the Foreground material In the same way, it can be used for underwater effects. For under water you would use it to create fog (limiting visibility) and to desaturate the color with distance. The basic idea of the shader is that it calculates a number to output based on a minimum distance and a maximum distance. And since the minimum and maximum can be animated (or set as objects, which can be animated), it gives a lot possibilities. Note: The only thing that will appear in the object pulldowns are the camera and null objects.
You can either enter a distance in the numeric fields (and even animate the number) or use the object pulldowns. The object pulldowns override the numerics, so you only need one or the other (though you can mix and match, using a numeric for one and an object for the other).
The Minimum Distance (or object) is where the start of the effect is. (0% of the effect.)
The Maximum Distance (or objetct) is where the maximum level of the effect is. (100% of the effect.)
There are three sample scenes in the messiah_content\Scenes\Samples folder. Here is what each of them are, and what they show:
RayDistance_Sample_SimpleFog.mpj - This shows how to use RayDistance to create a quick, easy to adjust fog. The Depth output of RayDistance is applied to the Opacity of the Foreground surface. As you can guess, what this does is make the foreground more or less opaque, depending on the distance (depth) from the camera.
RayDistance_Sample_CrazyFog.mpj - This is similar to the above, but it uses a Gradient to control the color and opacity of the fog. (The Alpha channel of the Gradient markers controls the opacity.) The Alpha channel on the last marker on the Gradient is set to 50% so you can see through the "fog" at its maximum depth. The background color is bright red to make it more obvious what's going on with the Alpha setting of the fog.
RayDistance_Sample_UnderWater.mpj - Not only does visibility under water drop off quickly (in a short distance), but so does color. This scene shows how to use RayDistance, a Gradient, and ColorCorrection to achieve this effect. The Depth channel of RayDistance goes into the Gradient, which converts the data to a range that then goes into the Saturation input of the ColorCorrection node. The Depth channel also goes directly into the Color, Contrast and Pinch inputs of ColorCorrection. Those control the thickness of the fog (visibility). Finally, the output of ColorCorrection goes into the Color input on the Foreground material.
|Converted from CHM to HTML with chm2web Pro 2.82 (unicode)|