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
http://www.youtube.com/watch?v=lb5Bpl9R49o
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.
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
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