|
![](/i/fill.gif) |
"Paco" <nomail@nomail> wrote:
> I was hoping to create an image where the colour of each pixel is proportional
> to the distance from the camera to the intersecting object.
>
> I figure I can use the trace function to get the intersection distance, but how
> about outputting the image? Is there some flag or something to do this?
If I am understanding you correctly, couldn't it be done with a pigment
function? You could pre-declare the camera coordinates and make a distance
function:
#declare CamLocationX = 0;
#declare CamLocationY = 5;
#declare CamLocationZ = -5;
#declare fn_CamDist = function{
sqrt(
(x - CamLocationX)*(x - CamLocationX)
+ (y - CamLocationY)*(y - CamLocationY)
+ (z - CamLocationZ)*(z - CamLocationZ)
)
}
That gives you the straight line distance from any point to the camera. To
properly use it with a color_map or other map, you'll need to normalize or
clamp the values between 0 and 1. The way you'll want to depends on your scene
- you could set a distance at which all objects beyond (or in front of) have a
certain map entry, or apply a different function that allows very distant
objects to approach a max map entry at infinity.
HTH
-Reactor
Post a reply to this message
|
![](/i/fill.gif) |