misbehaving normals

So I’m using blender to create some objects for a Java/OpenGL game I’m working on. My process is to design the object in blender, export as wavefront .OBJ, parse the ascii file and convert into some vertex buffer objects I can render via OpenGL. Normally this process goes quite well. But quite often I hit the below rendering artifacts.

From the blender side the Normals don’t look this bad. I tried selecting certain surfaces as being Smooth/Flat, although I’m not sure if that is affecting much on the normals.

Does anyone recognise what might be casing the ‘zebra stripes’.

I think the pattern on the top is caused by many triangles starting from the same vertex, probably causing a heavy weighting for the normal average calculation. In fact when I display the model normals I can see that this seems to be the case. So is there some easy way to get blender to recalc the triangle used to form a surface? ie for this I’d want like a zig-zag pattern, or radial triangle fan from the center, rather than a triangle fan from a single vertex on the edge. I found Beautify Fill but that still gives me some vertices that are heavily shared for triangles, thus affecting the normals.

I’ve also tried selecting just the faces around the bulge of the bottle and Ctrl-N for a normal recalc, but this doesn’t change anything on the normals from what I can tell.

Thinking a bit more about this, I think what I’m looking for is a way to control which surfaces get included when calculating the normals. The bottom of the bottle is probably causing the dark bands… so I’d need to exclude the bottom surface for the vertices around the bottom when calculating the normals… if that makes sense :slight_smile:

Any tips or pointers appreciated.

Cheers

Peter

EDIT
I found the Shift-Fill option now which gives me the zig-zag type fill for the top, but I can’t find anyway to do a radial fill (spokes on a wheel) without doing it by hand, which means the normals are still being weigthed to the vertices with more edges.

I also noticed that the normals are not updated on the fly which has been causing some of my confusion, pressing TAB twice seems to update them. (tested with 247.7 as well)

http://www.whitehexagon.com/bottle.png

Start again. Use extrude, but don’t reduce the amount of sides as you get to the top.

Same number of vertices on each extrusion. It’s just these lighting glitches that make it look otherwise. (see blender image below - yes I changed the shape a bit)

With smooth shading in my openGL it doesn’t look quite as bad, although the darker triangles from the base still seem to show through a bit. I guess I could subdivide to try and hide it somewhat. But I would still like to try and understand why the dark triangles are there in the first place…

http://www.whitehexagon.com/bottle-blender.png

Some rendering engines can have problems with long thin triangles. You may have to convert those back to quads then add a few edge loops to divide polys more evenly.

Not sure about your triangle issues, but as far as the radial fill you were asking about, I may be able to help.

First off all get rid of any faces on top until you have a hole.
Then grab the ring surrounding the hole
Extrude then right click to leave the extrusion in the same place
Scale -> 0
alt+m -> merge at center

Hope that makes sense.

thanks for the radial fill tip, worked a treat!

Regarding the normals. I’m starting to piece together how this works. It seems like faces that are maked as smooth assume the vertex normals, and faces maked as flat assume the face normals. Is that be correct?

I think the stripes don’t show as bad in Blender because the light moves with the camera, whereas in my game they are fixed somewhere above and in front of the object. This means the underside of the bottle is darker for me making the stripes worse. Even if I make the side of the bottle smooth and the underside flat, the smooth side vertex normals are probably being weighted by the surface underneath. (I can see this by deleteing the bottom of the bottle, then the vertex normals are calculated at 90deg to the bottle side, when the bottom is replaced, the vertex normals are pointing down 45deg making the bottom triangles darker)

So here’s the crunch… I have an idea for trying a different approach with the normal calculations, but I need a pointer to where the normals are being calculated. I found the export python file once before (changed some defaults) but the normals seem to be recalculated elsewhere in blender…

What I’m thinking is that vertex normals would only take account surrounding smooth surfaces when averaging out, ie the flat bottom of the bottle would then be ignored. Sound reasonable?

Cheers
Peter

I always got bad surprises with triangles… Is there any reason to keep them?

sure, the models are being used in OpenGL which needs a triangle mesh.

?
I use OpenGL… and triangles are very rare on my meshs… ;?

Blender Game Engine also uses OpenGL and does not require triangles.

But same game engines do require triangles, in fact Oblivion’s engine requires triangles if I recall correctly. Most likely the engine being used here requires triangles, so there may not be any way to avoid them. Have you tried opening the .obj to see if it did not export correctly?

As far as the normals, I don’t really now to much about how blender handles them, but you can have Blender draw the normals. While in edit mode -> Edit Tab -> Mesh Tools More -> Draw Normals.

Not sure if that will help any as I think it more shows the normal’s facing than how it is calculated.

edit
changed texture to triangle :stuck_out_tongue:

yes, my bad. My .OBJ importer expects triangles is what I meant. Since this avoids any of the OpenGL nastiness associated with non-coplanar polys.

Coming back to the point.

I’ve found now the code that exports the .obj file. For surfaces marked as smooth it takes the calculated vertex normal, and for faces marked as solid (flat) it takes the face normal. This makes sense to me now, and has helped my improve the final OpenGL render on some of my meshes now.

However one open point remains open, and that’s the boundary conditions between Smooth and Solid faces. Would it make sense to have an option here to allow Solid surfaces to be issolated from adjacent Smooth surfaces during normal recalculation? ie the meshCalcNormals would exclude adjacent non-smooth surfaces when calculating vertex normals for smooth surfaces.

I’ve found a couple of ways to work around this for now:

  1. Increase triangle count near bottom of bottle. ie a row of very small triangles where my dark underside ‘shadow’ can bleed into.
  2. Use a separate mesh for the Solid areas. ie split all vertices around the bottom of the bottom.
  3. Remove the bottom of the bottle

Since I’m interested in using a few triangles as possible, option 3 is the simplest way for now :slight_smile: but somehow not very satisfactory…

Sorry i didn’t notice immediately the purpose for gaming… I just read something about the need of triangle for certain game engines… <;o/