Change Color by Distance
Xpresso, Textures – by: base80
October 10th, 2005
Here is a small example on how to change parameters of a texture using xpresso.
What I wanted to do is change the color of the sphere according to the distance to the “bullet”.
Follow up:
Lets start by animating the bullet on a spline so that we can see the result of the xpresso as it evolves.
Now open the xpresso editor and drop the sphere and the cone in it. Open the position ports of both objects. Drop a Distance-node in the editor and connect the position of the two objects to the input ports. The output port gives you the distance between the two objects, that is great.
Next thing is that we want to feed this distance to the color channel of the texture of the sphere. We need to use a Range-mapper-node to “translate” the distance to the color. The color port accepts values between 0 and 1. So we put those aas upper end lower output in the range-mapper. Then we need to determine the upper and lower input values. What I did is to chack how far the cone is at tha maximum and minimum, 0 and 1000 in this case. Put those values as upper and lower imput in the range mapper. Now connect the output to the color ports of the material and the whole thing should do as in the animated gif.