|
|
In math.inc it says :
"Clamps a number (x) to the range [Min, Max] ([y, z]).
Values outside this range wrap around."
That last bit is a problem imo. It should not wrap around. As an example
of why it should not wrap an implementation of the Smoothstep function.
Render the scene as is and then with the ifdef section uncommented.
I would rename the existing function to clamp_wrap and add the one below
as clamp as that is what one would expect.
ingo
---%<------%<------%<---
#version 3.8;
#include "math.inc"
// +a0.1 +w400 +h400
global_settings {assumed_gamma 1.0}
#default{ finish{ ambient 0.1 diffuse 0.9 }}
camera {
orthographic
location <0.5,0.5,-.1>
look_at <0.5,0.5,0>
right x*image_width/image_height
}
/*
#ifdef (clamp)
#undef clamp
#end
#declare clamp = function(x,y,z){select((x<=y),-1,select((x>=z),-
1,x,z),y)};
*/
#declare Smoothstep = function(x,y,z){
(3*pow(clamp((x - y) / (z - y), 0.0, 1.0),2))-
(2*pow(clamp((x - y) / (z - y), 0.0, 1.0),3))
}
#for (I,0,1,0.001)
sphere{<I, Smoothstep(I,0.2,0.8), 0>,0.01 pigment{rgb x}}
#end
box {
<0, 0, 0>, <1, 1, 1>
texture {
pigment {
function{Smoothstep(x,0.2,0.8)}
}
finish {
ambient 1.0
diffuse 0.0
}
}
}
Post a reply to this message
|
|