8
\$\begingroup\$

I'm making a small game in Unity, and some models are displaying very ugly shading. The shading usually looks funky along the edges between triangles. I'm pretty new to working in 3D; I bet this is an artifact of vertex lighting, but I'm not sure, and I'm not sure how to fix it.

Here you can see the worst example of this problem: alt text

Low-quality lightmapping is visible in that shot, but I'm asking about the visible bands and weird shapes visible on the surface of the orange mesh in the foreground. The mesh was built and UV-mapped in Blender, and is using a standard bumped diffuse shader. There is a light behind and above the camera; all other lights in the scene are pretty far away. What am I doing wrong, and how can I do better?

EDIT: Below is the wireframe for this model in Blender.

alt text

\$\endgroup\$
2
  • \$\begingroup\$ Maybe add screenshot of wireframe model. And also why are you using bump mapping and no bump map? (or it looks like you have none) \$\endgroup\$
    – Notabene
    Commented Jan 18, 2011 at 22:27
  • \$\begingroup\$ I added a wireframe. There's a bump map, but it's intentionally very subtle. This object is a couple of meters tall, and the bump pattern is really only visible from close up. \$\endgroup\$ Commented Jan 18, 2011 at 22:38

4 Answers 4

7
\$\begingroup\$

It looks like your vertex normals might be messed up. Each vertex's normals should be perpendicular to its face (parallel with the face normals that your wireframe image shows), and you'll need separate vertices for the corners, one for each face that meets at a corner.

\$\endgroup\$
4
  • 1
    \$\begingroup\$ To fix vertex normals in Blender, select all the vertices (A) then use "recalculate normals outside" (Ctrl+N). \$\endgroup\$
    – Jon Purdy
    Commented Jan 19, 2011 at 2:15
  • \$\begingroup\$ adurdin: this worked perfectly. Thank you very much. Purdy: I'd tried recalculating normals outside; the problem is that the vertex normals were (quite reasonably) the average of the face normals. I needed to Select Sharp Edges, then Split Vertices to separate each contiguous flat surface from the rest of the model. \$\endgroup\$ Commented Jan 19, 2011 at 3:15
  • 1
    \$\begingroup\$ I guess selecting Flat-Shading instead of Smooth in Blender (Mesh Tools) would have worked as well. \$\endgroup\$
    – bummzack
    Commented Jan 19, 2011 at 6:36
  • \$\begingroup\$ bummzack: I don't see that option under either Mesh Tools panel. There's a "Set Smooth" and "Set Solid" under Link and Materials, but it doesn't seem to translate into Unity. Must be Blender-internal. \$\endgroup\$ Commented Jan 19, 2011 at 15:47
2
\$\begingroup\$

That looks like a vertex normal issue. Not having used Blender I'm not sure what options you have to see/modify the normals directly at the vertex level.

The first thing I would do to test, is break off the front surface from the rest of the object and see if it lights correctly. If that works then you could just export it as 2 parts, front & back faces as one object and then side parts as another.

\$\endgroup\$
1
  • \$\begingroup\$ This is exactly what it was. Blender can't modify vertex normals, so I needed to separate the flat surfaces into separate submeshes in the same object. \$\endgroup\$ Commented Jan 19, 2011 at 17:50
1
\$\begingroup\$

I know this is an old thread, but I stumbled over it, so maybe someone else can benefit from this answer: The problem is: you are trying to interpolate (smooth shading) normals over a 90° angle which most of the time leads to problems.

There are multiple solutions for this: 1. set the shading to flat (T-Menu) 2. Select all edges with an angle > 50 (or higher, toy around a bit), press CTRL E -> mark sharp. Unity can read that information. It will split the vert. normals at the marked edges instead of trying to interpolate them. 3. Use an edge split modifier to actually split the mesh at the angle you specify (I would recomend the upper one in this case) 4. Use a bevel modifier with a depth of 2 or higher. I would recommend this option, it makes the mesh a bit more high poly, but also more realistic. Be sure to either mark the edges you want beveled yourself or choose angle as the limitation mode.

\$\endgroup\$
0
\$\begingroup\$

If you're actually using lightmapping, Unity has a modle import setting to Generate Lightmap UVs which would probably solve your problem.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .