1
$\begingroup$

I have two 2D meshes next to each other in Blender. I plan to scale-animate one of them (with the connecting edge remaining constant). I'd like the two meshes to have a linear color gradient go across them. The following image shows a schematic of what I'm trying to achieve (the 2 rectangles representing my 2D meshes in Blender).

This schematic is drawn in figma, which provides a handy "from-color-1-to-color-2" overlay over the shape to be colored making it easy to coordinate such a color gradient across two shapes because this tool lets you specify the start/end color right at the edges you're interested in.

However, all I have seen in Blender so far when it comes to color gradients doesn't suggest a way to precisely determine the start/end color for any given edge of a 2D mesh. Is this possible? Thanks!

enter image description here

$\endgroup$
1
1
$\begingroup$

To add a basic gradient you first need a Texture>Gradient_Texture node, and have it's color output connected to the base color of a shader.

enter image description here

To add color to the gradient use a Convert>Color_Ramp node, and assign whatever colors you want to the extremes.

enter image description here

To control the placement you must understand texture coordinates. In this case, because there are no explicit coordinates set, the default is "generated coordinates". Generated coordinates start at the bottom left of the object's bounding box.

enter image description here

To rotate the gradient so that it starts at the bottom of the object you have two choices:

1- Select the Gradient texture node, open the item properties and use the rotation on the Z axis to rotate the gradient -90 degrees.

enter image description here

2- (preferred option) Use an Input>Texture_Coordinates and a Vector>Mapping nodes to control the placement of the texture. Why is this better? Because it is easier to see what is happening if anything goes wrong...

enter image description here

The exact location of the colors is thus determined precisely by the location, rotation, and scale in the mapping node.

The next step would be to learn even more about texture coordinates, and use UV coordinates instead, that will give you coordinates based on the actual geometry of the object and it's vertices.

But since the goal of this answer is not to teach you how to use blender in a single post, you can do the rest of the learning into coordinates by watching Bartek Skorupa’s video on How to Manipulate texture coordinates

$\endgroup$
4
  • $\begingroup$ Thanks for such a super-thorough response! $\endgroup$ – Magnus Jan 5 '20 at 21:50
  • $\begingroup$ FYI to any others facing this sort of situation -- it was also very helpful in my case to understand that the coordinates of the gradient are relative to the bounding box of the object, which you can view for a selected object by going to Properties Editor > Object Properties > Viewport Display and selecting "Bounds" $\endgroup$ – Magnus Jan 5 '20 at 21:53
  • $\begingroup$ It all depends on what kind of coordinates you are using. UVs are tied to the actual vertices of the object, while Object Coordinates start at the origin. $\endgroup$ – user1853 Jan 5 '20 at 23:00
  • $\begingroup$ FYI to any others facing this sort of situation -- make sure you pay attention to the direction of rotation (try both - and + values). Also, be aware that translations of the gradient seem to always happen first, followed by the rotation; if you first rotate and then try adjusting position, you'll find the direction of translation is not in line with the direction of the gradient. $\endgroup$ – Magnus Jan 9 '20 at 20:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.