So, William Pokorny's recent experiments / bug eradication in the yuqk fork
reminded me of a discussion we had about 2 years ago concerning POV-Ray's
internal handling of surface normals, and how they get perturbed by the various
clipka briefly touched on this:
"When plugging in a pattern into a normal, the normal is computed by
first sampling the pattern at four points in 3D space, from that
computing the gradient of the pattern in 3D space, and from that
computing how to perturb the normal. The four samples are always taken
at fixed offsets relative to the intersection points, distributed in a
But I'm still mystified how applying a scalar value to a normal (vector) changes
the direction of the normal. This is apparently the basis of how surface
normals are simulated in the raytracer, but neither myself nor WFP exactly
understand how it all works. All the vectors sum to <0, 0, 0>, and we can't
seem to determine where the anisotropy gets introduced.
In trying to figure this out, I stumbled upon:
Which attempts to explain it a bit too briefly, but the result seems to be that
after terms cancel, one gets directional gradients of the function, the vector
sum of which is the normal vector to the surface.
I was unable to find any other mention of this method, so I have an email out
trying to find the origin of this technique, and hopefully the
technical/mathematical details of how it works.
Maybe TOK has the key to this. :)
I hastily scribbled out a scene that uses the method to compute the normal of a
simple sine-wave function, and plots the normal vectors on the surface. It
seems like it mostly works, but some of the normals are wrong.
(it almost seems like if the sides of the valleys were switched, and the signs
of the normals were reversed, then the wrong normals would be corrected)
I'll have to superimpose a trace () result onto this for comparison.
Rendering a visualization of the tetrahedral vectors and coloring them by vertex
coordinates suggested that 3 of the vectors are pseudo-cardinal vectors, and the
remaining vector is the inverse of their vector sum. (Center cube)
Shifting the reference point/origin to <-1, -1, -1> shows what I mean. (Right
I don't presently know what that all means, but hopefully it spurs some ideas.
Some interesting additional reading on normal related topics:
Post a reply to this message
Download 'pyramidnormal.png' (94 KB)
Preview of image 'pyramidnormal.png'