Distance from centerline to the edge of mesh/object

I was wondering if there is a texture changing based on the centerline to the edge.

It basically lets you texture an object by having other objects intersect with it (or just get near it, depending on the radius you define), and set colors for inside, outside, near and far ranges. Like I have a model and also its centerline. I basically want the the distance from a centerline…Like for individual vessel it will change the color from center to its edge. And that would give me the radius.

Try object cords, they go from the center out. Here I use the object cords of the sphere to control the texture of the cube.

If you move the sphere the texture will change.

Thank you for your response. But what I meant I tried to clarify in the picture here. I am sorry I couldn’t make it clear in my post.

Sorry I am even more confused now.

Is that form a plane or a 3d “blob”?
Where do you get the center line from, is it the center of mass or like an Edge detect on semi flat surface - AO?

I can not visualize what you want to do

and to add to DNorman’s confusion … is the “color in the nearest distance” the same as “color in the negative distance”

if so, sounds like you want a gradient extending from centerline to edge of mesh… but in 2d(ish)? 3d?

I am sorry for all the confusions. I draw it in 2D( i thought it would make this clear. sorry again) but my mesh is 3D. I already get the centerline from another algorithm. And yes “color in the nearest distance” can be the same as “color in the negative distance”. yeah. Its like I want a gradient extending from centerline to edge of mesh in 3D.To clarify more, I attached my model here. This is a mesh of some vessels. So what I want is Like for individual vessel it will change the color from center to its edge. The gradient change will happen for each vessel. not the whole mesh from center to edge. That’s why I was talking about centerline

I am also okay if there is any way I can do that without using the centerline mesh. I just need a gradient extending from center to the edge of mesh in 3D. Like it will change the color from center to its edge.

You could try to use @higgsas 3D skeleton node group and add a Geometry Proximity node at the end of the simulation zone to get the distance from your mesh to the skeleton:

3 Likes

And a more naive approach using a Raycast node:


The results aren’t nearly as good as with the 3D skeleton node group but it may be good enough… :sweat_smile:

2 Likes

Well it is a little clearer.

I take it the gradient you want is “inside” the mesh (from the center to the outer edge.)

Normally materials map to the surface of objects, not to their “volume”, the surface of the object would end up on the “greater” side of the gradient (the furthest values from the centre line).

If the distance is from the center line to the outer edge (0-1) the outer edges/faces would have a value of 1 which would be the colour the surface. If it is a standard surface material, the whole surface and object would have the same value.

Geometry nodes might get you a gradient from the centre line to the surface but I do not know how to go about it. There is then the problem of visualizing the inside of the object.

This sounds like a medical project and it is as if you are looking at the vessels in a depth sensitive microscope, seeing their outer bounds and a cut section of the inside of them.

There should be a way to “mimic” this but it would involve a non physical “hack”

I am not sure how you could visualize this with a shader, the only thing that comes to my mind is a volume shader. Volume shaders do map to the volume.
But maybe this is not what you are after.

This is volume absorption I gave the red colour a value over 1 so it becomes emmisive.
This gives you a “sort of” gradient from the center out.

3 Likes

Thank you @DNorman and @Zebrahead for all the supports and help. I really appreciate. @DNorman can you please post the rest of the shading approach? (left side of the image you posted) .
Thanks again.

It just goes into the volume input of the material output.

I am using Blender 4.0 and AGX colour management. AGX will turn emmisive colours white at high values. If you are using the Filmic colour management the colour will clip a bright red and not go into those white values.

AGX (Blender 4.0)

Filmic (Blender 3.5)

It is probably not a very controllable way to do this, volume absorption absorbs light and the colours will not always act in the way you expect. Changing the colour of the world lighting will change the effect.
Also this shader will look like this from an angle:

I was just trying to visualize the effect you are after, it is probably not a viable solution.

Here is the file anyway, it should open in 3.5 as well but it will be filmic colour management.

Absorbtion.blend (99.9 KB)

Not totally related but this thread reminded me of this old conversation:

3 Likes

Thank you very much @DNorman … It really means a lot :grinning:

I has occurred to me that maybe using a volume shader with some scatter would be more predictable. It does take a little longer to render.

Scatter.blend (148.9 KB)

In this one I did use a “center line” and gave it some thickness (it is a curve with a small bevel) and an emission shader.

Then I gave the mesh (in my case a curve) a principled volume shader.
You can make a 2 colour gradient by using the colour and Emission colour inputs.

Then you should be able to animate the gradient colours in a more predictable way than with volume absorption.

It also looks better at angles.

4.0 AGX

4.0 AGX

3.5 Filmic

1 Like

looks like a potential neon tube in the making. :slight_smile:

1 Like

Wow. It’s incredible. Thanks a ton for giving it a lots of thought and time. Its literally what I expected. It really helped me a lot. And I also learned a lot of techniques for better rendering. Thank you so much…

1 Like