# Correct Normals

I have created a 3d geometric shape using an export file from a modeling program (Art Of Illusion) ,see attached screenshots. I have manually calculated the normals for the shape and I am satisfied that these are correct (mathematically). However when I render my shape with OpenGL, it displays some unwanted facets at the points where the spherical cutout intersects with the cube shape. I believe the normals are actually correct and that because of the 1 normal per vertex relationship in OpenGL that this is expected behaviour. Is there any way around this? I assume there must be because the modelling program uses OpenGL for its rendering.
I would really appreciate any help.

Inline Images

## Comment viewing options

### Re: Correct Normals

Try rendering the normal vectors using OpenGL. Foreach normal, draw a single line from the vertex in question, P1 , to the point P2 defined by:

P1 = vertex;
P2 = vertex+normal*c;

.. where c is some appropriate constant, suitable for the scale of your model (maybe 1/100th of the whole model size)

Then you will visually see the normals in your renderings, and can judge whether they are actually normals to the surface or something else :)

### Re: Correct Normals

OK I have done what you suggested and the normals do seem like they are correct still.

### Re: Correct Normals

Could you post a screenshot, including normals visualization?

### Re: Correct Normals

Yes of course (see attached)

AttachmentSize
cube4.JPG17.27 KB
cube3.JPG15.23 KB
cube2.JPG19.46 KB

### Re: Correct Normals

If you want your model to be less "gouraud-shaded" and more "flat-shaded" (gives a more "square" look) - you should have three normals per "dice corner". In your images there are only one normal per "dice corner".

I don't know if this is the reason for the "dark areas" of your sides, but it it might be worth a try.

### Re: Correct Normals

Easier said than done. I originally started off with three vertices per "dice corner" and this gave perfect results - for simple square sided objects this is fine. When I want to achieve a more complex shape (which is my aim) I am relying on free 3d modeling software rather than modeling by hand. The only output I can export from the free packages doesnt calculate the additional vertices I need to model import into OpenGL correctly. Thus I seemingly have two options:
1 - Find a free 3d package that will successfully calculate per vertex normals
2 - Find a free 3d package that will successfully calculate the additional vertices needed to use flat shading.

Surely this isn't an uncommon problem? I have been trawling the Internet for days now but without success.

### Re: Correct Normals

Couldn't you convert the model data you are reading, into some other data structure?

From: one vertex, one normal, shared by many triangles per dice corner
To: soup of triangles or polygons, where each vertex has it's own normal (no shared normals).

This could be done by going through the model data polygon-by-polygon (or even triangle-by-triangle), and producing new polygonal data from that.

Of course simpler to say than do :)

### Re: Correct Normals

It's looking like I may have to do exactly that!

### Re: Correct Normals

IIRC, Blender3d allows you to specify soft / hard normals per-face. I don't know how this affects the exported model, but presumably hard normals will duplicate the relevant vertices.

Edit: Otherwise, maybe look into creating a normal map and use per-pixel lighting? I don't know if any free modelers can create normal maps, but maybe this is worth taking a look into. On the downside, this will increase hardware requirements (I don't think you can do per-pixel lighting with anything less than OpenGL 1.3).

### Re: Correct Normals

I have gone down the route of generating the new vertices and I am getting some very nice results.
Thank you all very much for your time and suggestions.