How can I create a green material with a white line?

Hi!

How can I create a material with a white line? Like this:

In the above example there are two meshes with different material.

Thank you!

Something like this:

But I don’t know how to use it.

Hello there @ViaCognita!

You are on the right track, but that setup won’t give you control over how the line behaves, where it’s positioned, or any other parameters. Let me show you how to create a material that you can easily manipulate:

  1. Create a new material, and open it

  2. Start by creating two vector parameters, holding V and clicking. Name them BaseColor (R=0.1 G=0.8 B=0.1) and LineColor (RGB=1)

  3. Next, hold S and click to create two scalar parameters. Name them LineWidth (0.05) and LinePosition (0.5). That last one will place the line in the center of a mesh

  4. Add a TextureCoordinate and a ComponentMask nodes. Set the mask with only the G channel enabled, to extract the coordinate for the line

  5. Now, add a Subtract and Abs nodes. The connection should be Coord > Mask-G > Sub-A > Abs. Take LinePosition and connect it to Sub-B

  6. To add a bit of a soft edge to the line, create a SmoothStep node, and a Constant node with value 0.01. The connection setup should be Min = LineWidth, Max = LineWidth + 0.01, Value = the Abs output. Add a OneMinus at the end to invert the mask

  7. Finally, we blend everything. Add a Lerp node, which will receive A = BaseColor, B = LineColor, Alpha = the OneMinus output, and connect the end to Base Color.

Here’s how the end result should look like:

Save it, then right click on your Material, to create a Material Instance:

Apply this instance to any mesh (I’m testing with a cube), then open the instance, and enable the checks on the Parameter Groups, which will allow you to modify how this material instance looks:


From here, you can create as many variants as you need. Hope this helps!