Recently I had to modify a Maya hypergraph shader to mimic a shader I had made in Unity. The Unity shader sampled a “ramp” texture using the dot product of the vertex normal and an arbitrary Vector3 that was set by a script, like a fresnel effect but not using the camera’s direction.
I ended up using Maya’s snow texture node, which by default applies color by comparing a pixels normal direction to the world up direction.The upshot of doing it this way over using samplerInfo’s facingRatio is that we get a place3DTexture in the scene (connected to the snow texture) which we can rotate to apply the facingRatio effect from different angles and even animated.
Here’s a simple shader using facingRatio
Here the facingRatio of the sampler input is plugged into the vCoord of a ramp, which is then plugged into the outColor of the surface shader. This is the effect I wanted to achieve, just not using facingRatio.
First I created a snow texture (which is under 3D Textures) and set its base colour to black and falloff to 0.
Maya seems to apply a curve to the result making a lot more of the surface white than there should be, to combat this I set the snows Depth Decay to 0.001, then multiplied the output by 1000, this gives a much more linear gradient.
With that setup I can rotate the place3DTexture node in the scene to change the direction the ramp is applied, the original effect is matched by rotating it so it’s Y axis points at the camera and to animate just key the place3DTexture’s rotation.
And that’s it, hopefully someone will find this useful, there’s nothing too complicated involved and there may be a better way of doing it, I’d love to hear if there is.