in this lesson we will demonstrate using
the very distance texture while
rendering on GPU and the creative
possibilities this gives us for a quick
overview the erase distance text creates
a gradient over the surface of an object
mapped by the position of another object
this allows you to set a different color
based on a points distance to an object
or objects specified in a selection list
okay let's start by opening up the v-ray
settings and make sure we're on v-ray
GPU next then let's start the IPR and
take a look at the scene here
I'd like to create more of a story for
this image by adding a little bit of
spilled coffee to it let's see how we
can do that with the help of the v-ray
distanced X if we open the material
editor you'll see that we already have a
material set for our paper but it is
just a mid gray color to get things
going first we need to create a v-ray
distance text by right-clicking in the
material editor view and selecting Maps
v-ray v-ray distance techs let's plug it
into the diffuse slot for the papers
material at first there isn't much of a
change this is because we don't have an
object selected to interact with the
distance techs yet let's go to the v-ray
distance text objects click Add and
select the mug immediately you'll see
that we get a black to white gradient
starting from the mug the NIR color
represents points that are right at the
edges of the mug while the far color is
for points that are at a distance
greater than the distance parameter
radius from the mug all right since
we're going to use the distance text as
a masker on the mug let's swap the black
and white values of the far color in
near color by dragging the far color
into the near color swatch and selecting
swap now you'll see that the gradient
starts with white and transitions to
black as it gets further away from the
mug then we can control the size of the
radius using the distance parameter
lower values will show less of the NIR
color and higher values will show more
of the NIR color okay now to create the
shape of coffee stains we will need to
break the shape of the distance text the
easiest way to do this is to simply map
the distance parameter
I have prepared a noise texture that
suits this scenario quite nicely let's
take it and plug it into the distance
texture slot as an instance and you'll
see that we immediately get a much more
organic shape around the mug in our
scene however we still need some way to
control the transition from black to
white one method is to use a gradient
ramp so I've prepared a custom gradient
for this purpose the important thing to
note here is that the gradient type
should be set to mapped then we should
connect the v-ray distance text as an
instance into the source map slot of the
gradient ramp texture now if we plug the
gradient ramp texture into the diffuse
slot of the paper material we'll see
that we have control over the gradient
transition of the near to far color
parameters of the viewer a distance text
okay that looks good so far next to
achieve the final result for this image
let's take a look at the composite map
that I have set up here in advance on
layer 1 we have the base texture for the
paper and on layer 2 you'll see there is
a brownish color with a slight amount of
noise to create a subtle variation in
its color and it's blending mode is set
to multiply layer 2 also has a mask
which is the gradient ramp texture that
we mapped a moment ago with the v-ray
distanced X so that layer 2's color only
appears where the gradient ramp
indicates it should together these
layers will help to give the paper both
a base texture and coffee stain thanks
to the gradient ramp mask with a
distance text now the black Far color of
the distance text is filled with layer 1
meanwhile the white near color is filled
in by the brown coffee stain color and
layer 2 in the transition between these
layers is controlled by the gradient
ramp ok
now let's plug in the composite texture
into the diffuse slot of our paper
material and observe how this changes
the material now you'll see that we're
getting a nice-looking coffee stain and
more details on the paper itself thanks
to the layers in the composite texture
another useful aspect of the v-ray
distance text is that even though we
have mapped the distance we could still
easily control the spread of layer twos
texture stained by tweaking the distance
parameter
let's try a few values once more going
from low to high just as we saw earlier
the low values will give us a subtle
effect while higher values spread the
coffee stain all over the entire piece
of paper feel free to test a few values
on your own until you find a look that
you're happy with I think I'm gonna
stick with the value of 10 another great
thing about the distance text is that it
is fully procedural based on the objects
you've added to its objects drop-down
this means that if we move any objects
that we added to the list in this case
the coffee mug the texture stain updates
immediately based on the new location of
the mug moving the mug around you'll see
that the stain follows the cup wherever
it goes giving us a ton of flexibility
for positioning the coffee mug and
tweaking the stain to our liking okay
now you've seen how in v-ray next the
v-ray distance text can be used with the
speed of GPU rendering to get you fully
procedural an object proximity based
texture masks for creating effects like
coffee stains