Welcome to od|forum

Register now to gain access to all of our features. Once registered and logged in, you will be able to contribute to this site by submitting your own content or replying to existing content. You'll be able to customize your profile, receive reputation points as a reward for submitting content, while also communicating with other members via your own private inbox, plus much more! This message will be removed once you have signed in.

Juraj

Maya, MEL and VEX - some questions

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
     
}
1 person likes this

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

Thanks for reply, I will look into those extensions of Maya. This SeExpr looks promising.

Share this post


Link to post
Share on other sites

After I have seen some demos of Fabric Engine I think that this is the way to go in the future. It should have great performance and it is independent of 3D package so Maya shouldn't complicate workflow much :)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now