|
|
I've only lately realized that the BOXED pattern can be used (with an image_map)
as a way to place a decal on an object--sticking the image onto only a *single*
surface in a particular location. (A more-or-less flat surface, of course, to
avoid distortion.) The tail number on my B-29 bomber is an example. I don't know
why this idea never occurred to me before; it's so obvious now(!)-- maybe I'm
the last person on the planet to know. But it doesn't immediately spring to mind
when reading the bare-bones documentation. Some newsgroup posts of the past have
given clues, but I never picked up on them. :-( I've included my example scene
below, to help others who may not have realized its potential.
Most folks would use uv-mapping for this, I guess (or maybe 'cylindrical' or
'spherical'); but IMO, boxed is easier to 'grasp' and implement for such a small
application. The decal can look distorted on a complex, bumpy object--but that's
better dealt with through uv-mapping anyway.
A typical/default planar-projected image_map applies the image 'infinitely in
z'--it shows up on both front and rear surfaces of an object. The BOXED pattern
restricts the image to a 2X2 square volume of space (filling it)--which can then
be scaled/rotated/positioned to apply the image *just so* onto only one surface,
of even a very thin object. (The box itself is automatically centered on the
origin, but the image_map is not--so a small translation is needed.)
Rotation/translation of the box can be tricky, of course, to get the decal into
proper position on an object, with the image 'parallel' to a surface. The box
itself can be scaled thinner if necessary, to place the decal onto one surface
of some closely-spaced objects in a union--squashing down the box/image to be
almost plane-like; but simply moving the box around in space will usually
suffice.
The pattern needs a 'map' of some kind to work with--a pigment_map in this case.
And only two index entries (for visually-understandable results, anyway.) IMO,
the documentation isn't completely clear about how the map's index values treat
an image_map. A small value like 0.0001 keeps the edges of the image sharp--you
can vary that up to 1.0 or even higher to blend it into the 'outside' color.
Here's my complete test scene (just plug in your own image.) Play around with
the parameters. Note the horizontal wing, and how the image is barely visible on
it--I scaled the box very thin to get that.
Ken
...................
//global_settings{assumed_gamma 2.2} // I'm using v3.6.1c
camera {
perspective
location <0, 2, -10>
look_at <0, 0, 0>
right x*image_width/image_height
angle 25
rotate -30*y // make this 30*y to see the other side
}
light_source {
0*x
color rgb <1,1,1>
translate <-100, 40, -20>
}
light_source {
0*x
color rgb <1,1,1>
translate <30, 40, -5>
}
light_source {
0*x
color rgb <1,1,1>*.7
translate <5, 100, 0>
}
background{rgb .6}
union{
sphere{0,1.5 scale <.1,1,1>}
sphere{0,1 scale <2,.1,.8> translate <0,-.6,.6>}
sphere{0,1 scale 1.2*<.1,.5,.4> translate <-1.6,-.2,.5>}
sphere{0,1 scale 1.6*<.1,.5,.4> translate <-1,-.2,.5>}
sphere{0,1 scale 1.6*<.1,.5,.4> translate <1,-.2,.5>}
sphere{0,1 scale 1.2*<.1,.5,.4> translate <1.6,-.2,.5>}
texture{
pigment{cells scale .1
color_map{[0.0 rgb .7*<.5,.6,1>][1.0 rgb .9*<.5,.6,.9>]}
}
finish{ambient .4 diffuse .5 phong .5 phong_size 10}
}
texture{
pigment{
boxed
pigment_map{
[0.0 rgbt 1] // everywhere *outside* the box
[0.0001 image_map{png "my_image.png" once interpolate 2}
// without ONCE, the image_map repeats as usual, but only INSIDE the 2X2
// box; depends on image scale below, of course.
translate -.5 // BOXED is already centered on the origin, but the
// image_map isn't, by default. Translating an image_map in z has no
// effect.
scale 2 // usually 2--to make a standard 1X1 image_map fill the 2X2 box
// size. Scaling an image_map in z has no effect, as usual. Scaling
// larger than 2 will 'crop' the image--a useful trick in itself.
]
}
scale <1,1,.05>
rotate -90*y // whatever is needed to align image 'parallel' to a surface
translate <.101,0,0>
}
finish{ambient .4 diffuse .6 phong .5 phong_size 10}
}
}
Post a reply to this message
Attachments:
Download 'boxed_decal_example.jpg' (207 KB)
Preview of image 'boxed_decal_example.jpg'
|
|