|
|
"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
|
|
|
|
"Reactor" <rea### [at] hotmailcom> wrote in message
news:web.4aaddb72280b0bab74fac1dc0@news.povray.org...
> "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:
>
I think there may be an even simpler way, which is to use a 'spherical'
pattern centred on the camera and scaled so that the 1-unit radius spherical
pattern reaches the most distant objects in your scene.
By applying this pigment to all of the objects in the scene (with a high
ambient setting and with no lights in the scene), you get an image where the
color of each pixel represents the distance from the camera.
The default pigment_map goes from Black on the outside to White in the
middle, but you can adjust the pigment_map to control the color that
represents each distance. The following example uses Red for the most
distant points, Green for the middle distance and Blue for objects close to
the camera. The pattern is scaled to reach the most distant object at 50
units, with the closest part of the furthest plane being at 45 units.
#declare MyCameraLocation = <0,0,>;
//#declare MyCameraLocation = <30,0,25>;
camera {location MyCameraLocation look_at 25*z}
union {
plane {x,-10}
plane {-z,-45}
sphere{<5,0,10>,1}
sphere{<5,0,20>,1}
sphere{<5,0,30>,1}
sphere{<5,0,40>,1}
pigment {
spherical
pigment_map {
[0 rgb <1,0,0>]
[0.5 rgb <0,1,0>]
[1 rgb <0,0,1>]
}
scale 50
translate MyCameraLocation
}
finish {ambient 1}
}
Regards,
Chris B.
Post a reply to this message
|
|