POV-Ray : Newsgroups : povray.general : hi~, everybody, how to modulate two bmp files with the third bmp file? : Re: hi~, everybody, how to modulate two bmp files with the third bmp file? Server Time
1 Aug 2024 22:23:33 EDT (-0400)
  Re: hi~, everybody, how to modulate two bmp files with the third bmp file?  
From: Mike Williams
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

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