POV-Ray : Newsgroups : povray.general : hi~, everybody, how to modulate two bmp files with the third bmp file? Server Time
31 Oct 2024 23:28:39 EDT (-0400)
  hi~, everybody, how to modulate two bmp files with the third bmp file? (Message 1 to 8 of 8)  
From: lien0n
Subject: hi~, everybody, how to modulate two bmp files with the third bmp file?
Date: 10 Mar 2005 03:45:00
Message: <web.42300839aa72325b598059850@news.povray.org>
For instance, I.ve got two files "wet.bmp" and "dry.bmp", and the third
file's name is "factor.bmp". All of them are of the same resolution,
256*128 for example.

Now, I want to use them to generate a new pigment. I've got the following:

#declare Wetting=function{ pigment {image_map{sys "wet.bmp"} }}
#declare Drying=function{ pigment {image_map{sys "dry.bmp"} }}
#declare Factor=function{ pigment {image_map{sys "factor.bmp"} }}

plane{z,-0.00001
  pigment {
    image_map {
      function 256 128 { pigment {
        color (1-Factor(x,y,z).gray)*Wetting(x,y,z) +
Drying(x,y,z)*Factor(x,y,z).gray     (*)
      }}
    }
  }
}

But when parsing, error message appears at line (*):
   Parse Error: Float expected but vector or color expression found.
It seems that (x,y,z), I use to locate the pixel, does not work. Maybe i am
still not familiar enough with the syntex of how to use
user-defined-fuction, and maybe there is an other way to implement what i
want to do.

So any advice will be deeply appreciated!


Post a reply to this message

From: Mienai
Subject: Re: hi~, everybody, how to modulate two bmp files with the third bmp file?
Date: 10 Mar 2005 04:10:00
Message: <web.42300df4a2703140c7fccea0@news.povray.org>
"lien0n" <nomail@nomail> wrote:
> It seems that (x,y,z), I use to locate the pixel, does not work. Maybe i am
> still not familiar enough with the syntex of how to use
> user-defined-fuction, and maybe there is an other way to implement what i
> want to do.
>
> So any advice will be deeply appreciated!

If I'm not mistaken, x,y, and z are reserved for the POV-Ray coordinate
system only.  Try using (X,Y,Z) for your functions.


Post a reply to this message

From: lien0n
Subject: Re: hi~, everybody, how to modulate two bmp files with the third bmp file?
Date: 10 Mar 2005 04:35:00
Message: <web.423013d6a2703140598059850@news.povray.org>
"Mienai" <Mienai> wrote:
> "lien0n" <nomail@nomail> wrote:
> > It seems that (x,y,z), I use to locate the pixel, does not work. Maybe i am
> > still not familiar enough with the syntex of how to use
> > user-defined-fuction, and maybe there is an other way to implement what i
> > want to do.
> >
> > So any advice will be deeply appreciated!
>
> If I'm not mistaken, x,y, and z are reserved for the POV-Ray coordinate
> system only.  Try using (X,Y,Z) for your functions.

Another error:
undeclared identifier X found instead.

Thx anyway!


Post a reply to this message

From: lien0n
Subject: Re: hi~, everybody, how to modulate two bmp files with the third bmp file?
Date: 10 Mar 2005 05:35:01
Message: <web.42302284a2703140598059850@news.povray.org>
"lien0n" <nomail@nomail> wrote:
> "Mienai" <Mienai> wrote:
> > "lien0n" <nomail@nomail> wrote:
> > > It seems that (x,y,z), I use to locate the pixel, does not work. Maybe i am
> > > still not familiar enough with the syntex of how to use
> > > user-defined-fuction, and maybe there is an other way to implement what i
> > > want to do.
> > >
> > > So any advice will be deeply appreciated!
> >
> > If I'm not mistaken, x,y, and z are reserved for the POV-Ray coordinate
> > system only.  Try using (X,Y,Z) for your functions.
>
> Another error:
> undeclared identifier X found instead.
>
> Thx anyway!

of course,if i add something like this:
#local X=0;
#local Y=0;
#local Z=0;
then Factor(X,Y,Z) would not to iterate inside the whole bmp, it just
extract the value at pixel (0,0,0).


Post a reply to this message

From: Mike Williams
Subject: Re: hi~, everybody, how to modulate two bmp files with the third bmp file?
Date: 10 Mar 2005 05:43:04
Message: <SVV3KEAZSCMCFwxB@econym.demon.co.uk>
Wasn't it lien0n who wrote:
>For instance, I.ve got two files "wet.bmp" and "dry.bmp", and the third
>file's name is "factor.bmp". All of them are of the same resolution,
>256*128 for example.
>
>Now, I want to use them to generate a new pigment. I've got the following:
>
>#declare Wetting=function{ pigment {image_map{sys "wet.bmp"} }}
>#declare Drying=function{ pigment {image_map{sys "dry.bmp"} }}
>#declare Factor=function{ pigment {image_map{sys "factor.bmp"} }}
>
>plane{z,-0.00001
>  pigment {
>    image_map {
>      function 256 128 { pigment {
>        color (1-Factor(x,y,z).gray)*Wetting(x,y,z) +
>Drying(x,y,z)*Factor(x,y,z).gray     (*)
>      }}
>    }
>  }
>}
>
>But when parsing, error message appears at line (*):
>   Parse Error: Float expected but vector or color expression found.
>It seems that (x,y,z), I use to locate the pixel, does not work. Maybe i am
>still not familiar enough with the syntex of how to use
>user-defined-fuction, and maybe there is an other way to implement what i
>want to do.
>
>So any advice will be deeply appreciated!

Although POV defines colour functions, I'm pretty sure that you can't
use them as render-time colours.

At parse time you can pick individual colours from individual points of
a colour function, like

   #declare My_Colour = Wetting(1,2,3) * (1-Factor(1,2,3).gray);

You can use a render-time float function as PATTERN of a pigment, but
you can't use render-time colour functions as the COLOUR of a pigment.

So what you can do is to declare Wetting and Drying as simple pigments,
not functions, use the float function "Factor(x,y,z).gray" as a pattern,
and then use that pattern as a pigment_map to map two image_mapped
pigments, like this:


#declare Wetting = pigment {image_map{sys "wet.bmp"} }
#declare Drying = pigment {image_map{sys "dry.bmp"} }
#declare Factor = function {pigment {image_map{sys "factor.bmp"} }}

plane{z,-0.00001
  pigment {
    function{Factor(x,y,z).gray}
    pigment_map {
      [0.0 Wetting]
      [1.0 Drying]
    }  
  }
}


I believe that gives you the particular effect that you were trying to
achieve. It's a lot less flexible than render type colour functions
would be, but you don't need that flexibility in this particular case.

-- 
Mike Williams
Gentleman of Leisure


Post a reply to this message

From: Christopher James Huff
Subject: Re: hi~, everybody, how to modulate two bmp files with the third bmp file?
Date: 10 Mar 2005 09:17:03
Message: <cjameshuff-060E72.09170110032005@news.povray.org>
In article <web.42300839aa72325b598059850@news.povray.org>,
 "lien0n" <nomail@nomail> wrote:

> plane{z,-0.00001
>   pigment {
>     image_map {
>       function 256 128 { pigment {
>         color (1-Factor(x,y,z).gray)*Wetting(x,y,z) +
> Drying(x,y,z)*Factor(x,y,z).gray     (*)
>       }}
>     }
>   }
> }

Break the pigment out to see what's going wrong:
pigment {
    color (1-Factor(x,y,z).gray)*Wetting(x,y,z) +
           Drying(x,y,z)*Factor(x,y,z).gray
}

Put simply...you can't do this. There's no mechanism in standard POV-Ray 
for taking a color function and using it directly as a pigment color. If 
there were (and if this were corrected to extract gray values from 
Wetting() and Drying()), this would still give a grayscale result.

It is possible, though...just a bit tricky. You have to average 3 
separate pigments, with the colors multiplied by 3 to counter the divide 
in the average so you can get a straight add.

pigment {average
    pigment_map {
        [1
            function {(1-Factor(x,y,z).red)*Wetting(x,y,z).red +
               Drying(x,y,z).red*Factor(x,y,z).red}
            color_map {[0 rgb 0] [1 red 3]}
        ]
        [1
            function {(1-Factor(x,y,z).green)*Wetting(x,y,z).green +
               Drying(x,y,z).green*Factor(x,y,z).green}
            color_map {[0 rgb 0] [1 green 3]}
        ]
        [1
            function {(1-Factor(x,y,z).blue)*Wetting(x,y,z).blue +
               Drying(x,y,z).blue*Factor(x,y,z).blue}
            color_map {[0 rgb 0] [1 blue 3]}
        ]
    }
}

Oh, and for the sake of your disk space, bandwidth, and everyone else, 
please don't use BMPs. PNGs let you do everything they do and more, are 
compressed, and are lossless.

-- 
Christopher James Huff <cja### [at] gmailcom>
POV-Ray TAG: <chr### [at] tagpovrayorg>
http://tag.povray.org/


Post a reply to this message

From: lien0n
Subject: Re: hi~, everybody, how to modulate two bmp files with the third bmp file?
Date: 10 Mar 2005 21:10:00
Message: <web.4230fc88a2703140598059850@news.povray.org>
Mike Williams <nos### [at] econymdemoncouk> wrote:
> Although POV defines colour functions, I'm pretty sure that you can't
> use them as render-time colours.
>
> At parse time you can pick individual colours from individual points of
> a colour function, like
>
>    #declare My_Colour = Wetting(1,2,3) * (1-Factor(1,2,3).gray);
>
> You can use a render-time float function as PATTERN of a pigment, but
> you can't use render-time colour functions as the COLOUR of a pigment.
>
> So what you can do is to declare Wetting and Drying as simple pigments,
> not functions, use the float function "Factor(x,y,z).gray" as a pattern,
> and then use that pattern as a pigment_map to map two image_mapped
> pigments, like this:
>
> #declare Wetting = pigment {image_map{sys "wet.bmp"} }
> #declare Drying = pigment {image_map{sys "dry.bmp"} }
> #declare Factor = function {pigment {image_map{sys "factor.bmp"} }}
>
> plane{z,-0.00001
>   pigment {
>     function{Factor(x,y,z).gray}
>     pigment_map {
>       [0.0 Wetting]
>       [1.0 Drying]
>     }
>   }
> }
>
> I believe that gives you the particular effect that you were trying to
> achieve. It's a lot less flexible than render type colour functions
> would be, but you don't need that flexibility in this particular case.
>
> --
> Mike Williams
> Gentleman of Leisure

wow~~,it works, firstly thks so much!
But will you pls to say something about how to use flexible colour functions
at render-time?


Post a reply to this message

From: lien0n
Subject: Re: hi~, everybody, how to modulate two bmp files with the third bmp file?
Date: 10 Mar 2005 22:45:01
Message: <web.423113d2a2703140598059850@news.povray.org>
Christopher James Huff <cja### [at] gmailcom> wrote:
> In article <web.42300839aa72325b598059850@news.povray.org>,
>  "lien0n" <nomail@nomail> wrote:
>
> > plane{z,-0.00001
> >   pigment {
> >     image_map {
> >       function 256 128 { pigment {
> >         color (1-Factor(x,y,z).gray)*Wetting(x,y,z) +
> > Drying(x,y,z)*Factor(x,y,z).gray     (*)
> >       }}
> >     }
> >   }
> > }
>
> Break the pigment out to see what's going wrong:
> pigment {
>     color (1-Factor(x,y,z).gray)*Wetting(x,y,z) +
>            Drying(x,y,z)*Factor(x,y,z).gray
> }
>
> Put simply...you can't do this. There's no mechanism in standard POV-Ray
> for taking a color function and using it directly as a pigment color. If
> there were (and if this were corrected to extract gray values from
> Wetting() and Drying()), this would still give a grayscale result.
>
> It is possible, though...just a bit tricky. You have to average 3
> separate pigments, with the colors multiplied by 3 to counter the divide
> in the average so you can get a straight add.
>
> pigment {average
>     pigment_map {
>         [1
>             function {(1-Factor(x,y,z).red)*Wetting(x,y,z).red +
>                Drying(x,y,z).red*Factor(x,y,z).red}
>             color_map {[0 rgb 0] [1 red 3]}
>         ]
>         [1
>             function {(1-Factor(x,y,z).green)*Wetting(x,y,z).green +
>                Drying(x,y,z).green*Factor(x,y,z).green}
>             color_map {[0 rgb 0] [1 green 3]}
>         ]
>         [1
>             function {(1-Factor(x,y,z).blue)*Wetting(x,y,z).blue +
>                Drying(x,y,z).blue*Factor(x,y,z).blue}
>             color_map {[0 rgb 0] [1 blue 3]}
>         ]
>     }
> }
>
> Oh, and for the sake of your disk space, bandwidth, and everyone else,
> please don't use BMPs. PNGs let you do everything they do and more, are
> compressed, and are lossless.
>
> --
> Christopher James Huff <cja### [at] gmailcom>
> POV-Ray TAG: <chr### [at] tagpovrayorg>
> http://tag.povray.org/

Yes, i tried and it works, many thks!


Post a reply to this message

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