is there a way to make a gradient material, white to black, in Unity3D?

Assuming a model has UV's already setup, is there a way to "create" procedurally or otherwise, in Unity3d, a gradient material without using a texture?

Here's an example of a gradient ramp:

Or do I need to create a texture, import it and apply it to the model?

You can create a material procedurally without textures by writing your own shaders. That way, you'll be working primarily with vertex positions, normals, uvs, colors and calling different arithmetic functions that are interpolated across the surface.

For example, you could do the ramp along your uv.x or uv.y. Just interpolate a color using the value from the uv map.

Or even more simple, depending on your needs, just set the Mesh.colors to the colors instead and use a shader that makes use of colors (I think the built in ones do, but I am not 100% sure - try it out!). Otherwise you can check out this shader.

  • Edit: The link I provided actually says:

    (Note that most builtin shaders don't display vertex colors, you can use eg. a particle shader to see vertex colors)

Here, each color represents a vertex in your mesh. This color is interpolated across the surface of the neighboring triangles automatically, just like texture coordinates or normals.

Editing the example from Mesh.colors could yield:

// Unityscript converted to C#
void Start ()
    var mesh = GetComponent<MeshFilter>().mesh;
    var uv = mesh.uv;
    var colors = new Color[uv.Length];
    // Instead if vertex.y we use uv.x
    for (var i = 0; i < uv.Length;i++)
        colors _= Color.Lerp(,, uv*.x);*_ 

mesh.colors = colors;

I tested this with a particle material and it seems to work fine.

void Start () {

    var mesh = GetComponent<MeshFilter>().mesh;

   Vector2[] uv = mesh.uv;

    Color[] colors = new Color[uv.Length];

    for (var i = 0; i< uv.Length; i++)
        colors _= Color.Lerp(,, uv*.x);*_

mesh.colors = colors;