- Home /
Why is my mesh getting messed up
I have a plane that I made in Blender and then applied a modifier too that split all the triangles so that none of them share vertices. See first image:
I Exported the file and then imported it into Unity (I tried both .blend and .dae) I then attempted to deform the mesh to check that the disconnection between triangles was maintained and lo, it has been broken. See second image:
Why is this happening and how to I make it stop happening?
For those who would question why I would want to do this in the first place: I'm attempting to do low ploy terrain generation. Mesh deformation is the easy part. But application of flat shading to a dynamic mesh is not. If a mesh is straight imported into Unity one can use the "set smoothing angle" function in the importer to apply flat shading. However, use of the "Mesh.RecalculateNormals" function applies an averaged shading angle to all vertices and there is no programmatic method in Unity for setting the smoothing angle. Thus, I must use a mesh with triangles having no shared vertices.
I am, of course, open to suggestions as to an easier way to accomplish this goal. But I have spent hours Googling the problem to no avail.
EDIT: Links to code and .blend file
(Ran out of attachments, and the code formatting was not working. hence the external links)
How are you defor$$anonymous$$g the mesh?
Can you post your .blend file in a .zip as well, thanks.
I have added links in the post to the code and the blend file. See the edit at the bottom. Thanks for looking into this.
That download link is full of mal ware, please post somewhere else thanks :)
The new link will let you download the file from my web server. Thanks again.
Answer by MrSoad · Dec 18, 2014 at 06:39 PM
You had not unwrapped your mesh. It took me a while to figure out :D
Here is a pic of your mesh and deform script running after doing the uv unwrap in Blender :
Thats so weird. Why does doing a UV unwrap affect the resulting mesh?
No idea but I was all out of ideas until I tried it with a height map, where it acted like a quad which told me that it was not unwrapped.
Once I had unwrapped it your script worked perfectly. $$anonymous$$aybe as it had no UV data and it is a single mesh object Unity or the Shader did not know how to deal with it and so it stretched the texture render over all the vert points...???
PS : Don't forget to accept my answer :D
It was probably a baking issue. $$anonymous$$odifiers only exist inside blender. When you exported the first time, you may have gotten the mesh without the "split verts" modifier baked in. There was probably a button you should have pressed.
When you unwrapped and exported, it just happened to force the modifier to be applied (since the unwrap had numbers for each split vert.)
Fantastic. Thank you for the help $$anonymous$$rSoad. And to you Owen for the explanation.
lol, thank you @Owen Reynolds for explaining.
Odd thing is I looked at modifiers and re saved a few times with an Edge Split modifier(both using angles and with all edges set to sharp). None of these did anything, only the unwrap at the end sorted it out?