How to multiply vector by scalar in material nodes? I'd like to do arbitrary vector math with the camera position, shading point, and possibly other points. As a test case (blend file), suppose I want to make a shader that will draw a simple gradient based on distance from the shading point to the camera in one of two ways. 

The two methods of getting the desired distance are:


"Camera Data.View Distance" as the control. 
Computing the length of a vector equal to the unit vector given by "Camera Data.View Vector" multiplied by the scalar "Camera Data.View Distance". This is the issue.


The node setup looks like this:



What can I put in the "Vec * Scalar?" frame so that the material will look the same no matter how the "Selector" Mix Shader Factor is set?
You should think more about the data types. If you want vector*scalar, use MixRGB set to Multiply (an RGB color has three components, like a vector), and not a simple scalar math node. See my answer to this question for an example of vector*scalar: Scale Texture with a Value-/Math-Node

Also your selector seems to be a Mix Shader (I didn't download your file, but it has shader inputs and outputs), and you should not put scalars into a node that expects shaders.

EDIT Just for completeness: There are also other ways of doing vector*scalar, like using a vector Mapping node and setting the same X, Y, Z Scale, or separating the vector components with a Separate XYZ and multiplying the three scalar coordinates individually, and merging them again with Combine XYZ.