problems with three normals on vertex

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
pera
Posts: 460
Joined: Wed May 14, 2008 1:05 pm
Location: Novi Sad, Serbia
Contact:

problems with three normals on vertex

Post by pera »

When I load 3ds model to irrlicht each vertex has three normals instead of one, so lighting is not smooth on these models but broken on edges so triangles are visible. Anyone knows irrlicht API that would calculate only one normal on vertex?
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: problems with three normals on vertex

Post by CuteAlien »

Irrlicht has only one normal per vertex. But maybe you have more than one vertex on the same point for some reason?
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Re: problems with three normals on vertex

Post by hybrid »

Yes, the 3ds loader duplicates vertices. You can use the mesh manipulator to weld the vertices together, and recalculate normals then. Better idea might be to use a different mesh format, though, as 3ds is not really well supported.
pera
Posts: 460
Joined: Wed May 14, 2008 1:05 pm
Location: Novi Sad, Serbia
Contact:

Re: problems with three normals on vertex

Post by pera »

But the question in 3d forum is oriented toward Blender exporting, there I ask 3D experts. Question here is for irrlicht API, but OK.
X format has same problem.
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Re: problems with three normals on vertex

Post by hybrid »

Well, it does not matter where the model is exported from. It's just an issue with 3ds files in Irrlicht.
smso
Posts: 246
Joined: Fri Jun 04, 2010 3:28 pm
Location: Hong Kong

Re: problems with three normals on vertex

Post by smso »

Maybe duplicated vertices.
Use blender/3dmax or irr mesh manipulator to clean them up first.

Regards
smso
pera
Posts: 460
Joined: Wed May 14, 2008 1:05 pm
Location: Novi Sad, Serbia
Contact:

Re: problems with three normals on vertex

Post by pera »

According to this thread: http://irrlicht.sourceforge.net/forum/v ... =4&t=30793
Welding vertices won't do anything. In fact, I don't care if there are three vertices, just as long as their 3 normals are all in one direction.

How do I go about finding vertices with same position and then changing their normals to new average value?
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Re: problems with three normals on vertex

Post by hybrid »

Iterate over all vertices and check if they coincide. Next you need to find all faces, and calculcate the normals over all adjacency faces, get the average, and assign to all those normals you found in the first place.
Klunk
Posts: 264
Joined: Mon Jan 10, 2011 5:21 pm

Re: problems with three normals on vertex

Post by Klunk »

do you have access over the original model and how its exported ? the three normals on the vert are there because there are 3 faces with different smoothing groups using this vert. Smoothing groups are used in 3ds Max as a way of putting hard edges on meshes. This is entirely desirable on say the corner of a cube, and as mentioned above it would actually be exported as 3 verts in the same position each with its own normal. As opposed to something like a sphere where it would not be so useful other than for some deliberate visual reason. If the later case and if you can edit it the model so that the faces all have the same smoothing group and re-export all will be dandy. Its worth noting that a break in Smoothing, UVs, vertex colours, vertex alpha etc should cause a duplicate vertex to be produced to achieve the same visual effects of a 3ds max model in a game engine.
krom
Posts: 17
Joined: Sun May 17, 2009 5:27 pm

Re: problems with three normals on vertex

Post by krom »

After trying to use the 3ds format some time ago i just concluded to not use it anymore, It sucks!
I dont think it support sharing of vertices/smoothing groups, witch basically made it slower in realtime than other better formats.
My advice is import it into blender and convert to ply, or obj.

k
Post Reply