Page
Page

Reputation: 63

Procedurally generated UVs

I have a procedurally generated cube that has a hole(s) in it. The script will take a mesh (the white squares in image 1) and creates the shown holes based on the position of the squares (image 2) (in other words, the squares are pretty much randomly placed.) The problem I'm having is that the light on the mesh is completely messed up (image 3). Currently the Array of UVs for the mesh is an empty Vector2 array. I believe that the UV array the problem so then how can I get the list of UVs when the only information I can get on the mesh is the list of vertices and the list of triangles? Or if it's not a problem with the UVs, how can I fix this? (In Unity C#)

enter image description here

Mesh of Cube

enter image description here

Upvotes: 0

Views: 161

Answers (2)

Bugge
Bugge

Reputation: 35

If the problem has to do with the normals try:

mesh.RecalculateNormals();

Upvotes: 1

tim
tim

Reputation: 114

Unless lighting is baked into the texture, it is more likely a problem with normals. You need to be more specific, show your shader code or how you generate vertices etc.

Upvotes: 0

Related Questions