POV-Ray : Newsgroups : povray.binaries.images : BOXED pattern with image_map, as DECAL Server Time
2 Nov 2024 18:51:46 EDT (-0400)
  BOXED pattern with image_map, as DECAL (Message 1 to 6 of 6)  
From: Kenneth
Subject: BOXED pattern with image_map, as DECAL
Date: 1 Apr 2010 11:45:00
Message: <web.4bb4bd96b883f0ef65f302820@news.povray.org>
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'
boxed_decal_example.jpg


 

From: Christian Froeschlin
Subject: Re: BOXED pattern with image_map, as DECAL
Date: 1 Apr 2010 13:27:28
Message: <4bb4d780@news.povray.org>
Kenneth wrote:

> the documentation isn't completely clear about how the map's index values treat
> an image_map. 

there is no special treatement for image_maps. If the value
you put before the image_map entry is V, and the boxed pattern
at a certain point in space evaluates to x (0<=x<=1), then the
resulting pigment is:

  x ==  0  ==> Fully transparent
  x >=  V  ==> Pigment as specified at V (last entry in map)
0 < x < V ==> Resulting pigment is weighted average of
               fully tansparent and specified pigment
               depending on how close x is to 0 or V.

E.g. if x = 0.5*V you will get 50% transparency. For your
decal you don't want fading from the center so you need a very
small value for V.

> Note the horizontal wing, and how the image is barely visible on
> it--I scaled the box very thin to get that.

if possible, it will of course be preferrable to apply the
texture to the target object *before* adding extra geometry,
so it will not be visible at all on the horizontal part.
But I assume this was just for demonstration ;)


Post a reply to this message

From: Kenneth
Subject: Re: BOXED pattern with image_map, as DECAL
Date: 1 Apr 2010 17:10:01
Message: <web.4bb50a6ca7ba370565f302820@news.povray.org>
Christian Froeschlin <chr### [at] chrfrde> wrote:

> there is no special treatement for image_maps. If the value
> you put before the image_map entry is V, and the boxed pattern
> at a certain point in space evaluates to x (0<=x<=1), then the
> resulting pigment is:
>
>   x ==  0  ==> Fully transparent
>   x >=  V  ==> Pigment as specified at V (last entry in map)
> 0 < x < V ==> Resulting pigment is weighted average of
>                fully tansparent and specified pigment
>                depending on how close x is to 0 or V.

All true, of course. Basically like 'spherical.' BTW, what I have a somewhat
difficult time with (always, it seems) is the 'order' of the index list for
these kinds of patterns. Just a difficulty in keeping the spatial ordering in my
head.
[0.0] // *outside*
[1.0] // *inside*
My own way of visualizing this is...backwards. I.e., 0.0 tells me its the
origin, and 1.0 looks like 1-unit from the origin and everything outside. I have
to *re-think* every time I use such a pattern. I need to cement into my brain
that the values really mean 'weight' or intensity, leading away from the
origin--the origin having a weight of 1.0  (That may not even be the correct
paradigm--but it helps me.) What screws me up is that gradient y (or x or z) has
an index list that implies [0.0...] *as* the origin--the pattern goes up from
there.  And that's the first pattern I learned to use. Of course, the docs
describe each of these patterns correctly--but I still have a hard time.

>
> E.g. if x = 0.5*V you will get 50% transparency. For your
> decal you don't want fading from the center so you need a very
> small value for V.

That's the little bit that threw me off initially.
>
> > Note the horizontal wing, and how the image is barely visible on
> > it--I scaled the box very thin to get that.
>
> if possible, it will of course be preferrable to apply the
> texture to the target object *before* adding extra geometry,
> so it will not be visible at all on the horizontal part.
> But I assume this was just for demonstration ;)

Yes, just as a demo. I completely agree: If possible, such a decal should be on
only one object, before being made part of a larger CGS construct. My scene is
really meant to show what is possible even in the worst cases. And it was fun to
do.  ;-)

My B-29 bomber model isn't textured 'correctly' (neither is this simple example
scene)--the major texture in both cases is just a regular 3-D cells pattern,
applied once to the entire model, rather than its parts. (And it shouldn't be
3-D in any case, but rather wrapped around the parts using uv-mapping or some
such.)  But that being the case, this decal idea came in very handy, as a simple
addition to the entire object.

Ken


Post a reply to this message

From: Alain
Subject: Re: BOXED pattern with image_map, as DECAL
Date: 1 Apr 2010 17:30:12
Message: <4bb51064@news.povray.org>

> 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.
>

Let see, render with +ua and another color_map for the cells pattern and 
some other image_map.
Change the name.
Render again with the previous image.


Alain


Post a reply to this message


Attachments:
Download 'boxed trick.jpg' (53 KB)

Preview of image 'boxed trick.jpg'
boxed trick.jpg


 

From: Kenneth
Subject: Re: BOXED pattern with image_map, as DECAL
Date: 2 Apr 2010 02:35:01
Message: <web.4bb58f52a7ba370565f302820@news.povray.org>
Alain <aze### [at] qwertyorg> wrote:

> Let see, render with +ua and another color_map for the cells pattern and
> some other image_map.
> Change the name.
> Render again with the previous image.

Very clever; somewhat like an infinite regression.


Post a reply to this message

From: Christian Froeschlin
Subject: Re: BOXED pattern with image_map, as DECAL
Date: 5 Apr 2010 12:53:53
Message: <4bba15a1$1@news.povray.org>
Kenneth wrote:

> My own way of visualizing this is...backwards. I.e., 0.0 tells me its
> the origin, and 1.0 looks like 1-unit from the origin and everything
> outside. I have to *re-think* every time I use such a pattern.

I also confuse this very often. But of course, the index list has no 
notion of inside or outside or distance from anything. It all depends
on they way the pattern function is defined. And the pattern functions
are general: if you use spherical for media you will often be happy
that the densest point is in the center ;)

You could easily create an inverted spherical pattern function:

#declare f_spherical_inverted = function(x,y,z) {1-f_spherical(x,y,z)}

pigment
{
   function{f_spherical_inverted(x,y,z)}
   color_map {[0.0 color Black] [1.0 color White]}
}

But it will evaluate somewhat slower than the built-in spherical.


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.