Last week I published a video where I showed how to map a Color Ramp along the Z axis of an object, both in local and global mode, to create a gradient along the object's height.
Video Transcript
Hello everyone! Last week I published a video where I showed how to map a Color Ramp along the Z axis of an object, both in local and global mode, to create a gradient along the object's height.
In this tutorial, I’ll build on the concept of axis based mapping to create both a color gradient and a mix between two Shaders. The concrete example will be a colored progress bar, but the methods shown can be applied in other contexts as well. Specifically, by moving the control Empty horizontally, we’ll see the bar progress, colored with a gradient that goes from red to green, passing through yellow.

First, let me show you the initial scene setup. We have a Plane object that’s been scaled to stretch it a bit along its X axis. For convenience, I placed the object’s Origin at its top left corner. I also applied rotation and scale transformations to this object. This Plane won’t be modified anymore.

The other object in the scene is an Empty, positioned at the Plane’s Origin, and it also has its rotation and scale transformations applied. This Empty will control the progress of the bar, which will be implemented entirely through the Plane’s Material, without modifying the Plane’s geometry.

The Material of the Plane needs to have two features. First, we need to define the gradient along the X axis of the Plane. Once that’s done, we’ll make sure that all parts to the right of the Empty are transparent, while all parts to the left are colored with a gradient we define.
Let’s start with the color gradient across the entire object. As in last week’s tutorial, we need a Texture Coordinate node, a Separate XYZ node, and a Color Ramp node, connected in sequence.
We take the Generated output from the Texture Coordinate node, since we’re interested in the Plane’s own dimensions. From the Separate XYZ node, we use the X output, which represents the Plane’s local horizontal axis.
The Color Ramp should now be connected to an Emission node, because we want the Material to always be visible and unaffected by shading. So let’s replace the default Principled node with an Emission node.

Now the Color Ramp can be customized however you like. In my case, I’m placing a red marker on the left, a yellow one in the center, and a green one on the right, using Ease interpolation, so that red and green aren’t limited only to the extremes.


To color only the part to the left of the Empty and make the right side transparent, we first need to add two Shader nodes in the editor. Specifically, a Transparent node and a Mix Shader node. Be careful to choose the Shader Mix node, not the Color Mix node!
Then connect the Emission node to the first Shader input of the Mix Shader node. Connect the Transparent node, which should be set to pure white, to the second Shader input of the Mix Shader node.
Connect the output of the Mix Shader node to the Surface input of the Material Output node. At this point, we have a semi-transparent Material with a gradient from red to green, passing through yellow.

In a Mix node, whether it’s Color or Shader, the second input is used fully only when the Factor is 1. So we need a way to make the Factor equal to 1 on the right side of the Empty’s position.
So let’s add a Texture Coordinate node and a Separate XYZ node to the editor, and connect the X output of the Separate XYZ node to the Factor input of the Mix Shader node.
This time, however, we use the Object output of the Texture Coordinate node and specify the Empty in the Object field of the node.

Now the resulting Material will be transparent to the right of the Empty and colored to the left, as intended. However, we can see that the Material remains semi-transparent well beyond the Empty’s position.

To make the transition to the Emission node happen sharply right at the Empty’s position, we insert a Math node between Separate X and the Mix Shader node, set to Greater Than mode with a Threshold value of 0.

This way, the Greater Than node will take the X coordinate from the Empty and output 1 for all values greater than that coordinate. The Mix Shader node will then sharply switch to the second Shader, that is the Transparent node.
Finally, we can parent the Empty to the Plane. This way, we’ll be able to move the Plane anywhere in the scene and the Empty will follow, but we’ll still be able to move and animate the Empty independently.
That’s it for this tutorial! Unlike most of my other video tutorials, a PDF version of this one is not currently available for download. However, you’ll find a link in the description to a page containing PDF versions of many of my other video tutorials. In any case, this is a great time to subscribe to the channel and turn on notifications! See you soon!