Inside Sabertooth
Learn how Sabertooth uses 3ds Max to create 3D interactive projects, including HBO Go’s Game of Thrones interactive experience
  • 1/3
You are here: Forum Home / Autodesk 3ds® Max® / Autodesk 3ds Max / 3ds Max Design 2009 / Triangulation causing bad vertex normals
  RSS 2.0 ATOM  

Triangulation causing bad vertex normals
Rate this thread
 
32017
 
Permlink of this thread  
avatar
  • Zuur
  • Posted: 13 July 2009 12:26 PM
  • Total Posts: 1
  • Joined: 13 July 2009 05:29 PM

Hi All,

I have the problem stated in the subject line - I know what’s causing it, but not which part of our pipeline it happens in, or how to avoid it…

Our artist is sculpting a model in Mudbox (2009), importing this into Max (2009), then exporting as an ogre mesh using OgreMax (1.6.23/1.7.0).

The problem we are seeing is that Mudbox uses quads, and the model which ends up in Max is using quads, but when we export a triangulated ogre mesh the vertex normals are “"incorrect"” and causing lighting problems because it appears to re-calculate the vertex normals after triangulation.

Please see the attached image - I’ll refer to the sub-images below:

What you can see in the images is the floor of a tunnel - it’s a bit hard to see what’s happening because there’s pink stripes drawn across the floor, but the floor is actually going up and down: if you look at 1B and 2B the faces I’ve highlighted in green are facing toward the camera the red ones are facing away from the camera.

If you look back to image 1A, you can see four or five slightly dark patches across the stripes on the floor - these aren’t part of the texture map. If you look at image 1C I’ve circled one of them in red. There are actually patches which are lighter than they should be as well but they’re not so obvious (one circled in green).

Now these ridges across the floor are pretty uniform - one side points slightly toward the camera and the other points slightly away, so all the vertex normals in question should point straight up for smoothing purposes (but they don’t => problem). To understand the problem, if you look at the red circled vertex in image 2C (which relates to a dark patch) it’s got 4 triangles connected to it which point away from the camera, and 2 triangles connected to it which point toward the camera, so the resulting vertex normal is pointing slightly away from the camera instead of straight up because of the 4:2 triangle weighting (ie: it points away because there are more tri’s connected to it pointing in that direction).

The green circled area has the opposite problem (ie: 4 tri’s pointing toward and 2 away, so the normal points slightly toward), and the purple circled area is just fine because it’s got 3 tri’s each way.

Three possible solutions occur to me:
1) Get mudbox to produce a normal map for an unsmoothed version of the triangulated mesh, in which case the bogus normal map would fix the bogus mesh normals and look right (assuming we have a shader on it that renders the normal map). I think this works, but it’s *really* not the solution we want.
2) If all the quads were split the same way into tri’s (eg: all split top-left to bottom-right), then all the vertices would be like the purple circled one and it would look fine (in most places). Again, this isn’t really a fix - it’s just an attempt to avoid the problem. I assume the generation of the new quads in Mudbox is what decides which way they will be cut into triangles?
3) The correct solution seems to be to generate vertex normals from the quad-mesh, and then retain these vertex normals when the mesh is triangulated.. this is because the quad-based vertex normals will always be “"correct"” because for example in the image shown there will always be two quads connecting to the vertex which point away, and two which point toward the camera. This is what I’d like to see happen, but I’m not sure where the triangulation and re-calculation of the vertex normals is happening at the moment, or how to control it.

Any thoughts on how to achieve “3)”, other fixes, or just feedback in general is most appreciated.



Attachment Attachment
Replies: 1
/userdata/avatar/jchcb5fdm_Light.png

First, I have never used Mudbox or OgreMax. But...have you tried to convert your quads to tri’s before it hits OgreMax? Try converting it in mudbox, then in Max...see if that helps at all.

Dean

Author: pyro777

Replied: 14 July 2009 03:28 AM  
avatar
  • Zuur
  • Posted: 14 July 2009 10:10 AM

I don’t think I can convert to tri’s in Mudbox because it seems to be designed as a quad-only editing tool (which is a large part of the problem), and as I understand it now the triangulation is actually happening in Max already.. If I triangulate in max and create the vertex normals there based on tri’s, I get the same problem showing in Max as we see in our ogre model at the moment.

I’ve got some good feedback from Derek here: http://www.ogremax.com/?q=node/496 (I think he’s the author of OgreMax, or at least very knowledgeable about it). Apparently the triangulation is coming from Max, but the vertex normals are being generated by OgreMax based on the smoothing groups, etc. OgreMax will respect any explicit normals set by Max when it exports, so in theory all that needs to happen is for us to generate explicit vertex normals for the smoothed quad-mesh before it gets triangulated and exported…

Apparently adding an “Edit Normals” modifier will create explicit *face* normals rather than *vertex* normals, so isn’t quite what we want.. Can anyone tell me how to create explicit vertex normals for the model based on the smoothed quad-mesh?



Replies: 0