• News

• Industries

• Learning & Support

• Community

• Marketplace

# Procedural Mesh - UV and Color issues

Hello!

Having problems in giving color to a procedural mesh I have made, I tried to start form this exemple (https://wiki.unrealengine.com/Procedural_Mesh_Component_in_C%2B%2B:Getting_Started) to understand how UV and vertexColors are supposed to be used.

First of all, copy-pasting the code I found there, I got a triangle which isn’t not like the one represented there. Here’s my triangle:

I tried to change every

``````

``````

with

``````

``````

but the triangle still looked the same.

Plus, it’s not also very clear to me how UV co-ordinates works. For an example, if I had a vertex at (100, 0, 0) what should be its UV co-ordinates? (-10, 0) maybe?

Thanks for the attention!

You need to apply a material that uses the vertex colour in order to see it on the mesh. Use the VertexColor input and link it straight to the diffuse.

UVs map to texture coordinates. If you wanted to create a square mesh that 1:1 mapped a texture you would use something like this

Vertices {0,0,0},{0,100,0},{100,0,0},{100,100,0}]
Triangles [0,1,2,2,1,3]
UVs {0,0},{0,1},{1,0},{1,1}]

Ok thanks, I actually don’t know how to apply the material in c++ but probably I can search before doing further questions.

But I still have a little problem with the UV. I’ve got your explanation, but let’s assume I just have two triangles. One lies in the XY plane, the other in the XZ.

Vertices {0,0,0},{0,100,0},{100,0,0},{100, 0 , 100}]
UVs {0,0},{0,1},{1,0},{1,?}]

For the material you probably want a UMaterial pointer in your C++ class and use a blueprint wrapper to set it.

UVs are the coordinates on a square texture 1 unit tall and 1 unit wide. If your texture is a vertical gradient starting at the top with yellow and fading to red at the bottom, UV (0,0) is going to sample the red at the bottom. UV (1,1) or (0,1) or (0.3245f, 1) will all be yellow. UV (0.5, 0.5) will be orange, as will UV(1, 0.5) and UV (0, 0.5);

It’s easier to explain with images but once you get it it’s pretty straightforward.