Use the V-Ray Distance texture in SketchUp to set colours based on distance from selected objects.
Overview
VRayDistanceTex is a procedural texture specific to V-Ray. It returns a colour based on a point's distance from the objects in a selection list.


Where to find it
||V-Ray Asset Editor|| > Textures (right-click) > Distance
||V-Ray Asset Editor|| > Create Asset (left-click) > Textures > Distance
Parameters
Distance specifies a texture that multiplies the distance value. Within the radius, black areas of the distance map shade points with Far Color. White areas shade them with Near Color. See the Distance Texture example below.
Far Color sets the colour for points farther than the Distance value from the listed objects. See the Far Color example below.
Near Color sets the colour for points at the edges of the listed objects. See the Near Color example below.
Add Objects adds the objects you have already selected in the scene.

Example: Distance with a Noise texture
In this example, the Fur geometry uses a Distance texture as its Density map. The Distance texture has a Distance value of 60 and uses a Noise map. Rocks and grass Assets are added to the Distance texture's Add Objects list. Fur Density is zero within a radius of 60 units from these objects. Outside this radius, Density uses the value set by Fur Count. The Noise texture multiplies the Distance value. Within the radius of 60 units, black points in the Noise texture give zero Fur Density, while white points give normal Density. This varies the grass density for a more natural appearance.


Example: Far Color

Far Color
= R1G1B1

Far Color
= R04G04B04

Far Color
= R06G06B06

Far Color
= Noise

Far Color
= R08G08B08
Example: Near Color

Near Color
= R0G0B0

Near Color
= R02G02B02

Near Color
= R04G04B04

Near Color
= R06G06B06

Near Color
= Noise
Inside Separate
Inside Separate replaces Near Color with Inside Color for points inside the specified geometry when enabled.
Inside Color sets the colour for points just inside the listed objects.
Inside Solid applies Inside Color to all points inside the specified geometry when enabled. The colours do not blend.

See the Inside Separate example below.
Example: Inside Separate
In this example, the stones are hidden by adding Raytrace Properties Attribute and turning off all visibility options. When you use a Noise map for either Inside or Outside colours, the preview swatch does not show the final Distance texture or any noise. In these cases, only the Noise texture appears in the render.

Color = R0G0B0

Color = R04G04B04

Color = R08G08B08

Color = R0G0B0; Inside Solid = On

Color = R1G1B1; Inside Solid = On

Color = Noise Texture; Inside Solid = On
Outside Separate
Outside Separate replaces Near Color with Outside Color for points outside the specified geometry when enabled.
Outside Color sets the colour for points outside the listed objects.
Outside Solid applies Outside Color to all points outside the specified geometry when enabled. The colours do not blend.
See the Outside Separate example below.

Example: Outside Separate

Color = R0G0B0

Color = R04G04B04

Color = R08G08B08

Color = R0G0B0; Outside Solid = On

Color = R1G1B1; Outside Solid = On

Color = Noise Texture; Outside Solid = On
Example: Refine texture placement with the Distance texture
Watch the example on YouTube.
Example: Displacement
This example shows how to use geometry to create a Distance map for Displacement. The pot has a Displacement geometry tool. It uses the Distance texture created from the intersection as its Displacement map.

Displacement:
Off

Distance:
Geometry

Distance Displacement
,
White Ceramic:
On
Example: Fur
The Density image shows how the Distance texture controls grass density. Inside Separate and Inside solid are set to On, and Inside Separate uses black. The final image shows how the Distance texture controls grass density and length, with a map connected to Length.

Fur:
Off

Distance:
Off

Distance:
Density

Distance Inside Separate:
Density

Distance Inside Separate:
Density Length