Problem making a mask follow the shape of its plane

I’m making a guitar and I want it’s body to have this cool effect that’s something like… darker color on and around the edges and as the texture goes deeper it gets less dark, just like this guitar in the picture


.
I have tried to make a mask for this using a texture coordinates node connected to a vector math node set to distance then to a color ramp to adjust the size of the black circle. here’s a preview.
my problem is that the circle in the middle doesn’t match the shape of the plane it’s on. in my case I want it to match the shape of the guitar face, is there a way to do this procedurally?? (note that I have tried to use a geometry node attached to a color ramp and it didn’t exactly work on my guitar mesh, I also have no idea why… here’s a preview of this one.)
By this point I have already asked all around blender subreddits and even tried to contact CGmatter himself, but with no success as you can imagine. it’d be pretty awesome if you guys could help :grin:
Thanks in advance!

You could use vertex color mask? Painting black and white … perhaps

No, I’m afraid that won’t do at all… isn’t there a way to do it procedurally?? do you know a blender artist who’d know??

Abuse some sin waves?

Now, if you add a couple of circle masks on top this should get you there…

What you need is and “edge detect” setup.
For cycles (your screenshots use cycles) it is best to use the bevel node. There are different ways to set this up, if you google edge detect there are many videos with different variations.
In this one I used the bevel node and 2 vector math node (subtract and length).

For eevee the bevel node does not work. Google eevee edge detect.
Here is one video I found:

1 Like

Or just use the z height for the shader like this…?

1 Like

That’s AMAZING THANK YOU VERY MUCH!!!
but could you please perhaps show the rest of the nodes?? cuz I couldn’t replicate it
I have one wood material aaand you had two colors aaand I just don’t know what to do man excuse me I’m still REALLY noob with shading
that’s how I planned on replicating:

There was only one more node! A “viewer” node. I was using the “node wrangler” addon and had the output of the brightness-contrast plugged into a viewer node. The viewer node comes with the addon (which ships with Blender), I strongly recommend you look up tuts for the node wrangler addon.

You could plug what you see it into a principled shader and give it roughness etc.

The important bit is the edge detect (circled) that gives you a black and white “mask” which you can use as a factor to mix colours of your wood texture.

The edge detect bit on its own will give you a mask like this (I used the denoiser):

You can change the width of the dark area by changing the radius of the bevel node or by sliding the colour stops of the colour ramp. You do not need that many colour stops I was playing around to see how much I could control the gradient.

You can use that mask to darken your wood texture in different ways.

To explain what I did: I used a wave texture (instead of a wood image) and fed it into the factor of 2 different colour mix nodes.
One of the colour mix nodes has darker colours than the other.
The result is the same pattern one with darker colours than the other.
I then mixed those results with another colour mix node using the “mask” (from the edge detect bit) as the factor.

You do not have to do it that way if you have a wood image you can do something like this ( I know my guitar is made of old planks!):

There are many different ways you can use the mask to darken the colour, here I simply used it as a factor to mix the image with black.
This time I did use the principled shader (to not confuse you) and also only 2 colour stops in the colour ramp.

Edit
A couple of things to note:
The bevel method will only work with cycles (rendered preview).
It does not actually work on a plane there has to be some thickness to “bevel” (in your case there is no problem as the guitar has thickness.
Here is a file if you get stuck, in this file you can replace the wave texture (and its colours) with your wood image.
git.blend (135.5 KB)

1 Like

That’s amazing!! it’s awesome!! it worked!!

that’s the most wholesome and useful response I’ve ever got on the entire internet!! thank you very much for your help, patience, and understanding. <3 <3

1 Like

Thank you, I enjoy answering these questions and am very pleased to help.

Sometimes I think I go “over the top” so it is nice to know that you appreciate it. :smiley:

Just one last example, to help you understand why I used the 2 colour mix nodes in my first example instead of simply mixing with black to darken the colour.

If you feed your wood texture image into 2 different colour mix nodes it gives you total control over the result. You can change the colours of your wood texture to your hearts desire using the mask as the factor in the third mix node.

Happy Blending!

1 Like

Thanks again!!!
yup that’s also really helpful. if you look another time at my guitar, you’ll find that I did just what you said now. that’s cuz I tried with only black on the edges and it looked like hot garbage.
also, I noticed that I could do the same thing with one mix shader node instead of mix RGB, that’s cuz I’m using a PBR texture and not simply a wave texture, meaning the BSDF output cannot be connected to the color in the mix RGB. so the mix shader node does the exact some thing and it’s amazing!!