POV-Ray : Newsgroups : povray.general : How to adjust image_map? Server Time: 30 Mar 2020 14:10:23 GMT
  How to adjust image_map? (Message 1 to 9 of 9)  
From: Kima
Subject: How to adjust image_map?
Date: 20 Feb 2020 09:40:00
Message: <web.5e4e53bf16a63c05ecc0fada0@news.povray.org>
I wrap an image over a lathe by

lathe{
  cubic_spline 8,
     < 0.00, 0.00>,
     < 0.60, 0.00>,
     < 0.72, 0.44>,
     < 0.31, 0.93>,
     < 0.49, 1.26>,
     < 0.48, 1.35>,
     < 0.43, 1.56>,
     < 0.16, 1.60>
     texture{
         pigment{
             color rgb<1,0,0>
         }
     }
     texture{
         pigment{
             image_map{
                 png "image.png" map_type 2 interpolate 4 once

             }

         }
     }
}

I have two problems:

1. image_map put the image on the object from the bottom (from south to north).
Thus, if the image height is not enough to cover the object, it is always the
top part, which is missing.

How can I put the image from top to bottom or even on the middle (with respect
to the y-axis)?

I can move the image by translate<0,0.5,0>, but it is not practical as I have to
find the image height on the object.

We need something like Center_Object, but image_map is not an object.

2. map_type 2 makes a full wrap cylindrically. How can I make image_map half
wrap or to a custom degree (instead of 360)?

By scale, we can control the image over the y-axis, but the scale on the x-axis
has no effect.


Post a reply to this message

From: jr
Subject: Re: How to adjust image_map?
Date: 20 Feb 2020 13:05:00
Message: <web.5e4e831b8411a31b451952ca0@news.povray.org>
hi,

"Kima" <nomail@nomail> wrote:
> I wrap an image over a lathe by
>
> lathe{
>   cubic_spline 8,
>      < 0.00, 0.00>,
>      < 0.60, 0.00>,
>      < 0.72, 0.44>,
>      < 0.31, 0.93>,
>      < 0.49, 1.26>,
>      < 0.48, 1.35>,
>      < 0.43, 1.56>,
>      < 0.16, 1.60>
>      texture{
>          pigment{
>              color rgb<1,0,0>
>          }
>      }
>      texture{
>          pigment{
>              image_map{
>                  png "image.png" map_type 2 interpolate 4 once
>
>              }
>
>          }
>      }
> }
>
> I have two problems:
>
> 1. image_map put the image on the object from the bottom (from south to north).
> Thus, if the image height is not enough to cover the object, it is always the
> top part, which is missing.
>
> How can I put the image from top to bottom or even on the middle (with respect
> to the y-axis)?

using your code as posted, I inserted:
pigment {
  image_map {...}
  rotate <270,0,0>
}

and the image covers the shape.  no ideas wrt second question.


regards, jr.


Post a reply to this message

From: Kima
Subject: Re: How to adjust image_map?
Date: 20 Feb 2020 20:45:07
Message: <web.5e4eeee78411a31becc0fada0@news.povray.org>
"jr" <cre### [at] gmailcom> wrote:
> hi,
>
> "Kima" <nomail@nomail> wrote:
> > I wrap an image over a lathe by
> >
> > lathe{
> >   cubic_spline 8,
> >      < 0.00, 0.00>,
> >      < 0.60, 0.00>,
> >      < 0.72, 0.44>,
> >      < 0.31, 0.93>,
> >      < 0.49, 1.26>,
> >      < 0.48, 1.35>,
> >      < 0.43, 1.56>,
> >      < 0.16, 1.60>
> >      texture{
> >          pigment{
> >              color rgb<1,0,0>
> >          }
> >      }
> >      texture{
> >          pigment{
> >              image_map{
> >                  png "image.png" map_type 2 interpolate 4 once
> >
> >              }
> >
> >          }
> >      }
> > }
> >
> > I have two problems:
> >
> > 1. image_map put the image on the object from the bottom (from south to north).
> > Thus, if the image height is not enough to cover the object, it is always the
> > top part, which is missing.
> >
> > How can I put the image from top to bottom or even on the middle (with respect
> > to the y-axis)?
>
> using your code as posted, I inserted:
> pigment {
>   image_map {...}
>   rotate <270,0,0>
> }
>
> and the image covers the shape.  no ideas wrt second question.
>
>
> regards, jr.

rotating the image_map deforms the image appearance. I do not want to change the
image direction. I just want to move it up. 'translate <0,y,0>' does the job,
but the problem is that I do not have a practical method to calculate `y` to
move the image to the top.


Post a reply to this message

From: Bald Eagle
Subject: Re: How to adjust image_map?
Date: 20 Feb 2020 20:50:01
Message: <web.5e4ef0d58411a31b4eec112d0@news.povray.org>
"Kima" <nomail@nomail> wrote:

> 1. image_map put the image on the object from the bottom (from south to north).
> Thus, if the image height is not enough to cover the object, it is always the
> top part, which is missing.
>
> How can I put the image from top to bottom or even on the middle (with respect
> to the y-axis)?
>
> I can move the image by translate<0,0.5,0>, but it is not practical as I have to
> find the image height on the object.
>
> We need something like Center_Object, but image_map is not an object.

And image map is always like a square in the x-y plane, infinite in the
z-direction, unless rotated.




> 2. map_type 2 makes a full wrap cylindrically. How can I make image_map half
> wrap or to a custom degree (instead of 360)?

IIRC, you omit the "once" keyword, and then you can scale your image by 0.5 with
respect to the object's circumference.

> By scale, we can control the image over the y-axis, but the scale on the x-axis
> has no effect.

When I do my image maps, I do the following:
        #declare XSize = 1.965;
 #declare ImageMap =
          pigment {image_map {png ImageFilename once} };
 #declare Resolution = max_extent (ImageMap);
 #declare Resolution = Resolution + <0, 0, 1>;
This gives me a vector with <Xpixels, Ypixels, 1>

Then I make an actual box:
Notice the formula for scaling, which keeps the aspect ratio of the original
image.

 #declare ImageMappedBox =
  box {0, 1
   texture {
    pigment {ImageMap}
    finish {diffuse 1}
   }
   translate <-0.5, -0.5, 0>
   scale Resolution*(1/Resolution.x)*XSize
   //translate y*(Resolution.y / Resolution.x)*XSize/2
  }

object {ImageMappedBox rotate x*90 translate Offset scale ImageScale}

You might make a demo file for yourself that does everything you want, and keep
a copy in your Insert Menu directory.


Post a reply to this message

From: Alain Martel
Subject: Re: How to adjust image_map?
Date: 20 Feb 2020 21:02:47
Message: <5e4ef3f7$1@news.povray.org>
Le 2020-02-20 à 04:39, Kima a écrit :
> I wrap an image over a lathe by
> 
> lathe{
>    cubic_spline 8,
>       < 0.00, 0.00>,
>       < 0.60, 0.00>,
>       < 0.72, 0.44>,
>       < 0.31, 0.93>,
>       < 0.49, 1.26>,
>       < 0.48, 1.35>,
>       < 0.43, 1.56>,
>       < 0.16, 1.60>
>       texture{
>           pigment{
>               color rgb<1,0,0>
>           }
>       }
>       texture{
>           pigment{
>               image_map{
>                   png "image.png" map_type 2 interpolate 4 once
> 
>               }
> 
>           }
>       }
> }
> 
> I have two problems:
> 
> 1. image_map put the image on the object from the bottom (from south to north).
> Thus, if the image height is not enough to cover the object, it is always the
> top part, which is missing.

You need to scale the image vertically to the height of the object.
scale<1, Object_Height, 1>

> 
> How can I put the image from top to bottom or even on the middle (with respect
> to the y-axis)?

You can use : scale<1, -1, 1> or scale<1, -Object_Height, 1>
This will flip the image vertically.
scale<-1, 1, 1> will reverse the direction of the wrap.
scale<1, 1, -1> have no effect.

> 
> I can move the image by translate<0,0.5,0>, but it is not practical as I have to
> find the image height on the object.

By default, the image height's is one unit. The bottom is at zero and 
the top at 1.
If the image is smaller than the object, and you don't use «once», then, 
it will be visible multiple times.

> 
> We need something like Center_Object, but image_map is not an object.
> 
> 2. map_type 2 makes a full wrap cylindrically. How can I make image_map half
> wrap or to a custom degree (instead of 360)?

Scale the image along the X direction. For a half wrap, use
scale<0.5, 1, 1>

For a specific number of degree, it's :

scale<Degree/360, 1, 1>

> 
> By scale, we can control the image over the y-axis, but the scale on the x-axis
> has no effect.
> 
>


Post a reply to this message

From: Alain Martel
Subject: Re: How to adjust image_map?
Date: 20 Feb 2020 21:14:38
Message: <5e4ef6be$1@news.povray.org>
Le 2020-02-20 à 15:41, Kima a écrit :
> "jr" <cre### [at] gmailcom> wrote:
>> hi,
>>
>> "Kima" <nomail@nomail> wrote:
>>> I wrap an image over a lathe by
>>>
>>> lathe{
>>>    cubic_spline 8,
>>>       < 0.00, 0.00>,
>>>       < 0.60, 0.00>,
>>>       < 0.72, 0.44>,
>>>       < 0.31, 0.93>,
>>>       < 0.49, 1.26>,
>>>       < 0.48, 1.35>,
>>>       < 0.43, 1.56>,
>>>       < 0.16, 1.60>
>>>       texture{
>>>           pigment{
>>>               color rgb<1,0,0>
>>>           }
>>>       }
>>>       texture{
>>>           pigment{
>>>               image_map{
>>>                   png "image.png" map_type 2 interpolate 4 once
>>>
>>>               }
>>>
>>>           }
>>>       }
>>> }
>>>
>>> I have two problems:
>>>
>>> 1. image_map put the image on the object from the bottom (from south to north).
>>> Thus, if the image height is not enough to cover the object, it is always the
>>> top part, which is missing.
>>>
>>> How can I put the image from top to bottom or even on the middle (with respect
>>> to the y-axis)?
>>
>> using your code as posted, I inserted:
>> pigment {
>>    image_map {...}
>>    rotate <270,0,0>
>> }
>>
>> and the image covers the shape.  no ideas wrt second question.
>>
>>
>> regards, jr.
> 
> rotating the image_map deforms the image appearance. I do not want to change the
> image direction. I just want to move it up. 'translate <0,y,0>' does the job,
> but the problem is that I do not have a practical method to calculate `y` to
> move the image to the top.
> 
> 

You know the vertical size of your object.
It's bottom is set at Y=0.

So, you only need to scale by the vertical size of the object : 1.56.

Add :
scale<1, 1.56, 1>
to the pigment.

If you don't know that dimension, you can use
#declare YSize = (min_extent(Object_ID)-max_extent(Object_ID)).y;
Then, use :
scale<1, YSize, 1>

If you want to also flip the image vertically, then, do this :

scale <1, -YSize, 1>// Adjust height and flip.

If you don't use «once», there is no need to translate the image as one 
of the instances will fall at the correct place.


Post a reply to this message

From: Kima
Subject: Re: How to adjust image_map?
Date: 21 Feb 2020 04:30:00
Message: <web.5e4f5bd48411a31becc0fada0@news.povray.org>
Alain Martel <kua### [at] videotronca> wrote:

> > 2. map_type 2 makes a full wrap cylindrically. How can I make image_map half
> > wrap or to a custom degree (instead of 360)?
>
> Scale the image along the X direction. For a half wrap, use
> scale<0.5, 1, 1>
>
> For a specific number of degree, it's :
>
> scale<Degree/360, 1, 1>
>
> >
> > By scale, we can control the image over the y-axis, but the scale on the x-axis
> > has no effect.
> >
> >

I learned a lot from your tips, but I could not implement your approach for a
half wrap. As I mentioned before, x-scale does not control the size as y-scale
does.

Could you please elaborate on how you implement it?

In my case, scale<0.5,0.5, 1> leads to half-height but still full (360-degree)
cylindrical wrap.


Post a reply to this message

From: Bald Eagle
Subject: Re: How to adjust image_map?
Date: 21 Feb 2020 19:00:01
Message: <web.5e5027eb8411a31b4eec112d0@news.povray.org>
"Kima" <nomail@nomail> wrote:

> In my case, scale<0.5,0.5, 1> leads to half-height but still full (360-degree)
> cylindrical wrap.

I think that might be the nature of the cylindrical mapping mechanism.
If you want to make it only cover half of the circumference, you might need to
buffer the image on either side with half as many pixels in a transparent
"color".

But I did get what I think you want using uv_mapping.

#version 3.8;

global_settings {
 assumed_gamma 1
}

#include "colors.inc"


light_source {<1, 3, -3> color White}
sky_sphere {pigment {White}}

#declare Aspect = image_width/image_height;
camera {
 location <0, 2, -4>
 right x*Aspect
 up y
 sky y
 direction z
 look_at <0, 1, 0>
}

#declare YSize = 1.6;
 #declare ImageMap =
          pigment {image_map {"/home/oem/Documents/POV-Ray-3.8/0.gif" once} };
 #declare Resolution = max_extent (ImageMap);
 #declare Resolution = Resolution + <0, 0, 1>;

#declare Lathe =
lathe{
  cubic_spline 8,
     < 0.00, 0.00>,
     < 0.60, 0.00>,
     < 0.72, 0.44>,
     < 0.31, 0.93>,
     < 0.49, 1.26>,
     < 0.48, 1.35>,
     < 0.43, 1.56>,
     < 0.16, 1.60>
      uv_mapping
 pigment {Blue}

     texture{
      ImageMap translate <-0.5, 0, 0>
      scale Resolution*(1/Resolution.y)*YSize
      scale x*pi*(0.72/2)/2
     }

}

object {Lathe}

object {Lathe rotate -y*90 translate  -x*2}

object {Lathe rotate y*90 translate  x*2}


Post a reply to this message

From: Alain Martel
Subject: Re: How to adjust image_map?
Date: 22 Feb 2020 15:37:11
Message: <5e514aa7$1@news.povray.org>
Le 2020-02-20 à 23:25, Kima a écrit :
> Alain Martel <kua### [at] videotronca> wrote:
> 
>>> 2. map_type 2 makes a full wrap cylindrically. How can I make image_map half
>>> wrap or to a custom degree (instead of 360)?
>>
>> Scale the image along the X direction. For a half wrap, use
>> scale<0.5, 1, 1>
>>
>> For a specific number of degree, it's :
>>
>> scale<Degree/360, 1, 1>
>>
>>>
>>> By scale, we can control the image over the y-axis, but the scale on the x-axis
>>> has no effect.
>>>
>>>
> 
> I learned a lot from your tips, but I could not implement your approach for a
> half wrap. As I mentioned before, x-scale does not control the size as y-scale
> does.
> 
> Could you please elaborate on how you implement it?
> 
> In my case, scale<0.5,0.5, 1> leads to half-height but still full (360-degree)
> cylindrical wrap.
> 
> 

OK, my bad.
You need to use warp{cylindrical} for that purpose.
The default options are what you need, so, no need to add anything else 
than the warp itself.

It works like map_type 2, but allow the scaling that I proposed.

pigment{image_map{.... scale<0.5,1,1> warp{cylindrical} }}

Will wrap 180° from +X going counter clockwise.


Post a reply to this message

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