1

enter image description here

I want to animate a section of a cylinder that changes colour and follows the path of the cylinder. Below, I've quickly illustrated what I'd like. I want the green section to move left-to-right and then following the path continuing towards the camera.

How can I achieve this? I note this answer, but it isn't quite what I'm after. It's only along one direction (X, Y or Z). I want the colour change to follow the cylinder regardless of what direction it's moving in.

I am following Maulik Sharma's suggestion and it works nicely. However, the way that I'm constructing my cylinder is causing issues with the UV unwrap. I generate the cylinder, scale it into the mirror and then difference bool the cylinder with the mirror to leave this face: enter image description here

Now, I simply extrude this face along a direction: enter image description here

The UV unwrap for an object like this is quite unruly and doesn't allow the 'colour' change to flow properly:

enter image description here

What's a better way to generate my cylinder so that this doesn't happen?

smollma
  • 134
  • 8
  • 2
    Consider UV unwrapping your object such that the path of your section corresponds to one of the axis of the UV map. Then you can use the same technique as the answer you linked, just using UV coordinates instead of generated coordinates. – Alexis King Mar 29 '21 at 23:29
  • Have you tried using the Geometry node -> Position vector in shaders? – TheLabCat Mar 30 '21 at 02:21
  • @Alexis King any more information on how to do that? – smollma Mar 30 '21 at 04:00

2 Answers2

2

As Alexis King says, you can unwrap your cylinder with the Follow Active Quads method in order to have an orthogonal grid (make sure that your topology has quads that are rather the same size):

enter image description here

Then give it this node setup: Texture Coordinate (UV output) > Mapping > ColorRamp (in Constant mode and with your main and stripe colors) > Diffuse > Output. Now you just need to keyframe the Mapping "Location" values to move the stripe along the cylinder:

enter image description here

moonboots
  • 155,560
  • 7
  • 105
  • 171
2

Here's my answer, hope it helps:

  1. UV Unwrap the object
  2. Follow this node groupenter image description here
  3. You can animate the color to make it color change
  4. Movement make the color move and width changes the width
  5. I have attached the blend file too

P.S. Make sure you place the UV islands one after the other so that the color moves properly

Result and UV map: enter image description here

In your case how you made your cylinder is not that important. Your UV Map is not that difficult to fix.

  1. Make any one face rectangle by scale the vertices on x and y axis to 0

  2. Select the face you corrected

  3. Press L

  4. Right Click

  5. Click on follow active quads

  6. For step by step instruction, I made a video for you: https://drive.google.com/file/d/1TZMg3nT229WVAF4RRS4pz20XnROdeJ7M/view?usp=sharing

(Blame the compression for garbage quality)

Blend File: https://pasteall.org/blend/1fbbe168afd841d093026a3c4967e20f

Maulik Sharma
  • 799
  • 3
  • 14