|
|
In article <3A5868E7.11DD2F4F@gmx.de>, Christoph Hormann
<chr### [at] gmxde> wrote:
> Not sure whether it has everything you wanted, but how about:
I was about to post something similar, but I would write it:
#macro Gradient2(Vector)
#local Len = vlength(Vector);
#local V = Vector/Len;
#local FX = V.x;
#local FY = V.y;
#local FZ = V.z;
function {
min(1, max(0, (x*FX + y*FY + z*FZ)/Len))
// You sure about the /Len here?
}
#end
Probably no actual difference in parse time, and render time would be
the same...it just computes the length and a division fewer
times(vnormalize() computes the length and divides the vector by that).
And axis-aligned versions would be even simpler:
#declare Gradient2X = function {min(1, max(0, x))}
#declare Gradient2Y = function {min(1, max(0, y))}
#declare Gradient2Z = function {min(1, max(0, z))}
Interesting how one fairly simple looking feature (the function pattern)
can replace so many others...
--
Christopher James Huff
Personal: chr### [at] maccom, http://homepage.mac.com/chrishuff/
TAG: chr### [at] tagpovrayorg, http://tag.povray.org/
<><
Post a reply to this message
|
|