Face weighted normals

1
Scruples
polycounter lvl 6
Offline / Send Message
Scruples polycounter lvl 6
Discuss face weighted normals. (or FWN for short)

Oftentimes I wonder why certain features are left out of the major 3d packages, and usually I will figure out why it was ignored.
But this time I am having a hard time understanding why no-one uses face weighted normals, it isn't something terribly new ID has
been using it since doom3. Still I have yet to see even a third party script for any package dealing with face weighted normals.

[example below created in Openbrf]
I realize it is possible to edit normals manually and get an even better result than this, but it only took two minutes to do and there is nothing to prevent me to continue tweaking the normals. It also benefits normal maps, by making them do less work because the vertex normals match the hi-poly normals much closer, and the sampling rays are fired at a more orthogonal direction.

[link explaining technique in depth]
http://www.bytehazard.com/code/vertnorm.html

Also...a bit off topic, Why isn't there any programs that offer a physics simulation for UV packing?, it just seems like the most logical next step...ten years ago. *grump face*

Thanks for reading!.

!!!Edit Nov-02-12: We now have a script for 3ds Max that can calculate FWN created by Lehm2000 of the Cgtalk forums http://polycount.com/discussion/comment/1690226/#Comment_1690226, and now Maya 2013 calculates normals using Face and Angle Weighted by default, this can be toggled in the shape node under >Mesh Controls

nromalsjpg

Replies

  • Scruples
    Offline / Send Message
    Scruples polycounter lvl 6
    bump...lol

    Actually since Maya 2012 I believe this has been added in the Normals>Set to Face just check the Match Face Normal option box when doing so.

    Now, is there any way of doing the same thing in 3ds?.
  • Bruno Afonseca
    Offline / Send Message
    Bruno Afonseca polycounter lvl 9
    well, this looks pretty cool. Is there a plugin or anything that does this?
  • cptSwing
    Offline / Send Message
    cptSwing polycounter lvl 5
    There are a couple of scripts for Max to do this as well (I use an old one by SyncViewS LINK )
  • monster
    Offline / Send Message
    monster Polycount Sponsor
    Have you tested this in a game engine like Unreal or Unity?

    The face weighted model certainly looks better.
  • Scruples
    Offline / Send Message
    Scruples polycounter lvl 6
    Yes, tested in UDK on a door prop and a little birdy told me that Maya 2013 uses face weighted vertex normals always by default (I can't find any online documentation to confirm it but my friend is adamant it does).

    And I am told that having a vertex normal set to face is actually quite different than 'face weighted' normals...confusing.
  • throttlekitty
    Offline / Send Message
    throttlekitty polycounter lvl 8
    Yes, "Set to Face" in maya is the vertex normal equivalent of setting edges to "hard".
  • Scruples
    Offline / Send Message
    Scruples polycounter lvl 6
    The faces becoming hard edged is just a side effect of all the vertex normals being re-evaluated, there is already a tool in Maya for controlling smoothing.
  • Scruples
    Offline / Send Message
    Scruples polycounter lvl 6
    What I meant with my above post is that both, Maya's 20xx-2012's set to faces with Match Face Normal checked and SyncViewS's script is not the same thing as having "Face Weighted" normals. I have been a little confused as to what the differences were up until now and will make a quick demo to show the differences and maybe generate some interest.
  • Scruples
    Offline / Send Message
    Scruples polycounter lvl 6
    Ok, here it is, I exaggerated the effect by not allowing any hard-edges for the experiment/demo, SyncViewS's script took about 3 minutes extra time because you need to manually select area's you want to flatten and push the shading errors into the nearby (hopefully smaller) polygons.
    XWjqf.png
  • dirigible
    Offline / Send Message
    dirigible keyframe
    So correct me if I'm wrong, but it seems like this technique basically gives larger faces preferential treatment when averaging normals. So larger faces' normals will be closer to how they would be if the normals were hardened. Conversely, smaller faces normals get distorted more. Am I right?

    Seems like a useful technique. I've done something like this manually, upon a time, but since maya's normal-editing tools are complete and utter balls, I never considered it a viable technique. If there's actually scripts and tools to do it with, could be pretty great.
  • EarthQuake
    dirigible wrote: »
    So larger faces' normals will be closer to how they would be if the normals were hardened. Conversely, smaller faces normals get distorted more. Am I right?


    I think so, yes. Actually I believe Doom3 had an option to do something like this all the way back in 2004 too.
  • dirigible
    Offline / Send Message
    dirigible keyframe
    Yeah reading the link in the original post, that's exactly what it does. Literally multiply vertex normal contribution by surface area of the face it belongs to.

    If anyone knows of a maya script / plugin that could do this, I would be eternally grateful.
  • kodde
  • kodde
    Offline / Send Message
    kodde polycounter lvl 12
    From what I can tell this seems to be the default behavior for vertex normals in Maya 2013. In prior versions does not seem to have this.
  • kodde
    Offline / Send Message
    kodde polycounter lvl 12
    I actually almost finished a script for doing this in Maya and then realized that this functionality already exists in 2013. Could still be useful in 2012 and older. It still has a king that needs fixing and it's really slow (40sec for 10k tris) so I'm not sure I'll bother releasing it. Learned a couple of things by writing this script though.
  • Scruples
    Offline / Send Message
    Scruples polycounter lvl 6
    Make one for 3ds!, I'll pay good money for a modifier version. I've been passing most of my models through OpenBRF to get them face weighted, but it would be nice to see it update in the viewport as I am modeling...Maybe I can convince Marius.
  • dirigible
    Offline / Send Message
    dirigible keyframe
    kodde wrote: »
    From what I can tell this seems to be the default behavior for vertex normals in Maya 2013. In prior versions does not seem to have this.

    Could you elaborate a little bit? I just downloaded maya 2013, and it doesn't seem to function any different from previous versions.
    EDIT: Checked the 'what's new' for maya2013, doesn't mention anything about normals.
  • rebb
    It's a new option in the "Mesh Controls" tab of the shape node.
  • dirigible
    Offline / Send Message
    dirigible keyframe
    rebb wrote: »
    It's a new option in the "Mesh Controls" tab of the shape node.

    Great, thanks!
    Autodesk - add a great new tool for editing normal maps, but don't put it in the normal map menu, and don't mention it in your what's new pdf. Brilliant.

    I've never really used the shape node attributes before, but it looks like there's some useful stuff in here.
  • kodde
    Offline / Send Message
    kodde polycounter lvl 12
    rebb wrote: »
    It's a new option in the "Mesh Controls" tab of the shape node.

    Oh Is that how it works. Thanks for sharing. Is this option in older versions as well?
  • dirigible
    Offline / Send Message
    dirigible keyframe
    kodde wrote: »
    Oh Is that how it works. Thanks for sharing. Is this option in older versions as well?

    Nope. Or if it is, it's hidden somewhere else.
  • JohnnyRaptor
    Online / Send Message
    JohnnyRaptor polycounter lvl 8
    Some nice stuff Scruples! thanks for sharing,

    Anyone got a script for us stoneage ppl still using Maya 2011?
  • perna
    Offline / Send Message
    perna polycounter lvl 12
    This, and several other vertex-normal tricks, have been around for a very long time. I've played with this a good deal myself.

    The issue is that when you already bake normals CORRECTLY (big big caps - this is the important part), the benefits gained from the vertex tweak methods are typically not worth building a toolset around, and not worth the potential pipeline issues (moving data between apps and into the game engine).

    First people need to bake correctly, which even many of the AAA studios don't do. We keep working with big-name studios that are not even aware that different apps create different normals maps, for example.

    When you look at the "barf" example above, it's not actually barf at all. You can't go by whether the shading looks "pretty", you've got to go by the actual normals, which are fine (just needs smoothing groups). Just enable normals view with an edit normals modifier.
  • perna
    Offline / Send Message
    perna polycounter lvl 12
    oh, just to add more of my findings from playing with this:

    The greatest benefit I found from these techniques had little to do with "shading quality", but using vertex normals to control the cage projection. Even that was just in special cases, though.

    Especially now as we move onto console next-gen, these kind of tools lose their relevance, as you can simple add a few more triangles to clean up trouble areas, which is a safe solution that works across all apps and toolsets, and can also contribute to the actual shape of the object.

    So just ask yourself; when you have a triangle spike that causes harsh normals change, is that worth building a whole toolset, workflow and pipeline around? Or is that simply mad overkill when you can just add a few more triangles instead?
  • dirigible
    Offline / Send Message
    dirigible keyframe
    @perna
    I think there are still major advantages to using FW Normals, some of which are covered in this thread.
    Earthquake goes over the advantages of reducing normal map gradation (which fw normals would do, at least on larger faces where any artifacting would be more noticeable).

    I agree that there's an inherent cost to adding more information that must be transferred through the pipeline, but this method doesn't really add anything. Vertex normals are already part of the pipeline - using a face weighted algorithm simply gives better results.
  • perna
    Offline / Send Message
    perna polycounter lvl 12
    dirigible wrote: »
    @perna
    I think there are still major advantages to using FW Normals, some of which are covered in this thread.


    That thread does not speak of advantages of FWN. That's not what EQ is talking about. He's actually showing how you can get perfect results entirely without it.

    You are just pushing your view, without actually addressing any of my points, which speaks towards your agenda. You also have no experience using this workflow, which I have plenty of, so I suggest thinking things through a bit more before you jump on a gimmicky bandwagon and talk about "major advantages" without having any way of backing up such claims.
    dirigible wrote: »
    Vertex normals are already part of the pipeline
    "The" pipeline that all studios, all engines, and all 3d apps use, correct?


    Well, I don't really have much more to add to this topic. Maybe someone else can elaborate on my points and explain them for those who don't understand or are just blinded by "pretty pictures" in this thread and don't really know the technical details behind it all and how it would relate to a real production environment.
  • EarthQuake
    Yes well sort of yes and no. Dirigible's point that I've talked about reducing gradiation in normal map content, and this sort of does the same thing is right.

    But Per's point of "Studios need to bake correctly in the first place" really trumps it. As well as the various workflow disadvantages he's brought up.
  • perna
    Offline / Send Message
    perna polycounter lvl 12
    to clear up what I said, as I realize it may be taken the wrong way: Face weighting is very cool. That's why I enjoyed using it and learning about it in the first place. It would be better if all apps, tools, and pipes supported it as standard. That's just not the case, and trying to enforce this late in the game leads to all sorts of headaches.

    The simple case remains: There are only very few areas where harsh normal change will be an issue, and those problems can be fixed by adding a few more verts, which in current-gen is zero-cost, and by far the best solution as it doesn't require any extra data.

    In 3ds, you can make a modifier to give you the normals, in case your existing pipeline supports the explicit normal exports. That's fine. Just, it's not going to suddenly make your normal maps look amazing or anything. The change won't be as dramatic as you may imagine. So you need to justify spending the time writing the tools, and remember that this technique has been around for ages, and still no-one has made such a modifier.
  • Scruples
    Offline / Send Message
    Scruples polycounter lvl 6
    @Perna You make it sound like using face weighted normals shouldn't be as easy as ticking a box, if anything adding a "few more triangles" (which is about 300 triangles or 13% more in the case of my stormtrooper model) takes even longer.

    @Earthquake your examples showing perfect normals is also without using compressed textures so it is a little misleading, and if you think the next generation of consoles won't use block compression you have another thing coming. The reduced gradients on FWN will reduce compression artifacts which become even more visible at angles and with mip-mapping.

    Finally, games that don't use normal maps at all are still quite common.
  • EarthQuake
    Scruples: please take the time to read that thread, not just look at the pictures. I explained that exact issue to great detail.
  • kodde
    Offline / Send Message
    kodde polycounter lvl 12
    This is still new to me. But I love to learn new things and get more knowledge about what I work with.

    I agree with this probably not being a major thing in production. But if I can get this for free at no real extra cost of time simply by knowing about this functionality and enabling it I'll use it. Like you said perna, if all software would have this by default it would be sweet. Maya 2013 seems to have taken this step as far as I can tell.
  • perna
    Offline / Send Message
    perna polycounter lvl 12
    Scruples wrote: »
    @Perna You make it sound like using face weighted normals shouldn't be as easy as ticking a box, if anything adding a "few more triangles" (which is about 300 triangles or 13% more in the case of my stormtrooper model) takes even longer.

    I'm not sure what you are saying. Did you read all my posts? I feel I make my stance extremely clear and I don't see how your follow-up fits into it.

    If you feel adding projection-correcting verts to your stormtrooper model results in a significant slowdown for you, you would clearly benefit from improving your poly-modeling workflow. Your "regular normals" screenshot is not an ideally constructed model with regards to baking normal maps, to put it like that. If you are going to make the case against "regular normals", you should make sure that the example mesh has perfect regular normals, or it's a biased comparison.

    Again it comes down to this point: First learn to make proper normals maps with the existing workflow, and then if you have a FWN script/tool that fits into your pipe, there's absolutely no reason not to use it.

    FWN isn't going to save you if your modeling/normal mapping skills suck.
  • dirigible
    Offline / Send Message
    dirigible keyframe
    Woah, man, sorry. Didn't mean to piss you off.
    I linked to that thread because it discusses the advantages of having less gradienting in your normal map. Using face weighted normals wouldn't lower the gradienting OVERALL, but it would shift it to smaller faces, where the artifacting that Earthquake talks about in his later posts would be less noticeable.

    Sorry if it seemed like I wasn't addressing any points you made. I was just now typing up a big long explanation of what I meant, and making a quick bake / demo - but I refreshed this page, and a lot of stuff has already been said.

    As for the bake / demo, I figure I'll summarize the results I got. They key thing about this technique is that it doesn't make all faces look better. It makes large faces look better and small faces look worse. The trouble I had with setting up a good example bake, is that baking correctly really does give quite good results, even using default vertex normals. So I changed the geometry into a shape that emphasizes errors with traditional averaged normals. The problem is that while this made the large faces look better - it didn't look THAT much better. And the small faces looked MUCH worse. I'm still toying around with it, but it's clear to me that this isn't a technique you want to use in every circumstance, for sure.
  • perna
    Offline / Send Message
    perna polycounter lvl 12
    dirigible wrote: »
    Woah, man, sorry. Didn't mean to piss you off.

    Nono, absolutely not. If there was such a tone, sorry, it must have come from the frustration associated with these kind of topics that pop up regularly where people jump on some bandwagon because of a couple of nice looking pictures.

    I appreciate the rest of your post, it's well balanced and echoes some of the conclusions I came to regarding this technique earlier. Basically: It can definitely be good. Are the real-world effects really significant, and worth it? In my experience, no, it's kind of underwhelming.
  • Scruples
    Offline / Send Message
    Scruples polycounter lvl 6
    The model I used for the demo was created in an rts engine which would be displaying possibly hundreds of the same models, it doesn't support normal maps and I was already over the vertex budget, 300 triangles can very quickly become 30,000 triangles which is quite significant when they are all deforming.

    I did read your posts/thread Perna, Earthquake.

    Earthquake actually did mention compression artifacts in the thread (I redact what I said about it being misleading earlier), and while I don't think he said the models/normal maps were perfect at any point, they do look damn near. My problem was when Perna claimed they were perfect and therefore no discernable improvement to be made by FWN. My argument is that when block compression is applied over his perfect normals, they will no longer be perfect and FWN can result in an improvement, they might even be usable on a lower lod.

    When you are really pushing whatever platform you are on, you can't just add some so called "zero-cost verts" that somehow "don't require any extra data". Any extra verts you have would probably best be used describing the form instead of fixing shading errors.
  • dirigible
    Offline / Send Message
    dirigible keyframe
    perna wrote: »
    Nono, absolutely not. If there was such a tone, sorry, it must have come from the frustration associated with these kind of topics that pop up regularly where people jump on some bandwagon because of a couple of nice looking pictures.

    I appreciate the rest of your post, it's well balanced and echoes some of the conclusions I came to regarding this technique earlier. Basically: It can definitely be good. Are the real-world effects really significant, and worth it? In my experience, no, it's kind of underwhelming.

    Aight, I understand. I guess a lot of people, including myself, are at a stage where we're optimistic / naive enough to think that anything can be the new holy grail of modeling.

    So here's a test that shows off the strengths of face-weighted normals.
    kSZpb.jpg

    Some things to note - exporting the fbx from maya2013 gave TERRIBLE looking results in udk. Possibly because I am using an old (march 2012) build of UDK. Had to import the fbx to maya 2012, then re-export for udk. Doing that created some odd seams on the edges of both tiles, but otherwise the results looked much more correct. I am pretty sure I could have gotten rid of the seams by unlocking normals in maya2012, but then I would have lost the face-weighted normals from 2013. So yeah.
    I baked both of these - as far as I am aware - with optimum settings. Both triangulated, both using a cage with softened normals, both with UV-seams hardened, etc. If you want me to post more info about the test, I'll be happy to.

    CONCLUSION:
    Using Face weighted normals can give noticeably better results in some circumstances, and noticeably worse results in other circumstances. Given the problems I had going back and forth between versions of maya, I can't see myself using this very often YET. At least until I can iron out the issues with 2013 fbx. Even without pipeline issues (Like Perna mentioned), I would need some way of gauging when using it would help, and when it would hurt. I >think< that a decent rule of thumb is 'if your model has small faces that are highly visible, and are at extreme angles to large faces, then it's worse to use face-weighted normals'. There might be additional factors I haven't considered.
  • dirigible
    Offline / Send Message
    dirigible keyframe
    ADDENDUM:
    I fixed the issue with exporting from 2013, it's just that some of my checkboxes were checked when they shouldn't be, or unchecked when they should be. So that's not really an issue.

    The results from a top view look the same as the image I posted (face-weighted normals have less shading errors). Here's another screenshot to demonstrate the cost of using FWNormals. The smaller edge faces - as expected - have much worse shading.
    y9JPF.png
  • Scruples
    Offline / Send Message
    Scruples polycounter lvl 6
    Ironically in this situation I probably would have just beveled the edge or made it a hardedge/UV seam, :P.
  • perna
    Offline / Send Message
    perna polycounter lvl 12
    Scruples wrote: »
    The model I used for the demo was created in an rts engine which would be displaying possibly hundreds of the same models, it doesn't support normal maps and I was already over the vertex budget, 300 triangles can very quickly become 30,000 triangles which is quite significant when they are all deforming.

    Not to attack you 3D skills, so please don't take this the wrong way, but you do use your model as an example: That model is inefficiently optimized for the use you describe, and your estimate of 300 is quite extreme, again indicating less than optimal modeling practices. That particular mesh is not useful as an example. Using it to make any points regarding FWN just doesn't work very well.
  • Scruples
    Offline / Send Message
    Scruples polycounter lvl 6
    And I thought we had something Perna ;(
    perna wrote: »
    I just fell in love a little

    I definitely underestimated how much I could get away with using only a diffuse texture, and I did go way over budget for what the model was intended for, but every single vertex is either being used to describe the form or allow for decent deformation, in an of itself it can't be called badly optimised.

    88iTo.png
  • throttlekitty
    Offline / Send Message
    throttlekitty polycounter lvl 8
    dirigible, can you show a screenshot of that FWN box there with vertex normals visible? It looks more like it split them with a bit of weighting rather than weighing more towards the top face. Not sure about the bottom side with that darker shading.
  • perna
    Offline / Send Message
    perna polycounter lvl 12
    Scruples: if you look at what I said: "That model is inefficiently optimized for the use you describe". 100s of copies of it on screen. You'd use LODs instead, or gogo for extreme optimization, remove the boxes on the stomach, let some of the parts flow together which do not, use less polies for the bit above the knee, all these kind of things, if polygon count was of uber-critical importance, the way it's presented.

    The initial FWN/Regular normals image has clear bias, whether intentional or not. The bit about "RTS without normal maps and 100s on screen" was mentioned much later. In a more typical context, the "regular" image would look a great deal better, as it would use hard edges.

    You opened the topic with normal maps in mind, which was discussed, and is the only case that I commented on and intend commenting on beyond saying that of course assets without normal maps can benefit greatly from tweaking vertex normals.
  • perna
  • monster
    Offline / Send Message
    monster Polycount Sponsor
    Thanks for bringing his to my attention. At Robot we are starting a new project. Most assets will probably not be normal mapped. I think we can benefit from this method.

    Our engine supports vertex normals. Everything will be very low poly. We won't have to use smoothing groups as much, so we'll avoid the extra vertex overhead.

    I created a maxscript that does face weighted normals. It also uses the angle between the faces as outlined in the byte hazzard's link. Unfortunately, I created the script at work so I'll need to get approval before posting it online. Maybe Monday?

    fwn.png
  • Scruples
    Offline / Send Message
    Scruples polycounter lvl 6
    Sweet, how fast is it?, this is abnormal but...I can't wait for Monday to roll around.

    Perna, you actually made me google "gogo 3d" as I was convinced it was some sort of optimizing program I had never heard of.
  • dirigible
    Offline / Send Message
    dirigible keyframe
    dirigible, can you show a screenshot of that FWN box there with vertex normals visible? It looks more like it split them with a bit of weighting rather than weighing more towards the top face. Not sure about the bottom side with that darker shading.

    Here you go.
    y703K.png
    The top vertex normals are all welded, and simply weighted upwards. The bottom vertex normals were split (on both models), since I had a UV seam there anyway.

    It does look like it has hardened normals. That's just how much of an effect fwNormals can have.
  • Scruples
    Offline / Send Message
    Scruples polycounter lvl 6
    Amisima pointed out this script for 3ds that a member of Cgtalk Lehm2000 posted a few months ago in this thread. Your mesh has to either be an editable poly or have an edit poly modifier as the last stack.

    addModifier $ (Edit_Normals ()) ui:on

    numNorms = $.Edit_Normals.GetNumNormals()
    numFaces = $.Edit_Normals.GetNumFaces()

    normalArray = #() --place to store temp info for each normal.

    --fill in normalArray with junk data.
    for i = 1 to numNorms do
    (
    append normalArray [0,0,0]
    )

    -- iterate through all the faces in the mesh. find out which normals belond to this face and then add the weighted value of the face normal to value already in normalArray
    for i = 1 to numFaces do
    (
    curFace = #{i}

    connectedNormals = #{}
    $.Edit_Normals.ConvertFaceSelection curFace connectedNormals --should now have a bit array of normals connected to current face.
    faceNormal = ( in coordsys local polyop.getFaceNormal $ i) * (polyop.getFaceArea $ i) --getweighted normal for current face.
    for j in connectedNormals do
    (

    normalArray[j] = normalArray[j]+faceNormal --add current face value to it.

    )


    )

    --normalize values in normaArray and apply to mesh.
    for i = 1 to numNorms do
    (
    $.Edit_Normals.SetNormalExplicit i
    normalArray = normalize normalArray
    in coordsys local $.Edit_Normals.SetNormal i normalArray
    )
  • OtrickP
    As someone who hasn't been baking quite optimally, working with hard edges and is now trying to get the most of the the present work without having to spend more hours remodeling, baking and texturing. The script proved to be a nice little way to get some cleaner shading information even out of the existing, poorly baked normal map. (I only say poor because it probably took far to long to get the right settings, and I feel if I went in the direction of using proper hard edges and uv seam/islands) It would have turned out even more nice (model + textures are still incomplete)

    IxvHw.jpg
  • Scruples
    Offline / Send Message
    Scruples polycounter lvl 6
    I wouldn't bother with FWN if I had an object with a baked normal map already, because I expect it would create more shading errors than it would have fixed. Unless... you created your normal map solely in NDO or any other method that doesn't involve baking from a high-poly, then should be no problems.

    In this case it looks like the turret and front glacis are more true to form but it created some strange looking shading on the upper left sonic cannon thing. So whether or not it is better is really subjective. *shrug*
  • cptSwing
    Offline / Send Message
    cptSwing polycounter lvl 5
    Yeah, usually changing vertex normals after baking your map is a bad idea, since a normal map takes them into account (so deleting edges for example, or changing normal orientation wouldn't be cool).

    But as always - if it looks good and you / your client are happy..
1
Sign In or Register to comment.