Home Technical Talk

cgfx projection shader working in Maya?

Hi,
I'm learning cgfx shading these days, and trying to create a cgfx shader in Maya that projects the texture from another camera with proper focal length with image ratio.

I realized that I actually need to compute view transform and projection transform matrix from given camera, but those matrix are way beyond me. (or maybe I'm wrong?)

Is there anyone who already worked on projection shader in Maya?
Please give me some hand here...

Thanks

Replies

  • Brice Vandemoortele
    Options
    Offline / Send Message
    Brice Vandemoortele polycounter lvl 19
    Using the connection editor you can link the matrices of your objects to your cgfx shader. You need to define a matrix in your shader - something like float4x4 camMatrix;
    Multiplying the vertex world position by worldInverseMatrix will give you a view space projection (no perspective)
    Unfortunately maya doesn't seem to expose the projection matrix of the cameras, nor the FoV and far/near plane to compute one on the fly (or am I missing something?). I guess your best chance is to look for the "Projection" node and have it to spit the proper information. There has to be a way since Maya can do camera mapping internally using that node.
  • yoonjunc
    Options
    Offline / Send Message
    Thanks Brice,
    Yes, I added simple 4x4 variable and connected camera's worldInverseMatrix to it using connection editor and it works! (I was trying to reveal those to shader's attribute using UIName, but it never worked for some reason. Using straight variables and connect them using connection editor was very good solution indeed!)
    As you mentioned, now I need to figure out how to create perspective projection matrix using Field of view and image ratio or the projection nodes.
    Thanks again!
Sign In or Register to comment.