Let's preface this post by stating that I'm fairly confident that the following, used as it is, is a pretty bad idea but it is interesting none the less. At least for the math behind it.
As I was watching Star Wars Rebels a few days ago, I noticed that the ping in the eyes was pointing towards a light source or at least a fixed point in space.
On the left, an extracted gif from saison's 3 episode 2 preview, Star Wars Rebels The Antilles Extraction, https://youtu.be/E0M2RC5ENLI
On the shows I worked on, we used two techniques to create the ping, a texture or a mesh. In both cases, the ping was following the eye and not the "light source". Which is something that always bugged me.
On the right, an extracted gif from Skylanders Academy's trailer, https://youtu.be/FeMStkCW2LY
Maya has a Closest Point constraint that lets you attach a locator to a mesh surface and moves it to the closed point to the target. On paper, it could be use to move the ping mesh toward the light. In practice, I was somewhat disappointed by the results I got.
The movements produced by that constraint are jittery and favor the vertices to the rest of the surface.
The idea
The pretty bad one, but the interesting one.
What Maya does is basically checking if the coordinates of the surface match the coordinate of the line passing by the center of the sphere and the target. Or at least, that's what it looks like to me. It also sounds like it could be done with a world position pass and some locators.
I'm not entirely sure my method is the simplest one, but here is how I get the coordinates of a line in 3D space knowing the coordinates of two of its points.
What I have at my disposition in Nuke is two axis, one given by a fbx export of the position of the eye and one of the position of the light source, and the world position pass.
Now, rather than checking each pixel of the world position pass and getting a unique white pixel if one is on the line (which would be pretty rare; we would need to approximate to get more results), I decided to draw the distance between the line and the pixel.
To do so, I need to first find the projection of each point of the world position pass on the line.
The alpha channel expression is :
clamp(r==0 && g==0 && b==0 ? 0 : 1 - sqrt((r-x)**2 + (g-y)**2 + (b-z)**2) / radius)
Which is one minus the equation above divided by the radius. This limits the size of the circle and sets the whitest point on the shortest distance instead of the farther.
Results
Specular pass from the render engine
Calculated specular from the expression
Difference between the two speculars
And that is it. I never put it to the test in production nor did I create a proper gizmo. I hope that you have found some interest in this first blog post!
EDIT : Cyril from 2019 here!
Here is the comp files, in case you’re interested.