C++ example code

You can try these out by creating a new console project in Visual Studio and copy the code from each sample.

Shader refrence
Falloff = 1.0 - dot( N, V )

N = normalized surface normal
V = normalized vector from surface to viewers eye

3dsmax_falloff.fx per_pixel_falloff.glsl

Shaders Extra

The shaders contains lots of comments!
You can test them out in 3ds max with the "DirectX shader" material.

dot( A, B) = |A| * |B| * cos(a)

|A| = length of A
a = angle between A and B
A&B are vectors.