1
\$\begingroup\$

This is a generative mesh - wireframe looks like this enter image description here

Here's the material enter image description here

But the shaded object looks like a tie dye tshirt enter image description here

I've no idea what settings are causing it to look like this. These are the settings of the mesh renderer enter image description here

\$\endgroup\$
4
  • 1
    \$\begingroup\$ How did you set up the UV map for that mesh? If you didn't, then that's what you need to do. \$\endgroup\$ – Philipp Dec 17 '20 at 11:30
  • \$\begingroup\$ There isn't one - that sounds like a good lead, thanks \$\endgroup\$ – Tom Dec 17 '20 at 11:46
  • \$\begingroup\$ I'd also be curious how you've generated the mesh normals. We're seeing very strange interpolation artifacts between the vertices, which can happen if your normals are seriously warped around compared to the surface. \$\endgroup\$ – DMGregory Dec 17 '20 at 12:59
  • \$\begingroup\$ Quick correction: your second image shows a texture not a material. Materials can use textures, but the two are separate things. \$\endgroup\$ – jhocking Dec 17 '20 at 16:38
1
\$\begingroup\$

It appears like you generated the mesh vertices, but did not generate any texture coordinates (aka uv map) for them. Texture coordinates are important, because they tell the renderer which part of the texture should be visible on which polygon of your 3d mesh.

So when you generate a mesh using the Mesh class, make sure that you don't just fill the .vertices array but also the .uv array with one Vector2 for each Vector3 in your vertices array.

\$\endgroup\$
2
  • \$\begingroup\$ I've no clue how to do this - is it as simple as mesh.SetUVs(0, vertices) or do I need to do a more complex process? I also ran mesh.RecalculateNormals() to get the normals, but this doesn't seem to have made any difference to the rendering. \$\endgroup\$ – Tom Dec 17 '20 at 15:13
  • \$\begingroup\$ @Tom every Every Vector3 in your vertices array needs a corresponding Vector2 in your uv array. These Vector2's are pixel-coordinates on your texture and are used to determine which part of the texture is visible on which polygon. So the values depend on how exactly you want to apply your texture. There is no simple one-line shortcut for this. You will have to think about this for a bit. \$\endgroup\$ – Philipp Dec 17 '20 at 15:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.