Search Unity

Material not displaying correctly in custom mesh.

Discussion in 'General Graphics' started by tennseven, Sep 2, 2019.

  1. tennseven

    tennseven

    Joined:
    Sep 2, 2019
    Posts:
    2
    So I built a custom mesh using a quick tutorial online. It works fine if I use just a basic material on it but if I use anything with a texture, that texture doesn't translate. Here is an example: https://imgur.com/a/LG9gLZJ

    In that picture, both the triangle and the plane beneath it have the exact same material. It shows up correctly on the plane, but not on the triangle. If I change the material offset the triangle changes color, so I'm guessing it's some issue with the way the texture is projected onto the mesh? If I change the MeshFilter mesh to "Plane," I can then see the texture but of course it overrides my custom shape and turns the triangle into a square.

    Can someone tell me what I am overlooking?
     
  2. mouurusai

    mouurusai

    Joined:
    Dec 2, 2011
    Posts:
    350
    No UV coordinates I presume.
     
    PersianKiller likes this.
  3. tennseven

    tennseven

    Joined:
    Sep 2, 2019
    Posts:
    2
    Yeah, you're right. If I put in some UV coordinates I start to see the pattern, though it's all messed up. I'm not sure how to calculate them.

    EDIT: I found some docs that had an example. After figuring out how to correctly calculate the UVs, the material is working properly. Thank you @mouurusai !

    The doc is at https://docs.unity3d.com/ScriptReference/Mesh-uv.html , in case anyone comes across this later and needs it.
     
    Last edited: Sep 3, 2019
    jacksonkr, FastInsOi and kreso like this.