Home Technical Talk

Face weighted normals

1
Scruples
polycounter lvl 10
Offline / Send Message
Scruples polycounter lvl 10
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 10
    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 Polycount Sponsor
    well, this looks pretty cool. Is there a plugin or anything that does this?
  • cptSwing
    Offline / Send Message
    cptSwing polycounter lvl 10
    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 10
    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 Polycount Sponsor
    Yes, "Set to Face" in maya is the vertex normal equivalent of setting edges to "hard".
  • Scruples
    Offline / Send Message
    Scruples polycounter lvl 10
    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 10
    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 10
    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 polycounter lvl 8
    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 polycounter lvl 8
    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
    Offline / Send Message
    kodde polycounter lvl 16
    This looks mighty interesting.
  • kodde
    Offline / Send Message
    kodde polycounter lvl 16
    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 16
    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 10
    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 polycounter lvl 8
    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
    Offline / Send Message
    rebb polycounter lvl 12
    It's a new option in the "Mesh Controls" tab of the shape node.
  • dirigible
    Offline / Send Message
    dirigible polycounter lvl 8
    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 16
    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 polycounter lvl 8
    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
    Offline / Send Message
    JohnnyRaptor polycounter lvl 13
    Some nice stuff Scruples! thanks for sharing,

    Anyone got a script for us stoneage ppl still using Maya 2011?
  • dirigible
    Offline / Send Message
    dirigible polycounter lvl 8
    @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.
  • 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.
  • Scruples
    Offline / Send Message
    Scruples polycounter lvl 10
    @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 16
    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.
  • dirigible
    Offline / Send Message
    dirigible polycounter lvl 8
    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.
  • Scruples
    Offline / Send Message
    Scruples polycounter lvl 10
    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 polycounter lvl 8
    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 polycounter lvl 8
    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 10
    Ironically in this situation I probably would have just beveled the edge or made it a hardedge/UV seam, :P.
  • Scruples
    Offline / Send Message
    Scruples polycounter lvl 10
    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 Polycount Sponsor
    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.
  • 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 10
    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 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.

    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 10
    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
    Offline / Send Message
    OtrickP polycounter lvl 9
    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 10
    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 10
    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..
  • Michael Knubben
    cptSwing wrote: »
    if it looks good

    I just find that relying on things like that is setting yourself up for failure. You may get away with it once or twice, but having an arsenal of tricks that work depending on far too many factors out of your control, is just ridiculous when a proper solution isn't unattainable.
    You create an asset with the normalmap baking in mind every step of the way, you set up the uv's a certain way etc... so when you go in expecting to rely on tricks like that and they fail you, that's lost work. I so far haven't ever seen a need to reach for the dirty tricks since properly learning what normalmaps do and what you can do to alleviate common issues, which was all thanks to Polycount.
  • cptSwing
    Offline / Send Message
    cptSwing polycounter lvl 10
    I don't fully understand it I'm afraid - what's the 'dirty trick' here, relying on edited face normals or relying on the ol' "if it looks good.." saying? And what do the former have to do with UV's?

    That said, I personally don't hand-edit normals on normal-mapped assets either, it's a hassle and I'm afraid of losing the edits somewhere down the pipeline..
    I have used it on lowpoly-only models though, as per this method: http://www.polycount.com/forum/showthread.php?t=66139&highlight=superspecular
  • EarthQuake
    cptSwing wrote: »
    I don't fully understand it I'm afraid - what's the 'dirty trick' here, relying on edited face normals or relying on the ol' "if it looks good.." saying? And what do the former have to do with UV's?

    I think you answered your own question. :poly124:
    That said, I personally don't hand-edit normals on normal-mapped assets either, it's a hassle and I'm afraid of losing the edits somewhere down the pipeline..
  • dirigible
    Offline / Send Message
    dirigible polycounter lvl 8
    MightyPea wrote: »
    You create an asset with the normalmap baking in mind every step of the way, you set up the uv's a certain way etc... so when you go in expecting to rely on tricks like that and they fail you, that's lost work.

    I can't tell if I agree or disagree with you, since I'm not sure what kind of tricks you're talking about.

    For instance "partial mirroring". Like if I had a person with a hole in one side of their shirt, but the rest of the shirt could be symmetrical. As long as I sculpt, model, and uv everything correctly I can wind up mirroring the entire shirt, minus the one area that should have a hole in it. I can apply the same technique to get patches of asymmetry wherever I want on an otherwise symmetrical model, without wasting a ton of UV space.

    Is that a trick? If so it's a useful, reliable trick. I wouldn't use it every time, but that doesn't mean I should never use it.

    I don't think the answer is "don't use tricks". I think the answer is "know which tricks are reliable and which aren't and use them accordingly". If you go in using unreliable tricks, you gotta be prepared to get burned.
  • monster
    Offline / Send Message
    monster Polycount Sponsor
    And back to the topic...

    In my case (no normal maps, and extremely low poly models) this is a fantastic solution.

    In the end the vertex count is what matters to me (I'm a technical artist after all). Using Face Weighted Normals and UV Seams from Smoothing Groups I can lower the vertex count and get nearly the same visual as using Smoothing groups.

    For the object below I can even raise the poly count while lowering the vertex count!
    This is a screenshot taken from Unity. The descriptions show the steps I took from top to bottom.

    Clipboard-2.png

    Unfortunately, I won't be releasing my script, but the one posted by Scruples works well enough. It doesn't do angle calculations, but it does get the poly area which achieves the same affect with quads.
  • Brendan
    Offline / Send Message
    Brendan polycounter lvl 8
    I know this isn't specifically about FWN, but for 'manual' adjustments, is it possible to completely destroy the normal influence of faces?

    For this example, the beveled faces have no influence on normals, instead taking their normals from surrounding faces. This results in some sweet arse highlights. The only way I could do this was by selecging everything though, otherwise the areas I didn't select would mess up (also SSAO is on, so the darker patches on the large faces are there for that reason)
    normals.png

    What I want is a button that does this:
    bevels.png
    In that I'd select the newly beveled face on the right (BEVEL and an arrow pointed to it), then press one button, then get some more of the damn nice bevels.

    I'm using Maya 2012, is there a way to do this already that I haven't noticed, or would I need to script something?
  • dirigible
    Offline / Send Message
    dirigible polycounter lvl 8
    You would need a script. Maya's normal editing tools are fairly lacking. The best you could do with built in tools is select the vertex normals and swivel them to point the direction you want, manually.
  • passerby
    Offline / Send Message
    passerby polycounter lvl 10
    here is my quickie solution to doing this in maya 2012.
    global proc pbFacetoVertNRM() {
    
    
        string $Fs[] = `filterExpand -sm 34`;
        select -cl;
        for ($F in $Fs) {
            select -r $F;
            string $normals[] = `polyInfo -faceNormals`;
            string $buffer[];
            tokenize $normals[0] $buffer;
            
            float $plane[3];
            $plane[0] = $buffer[2];
            $plane[1] = $buffer[3];
            $plane[2] = $buffer[4];  
            PolySelectConvert 3;
            polyNormalPerVertex -xyz $plane[0] $plane[1] $plane[2];
            }
    }
    
    pbFacetoVertNRM();
    

    it works on a selection of multiple faces, and sets the vertex normals for all the verts making up that face to be the same as the face.

    kinda like set to face in maya but it doesn't cause a smoothing split, it just works with the existing verts and normals with out creating new ones.

    i more or less just select a bunch of big faces and run this.
  • dirigible
    Offline / Send Message
    dirigible polycounter lvl 8
    Great stuff, passerby! That's actually a super useful script.

    I really need to learn mel, some day.
1
Sign In or Register to comment.