|
|
So, I finally coded-up my idea, and it does indeed put the 'center' color of the
color_map across the center of the object. That part works, at least. But the
color pattern's 'limits' on the object have a problem: the color spread doesn't
extend all the way across. So far, after several days of trying to figure out
why, I still don't have a clue. I tried changing *every* parameter in the code,
but no luck-- although there's probably a hidden 'clue' in those trials.
So, I had to resort to some fudge-factors as well :-/ I eventually found one
set of those that actually works consistently... so the overall scheme is
workable after all. Only two 'fudging' values need changing, by eye; they depend
on relative distance between object and camera, and on the scale of the object.
I don't know if those values change linearly, exponentially, or what.
Essentially, they increase the distance between the object's found bounding-box
coordinates, *as if* the object is larger. A clue?
The first image is the result of the initial code idea; the second is with the
fix. The fudge factors indicate that the 'squashed' color_map values depend on
some kind of so-far-unknown variable. There HAS to be an answer; I just haven't
found it yet :-(
The camera and object positions are arbitrary, as is object scale, and can be
anything... within reason ; there can be precision issues behind-the-scenes. See
the #debug messages.
//------------------------
#declare CAM_LOCATION = <32, 56, -35>*3; // easily change location using the
// (positive) multiplier (actually changes it between location <0,0,0> and
// farther out)
#declare OBJECT_CENTER_LOCATION = <3,6,22>*1.0; // ditto
#declare OBJECT_SCALE = 2.7;
#declare CAM_ANGLE = 3; // 0.9 Just to easily change the camera angle when
// you change object scale or camera/object distance.
// main camera
camera {
perspective
location CAM_LOCATION
look_at OBJECT_CENTER_LOCATION
right x*image_width/image_height // aspect
angle CAM_ANGLE
}
/*
// OR, separate camera, 'un-coupled' from code, looking from another location
// way above
camera {
perspective
location <0,500,0>
look_at OBJECT_CENTER_LOCATION
right x*image_width/image_height // aspect
angle CAM_ANGLE
}
*/
light_source {
0*x
color rgb .7
translate <40, 80, 30>
}
background{rgb .1}
// stripes are 1-unit apart
plane{y,0
pigment{
average
pigment_map{
[ 1 gradient x
color_map{
[.05 rgb .8]
[.05 rgb .3]
}
]
[ 1 gradient z
color_map{
[.05 rgb .8]
[.05 rgb .3]
}
]
}
scale 1
}
}
#declare OBJECT_1 = // does not need to be centered on origin when made
// box{0,<1,.1,1> scale OBJECT_SCALE
// rotate 40
// translate OBJECT_CENTER_LOCATION
// }
// OR...
cylinder{-.05*y,.05*y 1
scale OBJECT_SCALE
translate OBJECT_CENTER_LOCATION // yes, PRE-translated -- it's part
// of the idea
}
#declare NEAR_CORNER = min_extent(OBJECT_1);
#declare FAR_CORNER = max_extent(OBJECT_1);
#declare L_1 = vlength(NEAR_CORNER - CAM_LOCATION) - 0; // or - 1.68 FUDGE
// FACTOR
#declare L_2 = vlength(FAR_CORNER - CAM_LOCATION) + 0; // or + 1.44 FUDGE
// FACTOR
#declare S = L_1/L_2;
#declare T = 1.0 - S;
#declare SPHERE_PIG =
pigment{
spherical
color_map{
[0 rgb 3]
[0 rgb <0,0,1>] // BLUE -- outside edge of pattern
[0.5*T rgb <1,1,0>] // YELLOW
[T rgb <1,0,0>] // RED
[T rgb 3]
}
/*
// to experiment with...
color_map{
[0 rgb 3]
[0 rgb <0,0,1>] // BLUE -- outside edge of pattern
[.48*T rgb <0,0,1>]
[.48*T rgb <1,1,0>]
[.52*T rgb <1,1,0>]
[.52*T rgb <1,0,0>]
[T rgb <1,0,0>]
[T rgb 3]
}
*/
scale L_2
translate CAM_LOCATION
}
object{OBJECT_1// already translated
pigment{SPHERE_PIG} // ditto
}
#debug concat("\n", "object SCALE = ",str(OBJECT_SCALE,0,9),"\n")
#debug concat("\n", "distance to bounding box NEAR corner (L_1) =
",str(vlength(NEAR_CORNER - CAM_LOCATION) - 0,0,9),"\n")
#debug concat("\n", "distance to bounding box FAR corner (L_2) =
",str(vlength(FAR_CORNER - CAM_LOCATION) - 0,0,9),"\n")
#debug concat("\n", "L_1/L_2 = ",str(L_1/L_2,0,9),
" (should never go over 1.0 !)","\n")
#debug concat("\n", "T = ",str(T,0,9),"\n")
Post a reply to this message
Attachments:
Download 'chromadepth_example.jpg' (225 KB)
Preview of image 'chromadepth_example.jpg'
|
|