Home Technical Talk

corner vertex baking - maya mel/python

2

Replies

  • kodde
    Offline / Send Message
    kodde polycounter lvl 19
    Getting this to work properly made my day.

    curvaturesample.jpg
  • rebb
    Offline / Send Message
    rebb polycounter lvl 17
    I believe you can change the "Clamp" Option on the colorPerVertex Node that is created - does this help ?

    Wonder if a min/max clamping function would be useful or not :d.
  • kodde
    Offline / Send Message
    kodde polycounter lvl 19
    rebb> I don't see any colorPerVertex node in Maya. Is it some form of auxiliary node that is hidden by default? Using Maya2010 at the moment. I also have 2011 available.

    I actually tried at some point to manually select a couple of vertices and run the "polyColorPerVert -cal 1;" which should clamp the vertex colors. But this as far as I remember this didn't make any difference to the results exported with the SBM.
  • kodde
    Offline / Send Message
    kodde polycounter lvl 19
    Ok I just tried with a dummy object.
    First of all, if you've ever deleted history on your object (anyone confirm this?) you won't get a colorPerVertex or createColorSet node as you run the script? I couldn't find any way to get these nodes exposed or recreated on my models, only on a brand new dummy object which I had never deleted history on.

    Either way, setting the clamped flags on these nodes didn't make a difference for the exported data in the SBM format.
  • rebb
    Offline / Send Message
    rebb polycounter lvl 17
    You're right, seems these nodes are only created when the shape has some history before calculating the curvature colors.
    I can put a clamp option in the next version.
    Try this for a mesh that doesn't get these nodes applied :

    setAttr theShape.colorSet[0].clamped 1

    Replace "theShape" with your Shape-Name.
    Replace the 0 with the index of the actual curvatureColor set if the mesh has more than one colorSet.
    You can see the name of a colorset with "getAttr theShape.colorSet[x].colorName".
  • kodde
    Offline / Send Message
    kodde polycounter lvl 19
    I tried setting the clamped flag with the command your posted.
    It did not make a difference with the SBM-export.

    I think it's since changing that flag doesn't alter the actual stored vertex colors. It's just a stored flag of some sort that is account for in certain other Maya features that use vertex colors.

    The SBM exporter probably doesn't take this into account, it only reads the existing vertex color values.

    rebb wrote: »
    I can put a clamp option in the next version.

    Thanks! Looking forward to it. :)
  • onionhead_o
    Offline / Send Message
    onionhead_o polycounter lvl 16
    is there a way to bake this on a mesh with several uv tiles in maya?
  • kodde
    Offline / Send Message
    kodde polycounter lvl 19
    Sorry for the semi-necromancy here. But I figured out a way to get the values clamped without any extra scripts/plugins if anyone is in need of it.

    The r7_vertCurvature plugin won't clamp your vertex colors, so at extreme angles and/or with a high Scale value you can get color values above 1.0 rgb. In my case this was an issue since I used xNormals SBM format to export to get my files to xNormal and use the "Bake highpoly's vertex colors" to get the results to textures. Problem was, with the SBM format vertex colors above 1.0 would render as black colors.

    I tried lots of stuff and noticed that if you create a new color set in Maya you can use the "clamped" flag which keeps the colors within 0.0-1.0. It doesn't seem like you can change this after a color set has been created. So here's the trick. Before running r7_vertCurvature you can create a new color set with the clamped flag, then rename it to the same name that r7_vertCurvature uses when creating a curvature color set. I'm guessing that when the plug-in tries to create this color set and it already exists it instead decides to just go ahead and use the already existing one (with clamp flag).

    I'm happy :)
  • kodde
    Offline / Send Message
    kodde polycounter lvl 19
    So, the work flow I use in short:

    1) Import your highpoly (or a lower division if Maya refuses).
    2) Create a new color set with clamped flag on.
    3) Rename it to "curvatureColor".
    4) Run the r7_vertCurvature to get the curvature colors you want.
    5) Export using xNormal SBM format (enable it first in your plug-ins). Make sure to include vertex colors.
    6) Set up your highpoly and lowpoly in xNormal and render the curvature data to the lowpoly's UVs using the "Bake highpoly's vertex colors". Make sure to uncheck the "ignore per-vertex-color" on your highpoly.
    7) Use the curvature texture as a utility texture to get masks for your various textures.
  • kodde
    Offline / Send Message
    kodde polycounter lvl 19
    I had to try with some example.

    Tile diffuse and grungemap from cgtextures. I modelled a highpoly source from the diffuse and used it for generating normals, ao and curvature. Spec as shown in image was created in photoshop with the curvature data and a grungemap.

    curvatureforspec.jpg
  • claydough
    Offline / Send Message
    claydough polycounter lvl 10
    Thanks Kodde
    Thats supercool. Gonna have to incorporate as much in some tools.


    I did something similar with Barycentric Coordinates to find crevices:
    ( from an object selection the script selects all the edges that make up crevices )
    or the opposite ( depending on whether I wanted a hill or a valley ).

    select object>
    run script cly_hillOrValley.mel <-- to select crevices:
    3380869214_cbb0cfe664.jpg



    Do something useful to that selection like apply a dark vertex color to fake AO:
    3380869250_5560f0cd28_o.jpg



    or...
    shift select crevice vrts to get the inverse selection ( the hills ):
    Do something useful to that selection like:
    editMesh> transform component or jes normal tool ( pump up the hills )

    overclock muscalature:
    3392880965_e2820ca609_o.jpg



    again exagerated overclock



    3392906083_44a651b698_o.jpg
    originally fer Sa74n
    http://www.polycount.com/forum/showthread.php?t=61998
  • kodde
    Offline / Send Message
    kodde polycounter lvl 19
    Wow that's nice claydough. I bet that can be useful. Gonna give it a go later. Thanks for sharing.
  • kkw
    Hi rebb, i find your tool to be super useful. Any chance you could recompile the plugin for Maya 2012?


    rebb wrote: »
    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.
  • passerby
    Offline / Send Message
    passerby polycounter lvl 12
    kkw wrote: »
    Hi rebb, i find your tool to be super useful. Any chance you could recompile the plugin for Maya 2012?

    i use it almost daily, and works fine on maya 2012 for me. Just using the latest one in this thread.
  • Arno
    Offline / Send Message
    Arno polycounter lvl 8
    I know this thread is kinda old, but I have a question related tot this script.

    I've got a high-rez object with the vertex colours aplied for the curvature.
    I am trying to bake this this to my low rez using mayas batch bake. But it's giving me a gray map, which is the material colour.

    Is there anyway I can use maya's transfer map to transfer vertex colour information ?

    I know there are work arounds like baking it to a texture with batch bake, or using a different program such as xnormal.

    I need to do a lot of objects, so I would like to do it in maya with the transfer maps, so I can get the Normal, AO, and Curvature information all in one go with the same envelope.

    Any help would be appreciated.

    PS @Reb, this script is super awesome I used it a ton, on my last project the metroid character.
  • kodde
    Offline / Send Message
    kodde polycounter lvl 19
    If I'm not mistaking there's an export tab in the Vertex Paint Tool(Artisan) in Maya. Maybe you could use that?
  • Arno
    Offline / Send Message
    Arno polycounter lvl 8
    Hi Kodde,

    Thanks for your reaction.

    I found the option gave it a shot. Like anticipated this function only allows you to export the data the a texture of the geometry the vertex colour is on.
    While my goal is to transfer the vertex colours from the high-res mesh to the texture of my low-res mesh. Similar to the X-normal functionally spoken off in this thread.

    But I am trying to keep it all in maya to speed up the workflow.

    The main drawback of your suggested method is that the high res mesh needs to have non overlapping uvs, and you first need to bake it out to a texture, creating an extra step.
    Since most high-res geo exported from a sculpting package doesn't have UVs you will get the following error // Error: Failed to export the attribute map.
  • Ikosan
    Hey guys
    So, I'm trying to use the TC curvature shader information of polygon models and I'm a little confused. If I apply the shaders in the example scene to my models the render comes out black, Im assuming this is because they are polygon models and all the example scene uses is nurbs. The site also claims there are lots of perameters but in my shader node it has none of these. Has anyone got a good example of this shader working on a polygon model and if so whats the work flow?
  • kodde
    Offline / Send Message
    kodde polycounter lvl 19
    From what I remember this is not a shader initially? It sets vertex color?
    But I do recollect one extra feature being bake-material? Anyhow, the parameters I remember using when fiddling with this was through a custom window which would appear as you called the plugin?
  • artquest
    Offline / Send Message
    artquest polycounter lvl 14
    **CASTS THREAD NECRO!!** (sorry guys! Had to do it...)

    Does rebb's script still work in maya 2014 or have we found other/better tools to do the job? Kodde's skrewdriver top looks kickass. I'd love to generate curvature maps with that kind of quality. Any suggestions?

    P.S. I already tried installing it but the plugin wont show up on my plugins list.
  • passerby
    Offline / Send Message
    passerby polycounter lvl 12
    I think it is broken in 2014, haven't tested but reb never distubute the real code, but instead the compiled python bytecode, which is dependent on the python version.

    And Maya 2014 uses python 2.7 while all earlier versions are still on python 2.6.4 or earlier.
    It could likely be decompiled back to normal python code to make it work on 2014 but that is kinda shady.

    Could contact reb I guess.
  • artquest
    Offline / Send Message
    artquest polycounter lvl 14
    passerby wrote: »
    I think it is broken in 2014, haven't tested but reb never distubute the real code, but instead the compiled python bytecode, which is dependent on the python version.

    And Maya 2014 uses python 2.7 while all earlier versions are still on python 2.6.4 or earlier.
    It could likely be decompiled back to normal python code to make it work on 2014 but that is kinda shady.

    Could contact reb I guess.

    Bummer! :( It looks so awesome. What are some other modern alternatives for curvature map baking?
  • MM
    Offline / Send Message
    MM polycounter lvl 18
    xNormal bakes curvature maps form highpoly, although it can produce lot of artifacts.

    Knald height map generated from an existing normal map works pretty good as a curvature map.
  • passerby
    Offline / Send Message
    passerby polycounter lvl 12
    artquest wrote: »
    Bummer! :( It looks so awesome. What are some other modern alternatives for curvature map baking?

    Well I just use rebs tool, but knald does a good job.

    Also you say you don't see it in the plugin list at all?
    If it isn't working due to the pythonvversion mismatch it would still show in the plugin list, it would just fail to load.

    Are you sure its in the right path?
  • artquest
    Offline / Send Message
    artquest polycounter lvl 14
    passerby wrote: »
    Well I just use rebs tool, but knald does a good job.

    Also you say you don't see it in the plugin list at all?
    If it isn't working due to the pythonvversion mismatch it would still show in the plugin list, it would just fail to load.

    Are you sure its in the right path?

    The instructions say to place it within your "plug-ins" folder. But to be honest the folder structure between maya 2012 and 2014 has changed slightly, so I can't be sure of anything.
    MM wrote: »
    xNormal bakes curvature maps form highpoly, although it can produce lot of artifacts.

    Knald height map generated from an existing normal map works pretty good as a curvature map.

    I like that the r7 curvature map places convexity and concavity in separate channels but still in the same image. Then I can use them quickly as alphas for masking.

    P.S. When I tried Xnormal I noticed it didn't give as good results as the ones posted here in this thread.
  • rebb
    Offline / Send Message
    rebb polycounter lvl 17
    Finally gotten around to this - i'm actually surprised people are still using it :o

    There's an updated version here .

    Be aware that it has a bunch of changes that break 1:1 compatibility with the old version. Mainly things like parameters, color output etc.
  • artquest
    Offline / Send Message
    artquest polycounter lvl 14
    rebb wrote: »
    Finally gotten around to this - i'm actually surprised people are still using it :o

    There's an updated version here .

    Be aware that it has a bunch of changes that break 1:1 compatibility with the old version. Mainly things like parameters, color output etc.

    Wow thanks! I'll have to try this out ASAP.
  • beefaroni
    Offline / Send Message
    beefaroni sublime tool
    Thank you rebb!! Been trying to do a tension map mask for a few days now and this look super promising!
  • onionhead_o
    Offline / Send Message
    onionhead_o polycounter lvl 16
    this made my day. Gona be using this at work to save time. Much appreciated Rebb!
  • ErikHallberg
    This seems absolutely awesome! I too have had some issues with xNormals curvature map baking.

    Though, when clicking "Assign Bake-Material" i get an error reading

    # Error: ValueError: file k:/Create/Maya/2014-x64/plug-ins\r7_vertCurvatureMain.py line 501: No object matches name: .cpvSets[0] #

    I may have done something wrong, but I can't think of what that could be.
    I have loaded MR and the r7 Vertex Curvature UI loads just fine. I am using the default settings too. The test object is a subdiv surface and I'm using the 2014 x64 version of the script on a windows machine.

    Any ideas would be much appreciated! Thanks!
  • combo_jerman
    Hi guys,
    Do you have this plugin for Maya 2014 AND Maya 2015?
    Im working on both versions and I cant run the Python to make some tests.
  • Ged
    Offline / Send Message
    Ged interpolator
    Its been a few years and we have new tools in Maya so I was just wondering if there's any easy way get a curvature bake these days? Im both baking high to lowpoly and also lowpoly to itself hoping to get edge bakes to save me hand drawing lots of edges manually in photoshop.
2
Sign In or Register to comment.