Home Technical Talk

Editing vertex normals in Max, got scripts?

1
Hey folks,

Now that UDK started supporting custom vertex normals I'm struggling with the archaic Edit Normals modifier in Max and since Google fails me, I'm wondering if anyone has any nice tools or scripts to edit normals in Max in ways that are actually practical. Something like this script for Maya would be great!
http://migugi.net/mel/normalTools/

Specifically all I'm really interested in doing is this, as taken from the script above:
fig_fillet_3.png

(forcing the connected vertex normals of a certain face to redirect along the face normal)

Much love as always.

Replies

  • Bal
    Offline / Send Message
    Bal polycounter lvl 17
    Yeah, I'm interested in this for the same reasons, now that I can use edited vertex normals in UDK, I'm doing it all over the place.
    But yeah, Max really isn't so hot for working with them, not only is the Edit Normals modifier kind of shitty, but max tends to mess up the edited normals alot depending on what you do to your model (like attaching stuff, or making other changes to the model).

    The only script I have at the moment is one made by Zoffty (I can post it if someone is interested), it just averages the normals of your selected face when you run it, that works in many cases (in your example for instance Rasmus, it would work), but idealy it should align them to the face normal instead.
  • Ark
    Offline / Send Message
    Ark polycounter lvl 11
  • rasmus
    Bal: Cool, mind posting it?

    Ark: Thanks for the info - don't see exactly what I'm looking for but NormalThief looks useful.

    I have a feeling this would be a breeze to whip up for anyone versed in MaxScript... I can promise big wet internet kisses to any and all takers :P Can't believe there aren't better tools for doing these things tbh, sort of like the same lack of quality tools when it comes to vertex colors.
  • Bal
    Offline / Send Message
    Bal polycounter lvl 17
    Here's the one I have rasmus, as I said, it's only really useful in some specific situations.

    [code]
    macroScript AverageNormal category:"zOffTy Tools" tooltip:" AverageNormal " buttonText: "AverageNormal"(
    --===========================================================================================================================
    clearListener()
    disableSceneRedraw()
    ---array pour stoker la face selectionn
  • Eric Chadwick
    Here's a quicker version of the NormalThief script (copies normals from one object to another) http://www.polycount.com/forum/showthread.php?p=1178203#post1178203
    Doesn't do exactly what you want tho.

    The mig Normal Tools look great.
  • Eric Chadwick
    Bal wrote: »
    But yeah, Max really isn't so hot for working with them, not only is the Edit Normals modifier kind of shitty, but max tends to mess up the edited normals alot depending on what you do to your model (like attaching stuff, or making other changes to the model).

    I looked into this awhile back, here are the (hidden) rules I uncovered.
    http://wiki.polycount.com/wiki/VertexNormal#3ds_Max
  • Bal
    Offline / Send Message
    Bal polycounter lvl 17
    Cool, thanks Eric, I'd learnt most of this by trial and error, but never took the time to really try out what exactly works or doesn't work.
  • Eric Chadwick
    What's weird is they kind of fixed some of worser bits in 2010, but left the other problems in.
  • rasmus
    Hmm I'm stumped guys - can I implore someone out there to take a look at writing a quick script that does what my first post describes? It could be as simple as the script posted by Bal, anything would be really appreciated. By now a lot of people use UDK and MAX and the complete lack of adequate handling of vertex normals is making me a sad puppy... SyncView? Render? All you other wizards?

    Basically what I'm imagining is:

    1. Make a face selection.
    2. Run script.
    3. Vertices connected to the selected face have their normals realigned to this face normal.
    4. Happy puppyness.
  • Neox
    Offline / Send Message
    Neox veteran polycounter
    isn't select faces and avarage selected doing pretty much this?

    normals.jpg
  • Eric Chadwick
    I think it is, as long as you do it on one polygon at a time. The normals for the faces at the far left in your example don't seem to be pointing along their face normals.
  • SyncViewS
    Offline / Send Message
    SyncViewS polycounter lvl 13
    I'm on it, trying something simple to begin with, then add functionalities as needed. It will require an Edit Normals Modifier though. I'm starting with support for Editable Poly Object only, eventually extend to modifiers.

    I take that selected contiguous faces keep the normals averaged between their normals. It implies that on a multiple face selection only the selection border vertexes get their normals reoriented. Is it right?
  • Neox
    Offline / Send Message
    Neox veteran polycounter
    yeah a bit bad example as its curved in space, on a flat plane it will do the normal you want, otherwise you'll have to do it on a per face level
  • Bal
    Offline / Send Message
    Bal polycounter lvl 17
    Neox, no doing average just averages the normals, if the angles of the neighboring faces are different, the resulting vector won't always be perpendicular to the face (which is what we want).

    Idealy I'd like a script that takes all my selected faces one by one, and aligns the vertex normals so they are perpendicular to their face. Order doesn't really matter, as usually you'll always have either unselected faces between your selected one, or the faces are coplanar to begin with, so it's not an issue.
    Maybe a box with x -x y -y z -z buttons as presets for vertex normals could come in handy too.

    rasmus, did the script not work for you? It's not ideal but it still saves me some boring Edit Normals modifier work most of the time.
  • Eric Chadwick
    Bal wrote: »
    Idealy I'd like a script that takes all my selected faces one by one, and aligns the vertex normals so they are perpendicular to their face.
    Don't need a script for this really. Select your faces, add a Smooth modifier, collapse the stack, done.
  • SyncViewS
    Offline / Send Message
    SyncViewS polycounter lvl 13
    Hi guys, I put together a fast script that should do the trick, it should be like the migNormalTools "Fillet Outside".

    The script works on Editable Poly Objects only, and it must be the active object in the stack. If not present, the script adds an Edit Normals Modifier right above the base object. Just go into Face sub-object level, make a face selection and run the script.

    Get the script here, and find it under Category: Rasmus Tools, Set Normals (sorry, this evening I'm running out of fantasy).
  • Bal
    Offline / Send Message
    Bal polycounter lvl 17
    SyncViews, this is great! Exactly what I wanted, now I just need to set it up so it auto collapses the Edit Normals afterwards (I never need to keep it around). Thanks alot.
    Don't need a script for this really. Select your faces, add a Smooth modifier, collapse the stack, done.
    What? I didn't know about the smooth modifier, but I really don't see how it helps here... It just seems to be reassigning smoothing groups, it's not affecting the vertex normals at all?
  • SyncViewS
    Offline / Send Message
    SyncViewS polycounter lvl 13
    Hi Bal, I'm glad you like it. It is not super tested, so let me know about any issue.

    If you want to collapse the Edit Normal modifier, just substitute line 81:

    from
    modPanel.setCurrentObject theEditObj
    
    with
    maxOps.collapseNodeTo theNode theNode.modifiers.count true
    
  • Eric Chadwick
    Smoothing groups do in fact edit the vertex normals. But I think it's not what you want anyhow, since it breaks the vertex normals on the edge of the selection, instead of just bending them.
  • Bal
    Offline / Send Message
    Bal polycounter lvl 17
    Eric, yeah I think you misunderstood what I wanted (or I didn't explain it clearly enough :). Had me worried there, thought for a second there was a modifier already present in max to do what I wanted all along, heh.

    SyncViewS, works perfectly, you rock. Will tell you if I come across any problems.
  • rasmus
    Wow, now that's what I'm talking about! Works like a dream :) Thanks a million SyncView, you do indeed rock!

    puppy.jpg

    Bal: Yeah I did get the script running (thanks) but I don't really see the use for the "Average"-function - to me this should be the same as just uniting the smoothing groups *opens can of worms* ;)
  • zOffTy
    Offline / Send Message
    zOffTy polycounter lvl 16
    yeah!
    great tools
    works better than mine !! :)

    You can add a subobjectLevel = 4 to return in Face selection mod :p

    Thanks a lot ;) !
  • Bal
    Offline / Send Message
    Bal polycounter lvl 17
    Ok, found a bug, or at least something unwanted I think.
    If I apply the script on a face, that has a neighboring face on a separate smoothgroup, it's gonna edit the vertex normals of the neighboring face, aligning them with the ones from the selected faces, instead of just leaving them alone, fixable?
  • rasmus
    Bal: I think that's a matter of preference :) I'd have to test it some more, but from what I could see nothing happens to faces that don't share smoothing (unlike Maya, where editing normals naturally forces smoothing across the affected faces). What I'm saying is, I wish it did what you describe :) I had to set a common smoothing for the affected faces first, then run the script to see the effect (Max 2010 x64).
  • Bal
    Offline / Send Message
    Bal polycounter lvl 17
    Eh? Weird, I've tested it out in multiple cases, and it always changes the vertex normals of neighboring faces, even if they are in a different smooth group (so initially broken vertex normals). I'm using Max 2009, 32bit.

    I don't really see the advantage of it doing this, can't imagine a situation where I'd want to. If I have a face on a different smoothing group, it's that I want that hard edge to stay.
  • rasmus
    Sure - I don't really mind it this way or that, but a bit odd that we get differences. Oh well.
  • SyncViewS
    Offline / Send Message
    SyncViewS polycounter lvl 13
    Hi guys, Bal is right, before realigning normals, each vertex normals set is reset to one, so it does a sort of "unify" smoothing groups. I did it because it doesn't makes a lot of sense -just in my mind- to realign a splitted normal set, as it should already be perpendicular to the face normal. Anyway I already see a way to do that, it is only slightly longer to code. If you want it, just ask, I'll patch it as soon as possible.
  • Bal
    Offline / Send Message
    Bal polycounter lvl 17
    Yeah i definitely want it! I often have this kind of situation appear, where I have a neighboring face on a different smooth group, because of how I set up my modular normals.
    Maybe both commands could be present in the script? I'm surprised it's not doing the same thing for Rasmus, Zoffty tells me he has the same as me on max 2010 64bit.

    Thanks again!
  • rasmus
    Hehe, maybe I'm just delirious :) Like I said, I don't mind it either way - doing it your way Bal I suppose just means that smoothing groups have to be united manually before the script will have any visible changes, right? My line of thought was the same as SyncViews, but I'm easy - I guess your way won't be destructive for anyone.
  • Eric Chadwick
    Yeah, I would think if you have a hard edge, then you don't want the script to merge the edge normals (killing the hard edge), instead I would want just the selected faces' normals to be adjusted.
  • SyncViewS
    Offline / Send Message
    SyncViewS polycounter lvl 13
    Hi guys, here is a new script version. It is a completely different algorithm and should not mess with Smoothing Groups at all. Let me know if it works as is meant. Keep in mind that every time a normal is modified by the script, is made Explicit to retain the modifications. If you want to revert it back to the original status, geometry dependent, you need to do it manually by resetting it through an Edit Normals Modifier.
    You can simply download the script and overwrite the previous one. Enjoy :)
  • Bal
    Offline / Send Message
    Bal polycounter lvl 17
    Works great, does exactly what I want anyways. Will keep testing it to see if I see if I come across any other problems, but I've tried most of the possibilities I can think of and it always does what I want it to for now.
    Thanks again!
  • Eric Chadwick
  • SyncViewS
    Offline / Send Message
    SyncViewS polycounter lvl 13
    Hi Bal, that's good to hear. One of the differences of this new version is that it works on face selection border vertexes but doesn't reset the normals of the internal selection vertexes. Is it good, or is it better to reset inner vertexes selection normals?

    To make an example to be sure to make it clear. Imagine to have four faces selected in a 2x2 way. There are 8 vertexes on the perimeter and 1 inner vertex, shared by all faces. The current script set all normals along the perimeter but doesn't reset the inner one. Which means it would be averaged among all shared faces, or if there is a split in smoothing groups, each face normal would be realigned to its face normal.

    I couldn't really decide on this, but preferred to leave the inner vertexes unchanged to avoid "undoing" normals modifications inadvertently. Is it good as is right now, or need a change? It would be a matter of a couple of lines of code.

    Edit: Thanks Eric, but maybe it would be better to name this script in a more meaningful way before adding it to the wiki. I didn't put a reference in the code either. Since it could still change, maybe you could link the thread only.
  • rasmus
    I think this is where we come into multiple uses and you start seeing a need to expand it into a Vertex Normal Toolbox of some kind to allow the user to modify this on a case-by-case basis, but at the moment I'm happy with it changing every vertex connected to the selected faces - bordervert or not - and I can't really see the need to do anything else quite yet. Will keep testing and keep you posted.

    Again, thanks a million for spending the time on this, SyncView!
  • Bal
    Offline / Send Message
    Bal polycounter lvl 17
    Yeah, same as rasmus, by default I'd expect it to change all the vertex normals of the selected faces, would be more consistent I think.
    In practice though, I wouldn't notice the difference very often at all. When I have multiple neighboring faces selected like that, they are usually coplanar anyways, so one way or the other it wouldn't make a difference.

    As rasmus said, at this point maybe it'd be interesting to expand it to an UI, or multiple commands, but personally the function you've made is the only one I really need for now, so not sure if it'd be worth it (that and surprisingly enough, not many people seem to mess with vertex normals much, especially max users).
  • SyncViewS
    Offline / Send Message
    SyncViewS polycounter lvl 13
    Hi Rasmus, I'm glad you liked it, and you're right, a further development would see a small panel with preferences and different options. If I see interest I could go on with it.

    Here is the same second release with some more meaningful names and "signed" by me in the code.

    Category: Normal Tools
    Action: Get Vert Normals from Faces
  • rasmus
    Great :)

    Bal: Not many people touch it probably because up until today it was useless :P Now we only need someone to take a look at multiple UV channel editing and some decent vertex color tools and Max is without blemishes for UDK folks! *hint hint*
  • Eric Chadwick
    SyncViewS wrote: »
    Thanks Eric, but maybe it would be better to name this script in a more meaningful way before adding it to the wiki. I didn't put a reference in the code either. Since it could still change, maybe you could link the thread only.
    I updated the wiki everytime you made a change. Feel free to update the wiki too if you like, by getting a wiki account.
  • SyncViewS
    Offline / Send Message
    SyncViewS polycounter lvl 13
    Hi guys, I just updated the script a bit. It now sets every normal from vertexes in the face selection and makes them explicit. Previous version has some glitches related to normals ID change when made explicit. The script now always switches back to Base Object level and Face sub-object level as expected, even when other modifiers are stacked on top of it.

    Get the new version here.
  • Bal
    Offline / Send Message
    Bal polycounter lvl 17
    Cool, seems to work fine, now if only max didn't blow up the normals on most modifiers anyways. :)

    Thanksa again! (To Eric too, for taking care of the Wiki so well ;)
  • RexM
    Are there any comparable scripts for XSI?

    Trying to get better lighting for my vegetation... even though it's not bad right now, it would really help make the vegetation look way more natural further away when shadows are not hitting it.

    Working in Cryengine 2.

    Somehow, if a script could be made to make normals like this, vegetation would be perfectly lit.

    The examples in here explain:

    http://wypierpapier.blogspot.com/2010_02_01_archive.html
  • 16bit
    Offline / Send Message
    16bit polycounter lvl 13
    Can I get some help with this script? I'm using 2012 and I select the polygons whose normals I want to change, and run the script but nothing happens? I'm a little confused on how to get it to work.
  • Trevelyan .
    Offline / Send Message
    Trevelyan . polycounter lvl 11
    Also trying to use the script, selecting the faces, running the script...nothing happens? Any help would be great as I've just switched studios and have gone from maya to max and am struggling a little with the functionality. Thanks all
  • SyncViewS
    Offline / Send Message
    SyncViewS polycounter lvl 13
    Hi Trevelyan,
    what version of 3ds Max are you on?

    The script works on Editable Polygons only, make sure you are not trying to run it on Editable Meshes, otherwise it won't do anything.

    To make a quick test: create a sphere, convert it to Editable Poly, select any face close to the equator (it is easier to spot the effect) and run the script. You should see a difference in the surface smoothing.

    To double check if it worked, apply an Edit Normals modifier. If the script worked you should see the face affected with green normals, rather than blue, exactly perpendicular to it.
  • kurt_hectic
    Offline / Send Message
    kurt_hectic polycounter lvl 10
    Bump!

    I've test it out and it works! But I had to spend some time to find out that before I use the script I have to set one smooting group to the mesh/part I'm working on (on stairs it's good to seet one SG to one stair). After that I can select face by face and hit shortcut with the script. It's awesome! Thanks!

    http://dl.dropbox.com/u/1397854/polycount/stash/SetNormals_02.zip

    AdtH8Sw.png
  • Eric Chadwick
    Hey kurt_hectic, thanks for sharing this!

    I couldn't get it to work though. Could you give me a step-by-step how to use it?

    1. Make an Editable Poly model, with a bevel.
    2. Select one of the polygons on one side of the bevel.
    3. Assign it a smoothing group.
    4. Run the script.

    Nothing happens? Tried in Max 2015, and in Max 2012.
  • kurt_hectic
    Offline / Send Message
    kurt_hectic polycounter lvl 10
    AD.2,3- Assign one smoothing group to the whole mesh or piece like one step, after that select a face or a group of faces (like the whole side of long stair) and use the script. Select the other side/ the other face and use script again ect.

    I had to make break/hard concave between steps, right? I did it by assigning different smoothing groups on each step.

    And before whole thing, go to edit normals, select all normals and hit reset, collapse to editable poly.

    Currently I'm working on 20 meshes with steps and this technique helped me a lot, a huge time saver.
  • Eric Chadwick
    Hmm, still doesn't work for me.

    1. Add an Edit Normals modifier, select all normals, Reset, Collapse the stack.
    2. Select all the faces, apply Smoothing Group 1.
    3. Select the top face, run the script.
    4. Select the bottom face, run the script.

    Nothing happens?

    Here's the file (3ds Max 2015 format)
    http://www.ericchadwick.com/examples/images/SetNormals_Stair_Max2015.max

    SetNormals_Stair_Max2015.png
  • kurt_hectic
    Offline / Send Message
    kurt_hectic polycounter lvl 10
    Can you see how Edit Normals mod. is being added and after 0,1 sec collapsed by the script? Or nothing?

    I have only max 2014:

    jZsVITA.png
1
Sign In or Register to comment.