Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

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

share|improve this question
    
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) –  Notabene Jan 18 '11 at 22:27
    
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. –  Gregory Avery-Weir Jan 18 '11 at 22:38
add comment

3 Answers

up vote 5 down vote accepted

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.

share|improve this answer
1  
To fix vertex normals in Blender, select all the vertices (A) then use "recalculate normals outside" (Ctrl+N). –  Jon Purdy Jan 19 '11 at 2:15
    
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. –  Gregory Avery-Weir Jan 19 '11 at 3:15
1  
I guess selecting Flat-Shading instead of Smooth in Blender (Mesh Tools) would have worked as well. –  bummzack Jan 19 '11 at 6:36
    
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. –  Gregory Avery-Weir Jan 19 '11 at 15:47
add comment

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.

share|improve this answer
    
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. –  Gregory Avery-Weir Jan 19 '11 at 17:50
add comment

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

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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