ananthonline has already given you some references, but those are total overkill for a simple line strand illumination model.
If your demands are not as advanced you can apply the Phong illumination model onto strands. You may ask "wait what, strands don't have normals, but you need those for Phong?" Well, yes and no. A line segment has an infinite number of normals, also known as a plane. Or in other words the line strand itself is a normal to a plane.
The phong model starts off the assumption of a Lambertian scattering model, i.e. the "more" perpendicular the angle of incidence, the brighter it gets. The math describing this is
I(phi) = I_max * cos( phi )
or, by substituting phi with a vector and cos( angle(↑a,↑b) ) = ↑a · ↑b
where ||↑a|| = ||↑b|| = 1
I(↑a, ↑b) = I_max * ↑a · ↑b
Now let ↑c · ↑b = 0
, where ||↑c|| = 1
, then ↑a · ↑b = 1 - ↑a · ↑c
. But ↑c · ↑b = 0
is the definition of a normal. Which means for a line segment of direction ↑b
and direction to light source ↑c
you can write the intensity as
I(↑b, ↑c) = I_max * (1 - ↑b · ↑c)
And that is a Phong illumination model for lines. And as it happens it's also exactly what Blender does.
Update: Specular reflection
You need the eye position only for the calculation of the specular reflex. You can do this as well, by assuming that the normal of the line strand is the light direction vector perpendicularized to the line strand. Let ↑b
again be the direction of the line segment and ↑c
the direction toward the light. Then applying the Gram-Schmidt orthonormalization method you can derive a in-situ normal ↑n
by
↑n = normalize(↑c - ↑b·↑c)
Using that you can build the usual set of
- vertex position
- vertex "normal"
- light direction
- light half direction
in a line strand vertex shader and pass it to a regular Phong fragment shader and do the math as usual.