POV-Ray : Newsgroups : povray.general : Pb and question about pigment in function using an image Server Time
1 Aug 2024 02:14:09 EDT (-0400)
  Pb and question about pigment in function using an image (Message 1 to 3 of 3)  
From: Sylvain
Subject: Pb and question about pigment in function using an image
Date: 29 Jun 2006 12:35:00
Message: <web.44a40092b7293f675847c8f80@news.povray.org>
Hello there,

Is it a bug or (most probable) did I miss something ?

I have this very nice image of a checker (this is just for the sake of the
example and not the image I am actually using) stored in a file called
test.pgm:
content of test.pgm:
P2
2 2
255
0 100
100 0

I am using this image in a pigment function, or whatever you might want to
call that:
#local fn_pig= function {
  pigment {
    image_map {
      pgm "test.pgm"
      map_type 0
      interpolate 0
      once
    }
  }
}
#local fn_pig_Height=function { (fn_pig(x, y, 0).red ) }

Then, I just call this function many times, using a loop:
#declare Pas = 0.1;
#declare Loc_x = 0;
#while (Loc_x < 1)
  #declare Loc_y = 0;
  #while (Loc_y < 1)
    #debug concat("x=",str(Loc_x,3,3)," y=",str(Loc_y,3,3)," fn_pig_Height =
",str(fn_pig_Height(Loc_x,Loc_y,0),5,5),"n")
    #declare Loc_y = Loc_y + Pas;
  #end
  #debug "n"
  #declare Loc_x = Loc_x + Pas;
#end

and HERE IS MY QUESTION !!! For each x value strictly lower than 1, and for
each y value stricly lower than 1 (x<1 and y<1), I get what I expect (0 or
0.39216, which is 100/255, depending on x and y). But, for x=1 and
y=anything, or for y=1 and x=anything, I get the value 1 !!
What I expected was :
for x = 0 to 0.5 and y = 1, f(x,y) = 0
for x = 0.5+ to 1.0 and y = 1, f(x,y) = 0.39216
for y = 0 to 0.5 and x = 1, f(x,y) = 0
for y = 0.5+ to 1.0 and x = 1, f(x,y) = 0.39216

Isn't the image supposed to fit exactly on a square <0,0>, <1,1> in the x-y
plane ?

I would not have been surprised to get such a value (1) for any x or y
strictly greater than 1. Is it merely a matter of machine error (meaning
that 1.0 is in fact something like 1.00000000000000000000015135) ?

When I render this as an isosurface, I get a kind of wall around my
checker...
Could anyone help me out ?

Hope my description is clear. If not, please ask for more information...

S.


Post a reply to this message

From: NEWS
Subject: Re: Pb and question about pigment in function using an image
Date: 30 Jun 2006 04:28:13
Message: <44a4e09d@news.povray.org>
from the doc: at 'once'

Normally there are an infinite number of repeating image maps, bump maps or
material maps created over every unit square of the x-y-plane like tiles. By
adding the once keyword after a file name you can eliminate all other copies
of the map except the one at (0,0) to (1,1). In image maps, areas outside
this unit square are treated as fully transparent. In bump maps, areas
outside this unit square are left flat with no normal modification. In
material maps, areas outside this unit square are textured with the first
texture of the texture list.



That says that the image from outside a unit square ...

Well a unit square starts from <0,0> to <1,1> exclusive ..(<0,0> to
<0.99999..,0.99999..>)











news:web.44a40092b7293f675847c8f80@news.povray.org...
> Hello there,
>
> Is it a bug or (most probable) did I miss something ?
>
> I have this very nice image of a checker (this is just for the sake of the
> example and not the image I am actually using) stored in a file called
> test.pgm:
> content of test.pgm:
> P2
> 2 2
> 255
> 0 100
> 100 0
>
> I am using this image in a pigment function, or whatever you might want to
> call that:
> #local fn_pig= function {
>   pigment {
>     image_map {
>       pgm "test.pgm"
>       map_type 0
>       interpolate 0
>       once
>     }
>   }
> }
> #local fn_pig_Height=function { (fn_pig(x, y, 0).red ) }
>
> Then, I just call this function many times, using a loop:
> #declare Pas = 0.1;
> #declare Loc_x = 0;
> #while (Loc_x < 1)
>   #declare Loc_y = 0;
>   #while (Loc_y < 1)
>     #debug concat("x=",str(Loc_x,3,3)," y=",str(Loc_y,3,3)," fn_pig_Height
=
> ",str(fn_pig_Height(Loc_x,Loc_y,0),5,5),"n")
>     #declare Loc_y = Loc_y + Pas;
>   #end
>   #debug "n"
>   #declare Loc_x = Loc_x + Pas;
> #end
>
> and HERE IS MY QUESTION !!! For each x value strictly lower than 1, and
for
> each y value stricly lower than 1 (x<1 and y<1), I get what I expect (0 or
> 0.39216, which is 100/255, depending on x and y). But, for x=1 and
> y=anything, or for y=1 and x=anything, I get the value 1 !!
> What I expected was :
> for x = 0 to 0.5 and y = 1, f(x,y) = 0
> for x = 0.5+ to 1.0 and y = 1, f(x,y) = 0.39216
> for y = 0 to 0.5 and x = 1, f(x,y) = 0
> for y = 0.5+ to 1.0 and x = 1, f(x,y) = 0.39216
>
> Isn't the image supposed to fit exactly on a square <0,0>, <1,1> in the
x-y
> plane ?
>
> I would not have been surprised to get such a value (1) for any x or y
> strictly greater than 1. Is it merely a matter of machine error (meaning
> that 1.0 is in fact something like 1.00000000000000000000015135) ?
>
> When I render this as an isosurface, I get a kind of wall around my
> checker...
> Could anyone help me out ?
>
> Hope my description is clear. If not, please ask for more information...
>
> S.
>
>


Post a reply to this message

From: Sylvain
Subject: Re: Pb and question about pigment in function using an image
Date: 30 Jun 2006 06:40:01
Message: <web.44a4ff7a17dd11819e4a59f60@news.povray.org>
"NEWS" <pen### [at] caramailfr> wrote:
> from the doc: at 'once'
>
> Normally there are an infinite number of repeating image maps, bump maps or
> material maps created over every unit square of the x-y-plane like tiles. By
> adding the once keyword after a file name you can eliminate all other copies
> of the map except the one at (0,0) to (1,1). In image maps, areas outside
> this unit square are treated as fully transparent. In bump maps, areas
> outside this unit square are left flat with no normal modification. In
> material maps, areas outside this unit square are textured with the first
> texture of the texture list.
>
>
>
> That says that the image from outside a unit square ...
>
> Well a unit square starts from <0,0> to <1,1> exclusive ..(<0,0> to
> <0.99999..,0.99999..>)
>

Yes, after I removed the 'once' keyword, according to your advice, I got the
same calculated values for x=1 than for x=0.
I did not quite realized that, if you want to tile 1-unit squares, they have
to stretch from (i) to (i+1-epsilon) so that they don't overlap each others
at (i+1).
Thank you for the tip !
S.


Post a reply to this message

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