Home Technical Talk

corner vertex baking - maya mel/python

1
polycounter lvl 12
Offline / Send Message
bugo polycounter lvl 12
I saw this somewhere and I was wondering if someone knows the same script for maya. Would be really appreciated.
http://www.neilblevins.com/cg_education/vertex_map_wear/vertex_map_wear.htm

This would do the darkening of the edges by angle or convexity of the mesh.
Probably we can call it as a convexity map as Xnormal does? But I would like to know if anyone knows a script of this for maya?

Replies

  • bugo
    Offline / Send Message
    bugo polycounter lvl 12
  • r_fletch_r
    Offline / Send Message
    r_fletch_r polycounter lvl 9
    Just pulling this out of my head (i read the script a while ago) but someone with even limited MEL should be up to writing this

    *per edge in the mesh get its connected faces
    *find the angle between the faces. acos(faceNormal_1•faceNormal_2)
    *if the angle is between a low and high value then collect the edges verts

    once you've processed all the edges colour the verts
  • MoP
    Offline / Send Message
    MoP polycounter lvl 14
    I might give this a shot tonight. Seems like something I'd use too :)

    Ideally I'd like to do a full surface-curvature to vertex color script, but that'd probably be intensely slow in MEL and better to do as a plug-in. Might be time to dust off Visual Studio again...
  • rebb
    Offline / Send Message
    rebb polycounter lvl 12
    After the last bigger thread about curvature i started fiddling around a bit with this.

    Here's what the current output looks like.

    vertcurvature.jpg

    It's in WIP state, and has some quirks related to undo ( also doesn't support undo in this state ), but if you really need it i can send you a .pyc or drop it online.

    The little dark splotches come from the raw output of the current algorithm, smoothing the vertex-color once or twice helps that tho.
  • EarthQuake
    Cool, can you bake it down to a lowpoly as a texture?
  • rebb
    Offline / Send Message
    rebb polycounter lvl 12
    Yep, here's an egghead example :)
    Its just baked to a sphere thats why the ears are being sampled strangely.

    curvature_egghead.jpg
  • bugo
    Offline / Send Message
    bugo polycounter lvl 12
    thats cool rebb, wonder if u can share that with us somehow?
  • r_fletch_r
    Offline / Send Message
    r_fletch_r polycounter lvl 9
    may i ask how you differentiate between convex and concave angles. maths not my thing but i could get this going in max if i had the idea. i had considered doing it with a ray cast but that would be pretty slow
  • renderhjs
    Offline / Send Message
    renderhjs sublime tool
    I am working on just that atm. for 3dsMax. I got a nice script from a buddy that blends hard edges and together with gradient mapped material and a mask for the chipped effect you could do just that.

    textools4texturemaps.jpg

    The one labeled as worn map assigns a vertex color based on edge vertex angles. A gradient material with the 3rd UV channel (color channel) is used to get more fine control in the material which can then be baked into a material or used as a mask.

    textools4wornmodes.jpg

    I am working on another script that converts a texture back to vertex colors so one can create complex materials that blend or mix in the vertex colors as a input.
  • MoP
    Offline / Send Message
    MoP polycounter lvl 14
    rebb: Awesome!

    renderhjs: Nice overview too.
  • rebb
    Offline / Send Message
    rebb polycounter lvl 12
    Ok, i've put it up here .

    It has different .pyc files for different Maya Versions ( 2009-2011 ), copy them into your script folder and load up the .py file.
    There's also some basic instruction inside the .py .

    @fletch :
    Looking at the Pits&Peaks Script renderhjs mentioned, it works pretty similar to that.

    @Mop :
    Thx :)

    Edit :

    Updated Version available here .
  • throttlekitty
    Offline / Send Message
    throttlekitty Polycount Sponsor
    Cool beans, thanks!
  • MoP
    Offline / Send Message
    MoP polycounter lvl 14
    I LOVE YOU REBB <3

    ibanez_curvature.jpg



    Edit: Just tried on a more heavy-duty test case, this time a 350,000 triangle decimated mesh from ZBrush.

    It took just over 90 seconds to calculate, which isn't too bad. I think the results would be better if the mesh wasn't run through decimation master, but obviously it'd take a lot longer to process. After doing Smooth a couple of times on the result I think it'd be good for most uses anyway.

    foto_curvature.jpg


    My next step is to try hooking this up into a shading network to control material parameters through the red/green vertexcolor channels :)
    Shame that Maya makes working with vertexcolor in Mental Ray such a total bitch.
  • Thegodzero
    Nice! The first thing that comes to mind is how useful that looks like it would be for controlling subsurface scattering. That would do wonders as a mask for a SSS map.
  • rebb
    Offline / Send Message
    rebb polycounter lvl 12
    Looks very sexy, Mop :P

    The next version should be a little faster as the algorithm is simplified some, also with undo support. The problem with undo support tho is that it will add some extra memory useage for each time the command is invoked ( because Maya has to hold the undo information ), but it should only be something to look out for with high vertex-count meshes.
  • bugo
    Offline / Send Message
    bugo polycounter lvl 12
    just looked at it now, THANKS REBB! This is just what i wanted man! Wonderful to find such a great thing. Now it's just a matter of baking it, putting some noise filter into it and consider it as a worn mask. Damn, this is good!
  • SHEPEIRO
    Offline / Send Message
    SHEPEIRO polycounter lvl 13
    this is ace...i can think of many applications...cheers
  • pior
    Offline / Send Message
    pior veteran polycounter
    This looks fantastic, and super useful. I have been hoping for a Mudbox realtime shader doing just that, in order to check for surface continuity (as a full heatmap, rahter than red>black>green tho)

    This however looks great as a base map to bake! Mop, did you manage to bake this to texture successfully ?
  • MoP
    Offline / Send Message
    MoP polycounter lvl 14
    Yep, any app that can import/bake vertexcolor will do this fine.

    Also, I checked and the Maya 2009 script works in Maya 2008 too :)
  • zxcman
    Offline / Send Message
    zxcman polycounter lvl 10
    What kind of profit can i get with convex&concave maps?
  • divi
    Offline / Send Message
    divi polycounter lvl 9
    lots of $$$

    concave map = areas where dust and dirt might settle
    convexity map = exposed areas that might be damaged/worn-out more.
  • Eric Chadwick
  • renderhjs
    Offline / Send Message
    renderhjs sublime tool
    somewhat related, a MR shader that does the same:
    http://www.tomcowland.com/mentalray/tc_curvature/index.html
    colured.jpg
    it supports tesselation with barycentric interpolation which results into smoother results if you want to bake or render stuff into bitmaps.

    Different but also nice:
    http://www.rpmanager.com/plugins/TensionMod.htm
    (to bad its just max and plugin only)
  • bugo
    Offline / Send Message
    bugo polycounter lvl 12
    Really useful as well renderhjs. Kinda easier to bake since it's a mentalray node.
  • shogunato
    Offline / Send Message
    shogunato polycounter lvl 10
    cool !
    i guess it can be useful for modeling
    detecting bumps and so far
  • yiannisk
    Offline / Send Message
    yiannisk polycounter lvl 7
    it is also available in 3dsmax (along with dirt maps, density, sss, etc.)
    Rendering>Render Surface Map.

    it's cool if you put it in textools.
    I wish there was a way to generate normal maps that fast as well :)
  • r_fletch_r
    Offline / Send Message
    r_fletch_r polycounter lvl 9
    Ive found render surface maps to be pretty crappy for these sorts of jobs as they are dependent on uvw mapping. The nice thing about the vertex approach is you can do it on your high poly model which usually has no mapping but has all the nice geometry detail.

    renderhjs: you might want to put a spinner for distance into your MR AO Baking option. MR AO is pretty useless without it. You tend to get a lot of unwanted shadowing in the AO without it.
  • Gannon
    Offline / Send Message
    Gannon greentooth
    would anyone mind re-uploading Rebbs script? I downloaded it and opened it up and it looks like it was corrupted.

    Thanks =D
  • rebb
    Offline / Send Message
    rebb polycounter lvl 12
    Hmm, it downloads and opens/extracts just fine when i try it.
    Does it not open for you or give you error messages ?
  • Gannon
    Offline / Send Message
    Gannon greentooth
    I open it with notepad or something of that nature and it get a bunch of random symbols.

    http://i10.photobucket.com/albums/a110/RdmLegend/test-1.jpg

    When I run it i get this error.

    # Error: name 'r7_vertCurvature' is not defined
    # Traceback (most recent call last):
    # File "<maya console>", line 1, in <module>
    # NameError: name 'r7_vertCurvature' is not defined #
  • renderhjs
    Offline / Send Message
    renderhjs sublime tool
    r_fletch_r wrote: »
    renderhjs: you might want to put a spinner for distance into your MR AO Baking option. MR AO is pretty useless without it. You tend to get a lot of unwanted shadowing in the AO without it.
    just fixed that, doh so obvious but went unnoticed, thanks
    much better default results now, update to be expected soon
  • rebb
    Offline / Send Message
    rebb polycounter lvl 12
    rdmlegend wrote: »
    I open it with notepad or something of that nature and it get a bunch of random symbols.

    http://i10.photobucket.com/albums/a110/RdmLegend/test-1.jpg

    When I run it i get this error.

    # Error: name 'r7_vertCurvature' is not defined
    # Traceback (most recent call last):
    # File "<maya console>", line 1, in <module>
    # NameError: name 'r7_vertCurvature' is not defined #

    Looks like you are trying to import the .pyc file. Instead you should copy both the .py and the .pyc file preferably into your script directory ( depending on your Maya Version, from the respective 20xx directory in the .zip ), then import the .py file and run that - it will automatically use the contents of the .pyc file.
  • kodde
    Offline / Send Message
    kodde polycounter lvl 15
    Trying to run rebb's script but with no success. Anyone know what I'm doing wrong here?

    I'm thinking maybe I'm using a different version of python?

    import r7_vertCurvature.py
    # Error: Bad magic number in C:/Users/kgia1/Documents/maya/2009/scripts\r7_vertCurvature_main.pyc
    # Traceback (most recent call last):
    # File "<maya console>", line 1, in <module>
    # File "C:/Users/kgia1/Documents/maya/2009/scripts\r7_vertCurvature.py", line 14, in <module>
    # from r7_vertCurvature_main import *
    # ImportError: Bad magic number in C:/Users/kgia1/Documents/maya/2009/scripts\r7_vertCurvature_main.pyc #
  • haiddasalami
    Offline / Send Message
    haiddasalami polycounter lvl 10
    Hmm I cant even get the 2011 one to run on my mac :(

    It runs but I get nothing..I select my mesh type import r7_vertCurvature it runs but there's no error or anything.
  • rebb
    Offline / Send Message
    rebb polycounter lvl 12
    @Kodde :

    Yeah it looks like you have a newer Python overriding the one that comes with Maya2009.
    Try setting the "PYTHONPATH" value inside the Maya2009 Maya.env file to "<YourMaya2009Directory>\Python" first.

    @haiddasalami :

    Yep that doesn't work.
    Either load up the r7_vertCurvature.py using the script-editor in Maya and run the contents, or load it via "from r7_vertCurvature import *".
    After that you can use the "r7_vertCurvature()" Python command on a mesh.
  • haiddasalami
    Offline / Send Message
    haiddasalami polycounter lvl 10
    @rebb: YAY it worked!! Thanks rebb.
  • malcolm
    Online / Send Message
    malcolm Polycount Sponsor
    I gave the script a try it doesn't work for me either. Pasted both files to my documents maya scripts

    r7_vertCurvature()
    # Error: NameError: name 'r7_vertCurvature' is not defined #
  • rebb
    Offline / Send Message
    rebb polycounter lvl 12
    @ Malcolm :

    Did you do what i told haiddasalami ?
    Anyway, i'll put a proper readme in the package next time, sorry for that :).
  • kodde
    Offline / Send Message
    kodde polycounter lvl 15
    Rebb> Tried on another computer where I had not fiddled with updating python. Got it working in both Maya 2009 32-bit and 2011 64-bit. Thank you!
  • kodde
    Offline / Send Message
    kodde polycounter lvl 15
    By the way, how do you guys go about vertex colors > bitmap?
    I used the Paint Vertex Color tool and used the export feature. But I'm lacking options such as fill texture seams with this method.
  • rebb
    Offline / Send Message
    rebb polycounter lvl 12
    You can use MentalRay Batch-Baking if you set up a material on the mesh like this.

    I hope it makes sense.

    Btw did you try the Maya.env PYTHONPATH approach ?
  • kodde
    Offline / Send Message
    kodde polycounter lvl 15
    Rebb> Cool thanks. Will give it a go.

    No I remember fiddling with updating python on that specific computer which I had the bad magic number error on. So I uninstalled the newer version of python and that did the trick.
  • rebb
    Offline / Send Message
    rebb polycounter lvl 12
    I just updated the script to Version 0.2.

    It's now an actual Command-Plugin that supports Undo.
    This also means that Maya now treats it more like a MEL Command, and it should mainly be used in this way, altho its still possible to invoke it through Python, just slightly differently.

    Other additions are a proper readme.txt, a UI Interface that pops up when using the Command without Parameters, some Algorithm changes, an newer Algorithm that should produce less artifacts on certain vertices, etc.

    Changes are more accurately listed in the readme :).

    Grab it here .

    Just shout if any problems crop up.

    Edit : Oh and better delete the files from the older Version in case you had that installed, just to be sure.
  • kodde
    Offline / Send Message
    kodde polycounter lvl 15
    Ooo sweet!
    Gonna give it a go tomorrow at work :)
  • pior
    Offline / Send Message
    pior veteran polycounter
    Can't wait to try it all out! Especially for continuity checks on highpoly sculpts. Delicious!
  • kodde
    Offline / Send Message
    kodde polycounter lvl 15
    Just tried the 0.2 version. Loving it. The bake material feature is great.
    Thanks.

    Found a confusing typo/error in the readme I think.
    === Installation ===

    Place this file and r7_vertCurvature_main.pyc in your "plug-ins" directory,
    then load the Plugin ( r7_vertCurvatureCmd.py ).

    That sentance says you should place the readme.txt and the r7_vertCurvature_main.pyc in your plug-ins directory. I assumed that the "this file" actually referred to the r7_vertCurvatureCmd.py" instead since this text might had been copy pasted from there at some point.
  • bugo
    Offline / Send Message
    bugo polycounter lvl 12
    Fun!!! Thanks for the update Rebb!! :)
  • rebb
    Offline / Send Message
    rebb polycounter lvl 12
    kodde wrote: »
    That sentance says you should place the readme.txt and the r7_vertCurvature_main.pyc in your plug-ins directory. I assumed that the "this file" actually referred to the r7_vertCurvatureCmd.py" instead since this text might had been copy pasted from there at some point.

    Oh, oops. Yeah you assume correctly, i wrote the text in the r7_vertCurvatureCmd.py originally, and then copied it into readme.txt.

    I'll update the .zip with less confusion, thanks :)
  • kodde
    Offline / Send Message
    kodde polycounter lvl 15
    Hey Rebb,

    Any chance we can get a clamp feature? The script writes color values outside of the 0.0-1.0 range. This is giving me some serious headache. Trying to use it together with xNormal and it's SBM format for Maya. But I get artifacts due to this.

    Thanks
  • kodde
    Offline / Send Message
    kodde polycounter lvl 15
    If anyone is interested using Vertex Chameleon plugin for maya to clamp the values works well, and fast!
1
Sign In or Register to comment.