12
$\begingroup$

I'd like to colour a beveled curve in Cycles by its tangent (the tangent of the actual curve - not its beveled faces).

For example:

enter image description here

In this image, the curves running up/down are blue, and the left/right curves are green. Is this information accessible in Cycles?

$\endgroup$
  • $\begingroup$ care to share a small sample blend ? :) $\endgroup$ – zeffii Dec 16 '15 at 9:03
  • $\begingroup$ I don't actually have a good blend yet - I still need to write the script to import the fiber tracts. Will hopefully get to that in the next few days. $\endgroup$ – ajwood Dec 16 '15 at 14:42
  • $\begingroup$ Alas, my laptop is I'd fried :( Time do do some research on the best choice for new hardware! $\endgroup$ – ajwood Dec 18 '15 at 2:59
  • $\begingroup$ There might be a way to do this using using the Texture Coordinate node... near the bottom there is a text field where you can use another object to control the texture space... an empty for example or a flat plane with a texture map with a full range of colors perhaps... $\endgroup$ – norvman Jan 27 '16 at 1:58
  • $\begingroup$ @zeffii I have a sample blend, but it's impractically large - 334,000 vertices in my curve object. Turns into 23.4 million Tris after beveling :/ I can share if you like. $\endgroup$ – ajwood Feb 1 '16 at 16:33
9
$\begingroup$

This is totally possible with the Tangent node (Input > Tangent):

enter image description here

Change the type from Radial to UV Map and also enable Use UV for mapping in Curve's data tab:

enter image description here

enter image description here

The problem is we get black instead of Z-axis direction. That's easily fixable - add both green and red channels together and invert them into a blue channel. To also not care about the direction of axis we make the tangent vector values absolute:

enter image description here

| improve this answer | |
$\endgroup$
  • $\begingroup$ This looks really promising! My context doesn't care about the sign of the tangent though.. so up-pointing-down should look the same as down-pointing-up. I suppose I could take the absolute value of the tangent vector. Can you think of the best way to make it note care about the sign of the tangent, without throwing out half of the colour space? $\endgroup$ – ajwood Jan 29 '16 at 21:48
4
$\begingroup$

Think I may have figured out a way. If you enable "use UV for mapping" you'll copy the curve U/V coords to the UV map of the beveled object.

Use UV for Mapping option

You can then use the vector transform node to strip off the object transform:

Vector transform

AFAIK this will fail if any of the curves have been transformed in edit mode since it relies on the object transform to get the coords back to world space.

Not sure if this is the best way, but I think any solution would have to be based around the "Use UV for Mapping" function as I don't think Cycles has access to the path itself, just the beveled and tessellated output mesh.

| improve this answer | |
$\endgroup$
  • $\begingroup$ Don't fully follow yet, but looks interesting! ...I'm wondering, would this get easier if I dropped the Cycles restriction? $\endgroup$ – ajwood Jan 27 '16 at 12:30
  • $\begingroup$ @ajwood UV's on itself are useless. There has to be math done with normal and tangent vectors from geometry node to get the actual spacial orientation of the surface. If Cycles cannot do it then there might be solution involving converting the curves into mesh and assigning vertex colors with script. $\endgroup$ – Jaroslav Jerryno Novotny Jan 27 '16 at 15:54

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.