Jump to content

Maya, MEL and VEX - some questions


Juraj

Recommended Posts

Hello,

I would like to ask you if there is some sort of equivalent to VEX in Maya. I am not experienced in Maya and I don't know all its functions.

Recently I tried to do a simple task on geometry - to compute facing ratio between vertex normal and light direction, and then map the result to vertex color. Well, I managed to create simple MEL script and it works but it's extremly slow and inefficient when compared to similar solution in Houdini :)

Also is there a solution to run this dynamically? (without need of clicking shelf button) Maya has some great nodes but I don't know how to extend them or create my own.

 

Also many people tell me that a lot of studios have Maya centered pipeline and therefore its beneficial to have skills in Maya. Do you think it is worth trying to mimick Houdini functions in Maya?

 

Here is mentioned MEL script.

global proc facing(){
    // facing ratio to vertex color
    // selection order: geometry, light
     
    float $start = `timerX`; // start timer
    string $prevTool = `currentCtx`; // record current tool
    string $sel[] = `ls -sl`; // selection to array
     
    int $nvtx[] = `polyEvaluate -v $sel[0]`; // number of vertices
    float $xform[] = `xform -q -m -ws $sel[1]`; // xform mtx from light
     
    vector $light = <<0,0,1>>; // init light vector var
    $light = pointMatrixMult($light,$xform); // mult with xform mtx
    $light = unit($light); // mormalize
         
    for ($i = 0 ; $i < $nvtx[0] ; $i++) { // iterate over all vertices
        string $vtx = $sel[0] + ".vtx[" + $i + "]"; // current vertex
        float $N_array[] = `polyNormalPerVertex -q -normalXYZ $vtx`; // return array of normals
        vector $N = <<$N_array[0] , $N_array[1] , $N_array[2]>>; // save first normal to vector var
        float $factor = clamp(0,1,dot($N,$light)); // compute angle between N and light vector
        polyColorPerVertex  -g $factor $vtx; // assign vertex color
    }
 
    select -r $sel[0]; // select colored object
    string $pVtxTool = `artAttrColorPerVertexToolScript 4`; // initialize the paintVertex tool
    artAttrPaintVertexCtx -e -sao "smooth" $pVtxTool;   // set it to smooth
    for ($i = 0 ; $i <= 6 ; $i++) {
        artAttrPaintVertexCtx -e -clear $pVtxTool;  // smooth vertex colors
    }
 
    select -r $sel; // restore selection    
    setToolTo $prevTool; // restore tool
    float $end = `timerX`; // end timer
    print ("\nnumber of processed vertices: " + $nvtx[0] + "\ntime to execute: " + ($end - $start) + "sec"); // print stats
     
}
  • Like 1
Link to comment
Share on other sites

Not built-into maya, no. You might be able to do something with SOuP:

 

http://www.soup-dev.com/

 

The fastest thing maya has script-wise is the expression language used for particles, which last I checked isn't multithreaded, and doesn't have anywhere near the language scope of vex.

 

You can prototype stuff in python and make calls to the maya API, but again its not multithreaded, to make it fast you'd need to code it in C++.

 

Another option might be SeExpr, which I _think_ is multithreaded, but it seems to be primarily for pattern generation. Someone made a deformer, but again, I don't think it is capable of the effect you're describing.

 

https://github.com/taikomatsu/SeExprMeshMaya

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...