Home Technical Talk

Maya: Bake vertex ao into a specific channel?

Does anyone know how to bake vertex ao into a specific channel?

Say I want to bake AO into vertex.r, and reflection occlusion into vertex.g, is there some way to do this?

Maybe if I baked each into two different bake sets, is there some scripting that could be done to copy bakeset 2 into vertex.g of bakeset 1?

Also, anyone know how to render reflection occlusion in Maya? I was thinking I would just try to tweak the AO output a bit.

Replies

  • haiddasalami
    Options
    Offline / Send Message
    haiddasalami polycounter lvl 14
    You're probably looking for PolyColorPerVertex You can query each channel and set too.

    Some sample code. Note this will probably be slow on higher vertex counts:
    import maya.cmds as cmds
    
    sel = cmds.ls(sl=True)
    start = cmds.timerX()
    for obj in sel:
        totalVerts = cmds.polyEvaluate(obj, vertex=True)
        window = cmds.window("ProgressWindow",title = "Crunching Numbers")
        cmds.columnLayout()
        progressControl = cmds.progressBar(maxValue=totalVerts, width=300)
        cmds.showWindow( window )
        for vertNumber in range(totalVerts):
            vertex = "%s.vtx[%d]" % (obj,vertNumber)
            cmds.polyColorSet(currentColorSet=True, colorSet= 'AO') 
            firstColorSet = cmds.polyColorPerVertex(vertex,query=True,r=True)
            cmds.polyColorSet(currentColorSet=True, colorSet= 'Lights') 
            secondColorSet = cmds.polyColorPerVertex(vertex,query=True,r=True)
            cmds.polyColorSet(currentColorSet=True, colorSet= 'myNewColorSet')
            secondColorSet = cmds.polyColorPerVertex(vertex,r=firstColorSet[0],g=secondColorSet[0],b=0.0)
            myStep = vertNumber/totalVerts
            cmds.progressBar(progressControl, edit=True, pr=vertNumber+1)
    
    totalTime = cmds.timerX(startTime=start)
    print ("%d seconds" % (totalTime))
    
    if cmds.window("ProgressWindow", exists=True):
        cmds.deleteUI("ProgressWindow", window=True)
    

    Was about 40 seconds for 2000 vert mesh. Probably derped at some parts as been coding too much maxscript haha. O and yeah this assumes you have a colorset named AO "mynewColorSet" etc. Feel free to change it to whatever
  • haiddasalami
    Options
    Offline / Send Message
    haiddasalami polycounter lvl 14
    Derp. Edited instead of added new.
Sign In or Register to comment.