# How to make roughness vary linearly along one axis for a vertex group?

I have a vertex group selected along a surface scratch and want to vary the roughness parameter in principled BSDF from lets say 0.5 at the start of the scratch to 0.2 at the end of the scratch linearly using a mathematical equation. Essentially making the scratch shine more as you go from the scratch start to end. Scratch is aligned along the Y-axis as shown in the image. Can anyone please direct me to achieve this solution. Any help will be appreciated.

If I understand this correctly, you don't need a vertex group whatsoever:

I'm using generated coordinates, which output n,0,n at the -y side, and n,1,n at the +y side. Then I'm remapping this to the 0.5, 0.2 range. I'm showing two of them, side by side, so you can see the difference in roughness at the edge between them.

That's assuming your scratch is a single object, which is how generated coordinates are calculated (on an object-by-object basis.) If you wanted your scratch integrated into some other object, you might consider UV mapping the scratch to the 0,1 range in its UV's y axis (ie, the V axis) and then using UV coordinates instead.

As shown, this is a mathematical formula-- it's linear interpolation, the formula of a line: roughness = 0.3y + 0.2. But, depending on your definitions, everything is a mathematical formula. If you want some specific mathematical formula, we'd need to know what formula to implement it for you.

• Hi Nathan, thanks a lot for your quick reply. This seems to be the solution I am looking for. I tried it on one scratch, it looks as I expected it. Thanks again for your time and effort. Commented Dec 20, 2023 at 0:48