Home Technical Talk

Maya ShaderFX Question

mattyinthesun
polycounter lvl 4
Offline / Send Message
Pinned
mattyinthesun polycounter lvl 4
Hey everyone
Quick ShaderFX question. I am constructing a custom shader to do a bunch of interesting stuff, and so far it is working great. I am now at a part however that is pushing outside of my knowledge!!

Instead of projecting a texture via UV space, I want to project a texture on to a model based on camera projection, and have it update as I move the camera around. Think of it like I have a vignette texture on the camera, that darkens the edge of the frame - I want this vigenette texture projected on to a mesh - so if the mesh moves towards the edge of the camera frame, it gets darker, towards the center, gets lighter.

Is this possible? I am thinking so, just outside of my knowledge.

Thanks!

Matt

Replies

  • throttlekitty
    Options
    Offline / Send Message
    Projection does exactly what you're asking for in the first half. I'm having trouble picturing this dark/light transition working with a typical vignette styled texture. The method I'd probably go for there would be to place a plane in front of the camera displaying the vignette, as well as parenting it so it moves with the camera.

    http://www.youtube.com/watch?v=lb5Bpl9R49o
  • mattyinthesun
    Options
    Offline / Send Message
    mattyinthesun polycounter lvl 4
    Thanks - yeah, I saw this video, and this projecting from a known plane, which is easily got through a node in ShaderFX. What I am wanting is projection from the camera viewport - which I cannot seem to hookup. It is very similar to this, but instead of projecting from a XY (or whatever) plane, you are projecting from the camera view plane
  • throttlekitty
    Options
    Offline / Send Message
    Gotcha, I didn't watch the first time, but got curious now. In a regular maya shader we'd just use a projection node that has that capability, or parent it directly.

    It looks like there's a cameraVector node according to this thread, I can't find any docs on it, so I couldn't tell you if you can directly replace the vertexWorldPos, or if you need to skew the output in any way.
  • shaderfx
    Options
    Offline / Send Message
    shaderfx polycounter lvl 9
    Hi Matt,

    If the information you want to pass into the shader is not readily available as an existing node, you can always use a float, float3, etc value. Expose it and then add an expression, set-driven-key, mel script or whatever to it to get the value into the shader.

    E.g. lets say we did not have camera-fov and you needed it for your effect.
    Add a float node to shader. 'Expose' it as a material input.
    Then link the camera-fov value from the maya scene to the shader.

    There are other ways, such as running a (mel-)script node every frame from within the shader, but that gets a little more complicated and I wouldn't recommend it as the first thing you try.

    Hope that helps,
    -Kees

  • kodde
    Options
    Offline / Send Message
    kodde polycounter lvl 19
    What a lovely video you linked to earlier ;)

    Anyway, can't you get away with using the "Pixel Screen Position" node? It gives you screenspace coordinates.
    If you try it out you will probably want to invert the vertical axis and probably also compensate for the aspect ratio of your current viewport setup.

    I've used it several time and it works pretty well. Check out this video of mine at 13:43 and you can see it in action.
    https://youtu.be/FCyRJlSYXXc?t=13m43s
  • kodde
    Options
    Offline / Send Message
    kodde polycounter lvl 19
    So did you come up with a solution?
Sign In or Register to comment.