POV-Ray : Newsgroups : povray.general : Pigment multiplication Server Time
31 Jul 2024 18:18:49 EDT (-0400)
  Pigment multiplication (Message 1 to 5 of 5)  
From: FlyerX
Subject: Pigment multiplication
Date: 14 Dec 2006 07:25:15
Message: <458142ab$1@news.povray.org>
Hello,

I would like to know if a pigment using an image_map can be multiplied 
by a color and the result applied as a new pigment in a texture. I tried 
with a filtered pigment on top of a solid color but it results in a 
washed-out pigment even with a white base as below.

material{
texture{pigment {color rgb <1,1,1>} finish{ambient rgb 0}}
texture{pigment {uv_mapping image_map{jpeg "body_01.jpg" interpolate 2 
transmit all 0 filter all 1} }}
}



Thanks,

FlyerX


Post a reply to this message

From: Skip Talbot
Subject: Re: Pigment multiplication
Date: 14 Dec 2006 10:16:35
Message: <45816ad3@news.povray.org>
I don't have time to write out the source, but I can suggest a possible 
solution if you are looking for a quick answer.  Use your image map as a 
pigment function, and then you should be able to directly multiply the 
output of the function by whatever scalar you want.  The function and 
its multiplied scalar can then be declared as a new pigment function. 
Hopefully one of the pros can help get you setup with this approach if 
you have any trouble.

Skip


Post a reply to this message

From: Trevor G Quayle
Subject: Re: Pigment multiplication
Date: 14 Dec 2006 12:15:00
Message: <web.4581856fe92a14b7c150d4c10@news.povray.org>
Skip Talbot <ski### [at] aolcom> wrote:
> I don't have time to write out the source, but I can suggest a possible
> solution if you are looking for a quick answer.  Use your image map as a
> pigment function, and then you should be able to directly multiply the
> output of the function by whatever scalar you want.  The function and
> its multiplied scalar can then be declared as a new pigment function.
> Hopefully one of the pros can help get you setup with this approach if
> you have any trouble.
>
> Skip

Hopefully this can help:

//declare image map as a function
#declare PIMAGE = function {pigment{image_map {jpeg "body_01.jpg"
interpolate 2}}

#declare Mult=rgb <1,1,1>; //multiplier colour

//r,g,b components need to be calculated individually as functions can't
carry vectors:
#declare FRed=function(x,y,z) {PIMAGE(x,y,z).red  *Mult.red}
#declare FGrn=function(x,y,z) {PIMAGE(x,y,z).green*Mult.green}
#declare FBlu=function(x,y,z) {PIMAGE(x,y,z).blue *Mult.blue}

//assemble using average: (colours multiplied by 3 so they average to 1)
#declare Pig=
pigment{average
  pigment_map{
    [function{FRed(x,y,z)*3} color_map{[0 rgb 0][1 rgb <1,0,0>]}]
    [function{FGrn(x,y,z)*3} color_map{[0 rgb 0][1 rgb <0,1,0>]}]
    [function{FBlu(x,y,z)*3} color_map{[0 rgb 0][1 rgb <0,0,1>]}]
  }
}


-tgq


Post a reply to this message

From: FlyerX
Subject: Re: Pigment multiplication
Date: 14 Dec 2006 15:27:07
Message: <4581b39b$1@news.povray.org>
Trevor G Quayle wrote:
> Skip Talbot <ski### [at] aolcom> wrote:
>> I don't have time to write out the source, but I can suggest a possible
>> solution if you are looking for a quick answer.  Use your image map as a
>> pigment function, and then you should be able to directly multiply the
>> output of the function by whatever scalar you want.  The function and
>> its multiplied scalar can then be declared as a new pigment function.
>> Hopefully one of the pros can help get you setup with this approach if
>> you have any trouble.
>>
>> Skip
> 
> Hopefully this can help:
> 
> //declare image map as a function
> #declare PIMAGE = function {pigment{image_map {jpeg "body_01.jpg"
> interpolate 2}}
> 
> #declare Mult=rgb <1,1,1>; //multiplier colour
> 
> //r,g,b components need to be calculated individually as functions can't
> carry vectors:
> #declare FRed=function(x,y,z) {PIMAGE(x,y,z).red  *Mult.red}
> #declare FGrn=function(x,y,z) {PIMAGE(x,y,z).green*Mult.green}
> #declare FBlu=function(x,y,z) {PIMAGE(x,y,z).blue *Mult.blue}
> 
> //assemble using average: (colours multiplied by 3 so they average to 1)
> #declare Pig=
> pigment{average
>   pigment_map{
>     [function{FRed(x,y,z)*3} color_map{[0 rgb 0][1 rgb <1,0,0>]}]
>     [function{FGrn(x,y,z)*3} color_map{[0 rgb 0][1 rgb <0,1,0>]}]
>     [function{FBlu(x,y,z)*3} color_map{[0 rgb 0][1 rgb <0,0,1>]}]
>   }
> }
> 
> 
> -tgq
> 
> 
> 

Thanks for the code. I think it should work but when I try to use in 
POV-Ray 3.6.1 (Win32) the FRed declaration stops with "Expected operand, 
colour identifier found instead". After reading about the function on 
the documentation I could not see what was wrong. I though that maybe 
POV-Ray though it was a color instead of a float so I enclosed the 
PIMAGE().red and Mult.red in parenthesis but that did not work.

FlyerX


Post a reply to this message

From: Trevor G Quayle
Subject: Re: Pigment multiplication
Date: 14 Dec 2006 15:55:00
Message: <web.4581b99fe92a14b7c150d4c10@news.povray.org>
FlyerX <fly### [at] yahoocom> wrote:
> Thanks for the code. I think it should work but when I try to use in
> POV-Ray 3.6.1 (Win32) the FRed declaration stops with "Expected operand,
> colour identifier found instead". After reading about the function on
> the documentation I could not see what was wrong. I though that maybe
> POV-Ray though it was a color instead of a float so I enclosed the
> PIMAGE().red and Mult.red in parenthesis but that did not work.
>
> FlyerX

Oops, didn't test before I posted.  A couple of errors.  First I missed a
bracket on the function declaration.  Second, I guess Mult can't be passed
as a colour and extract the colour channels like that.  Instead you can
predetermine them:

#declare PIMAGE = function {pigment{image_map {jpeg "body_01.jpg"
interpolate 2}}}

#declare Mult=rgb <1,1,1>; //multiplier colour
#declare MR=Mult.red;
#declare MG=Mult.green;
#declare MB=Mult.blue;


//r,g,b components need to be calculated individually as functions can't
carry vectors:
#declare FRed=function (x,y,z) {PIMAGE(x,y,z).red*MR}
#declare FGrn=function (x,y,z) {PIMAGE(x,y,z).green*MG}
#declare FBlu=function (x,y,z) {PIMAGE(x,y,z).blue*MB}

//assemble using average: (colours multiplied by 3 so they average to 1)
#declare Pig=
pigment{average
  pigment_map{
    [function{FRed(x,y,z)*3} color_map{[0 rgb 0][1 rgb <1,0,0>]}]
    [function{FGrn(x,y,z)*3} color_map{[0 rgb 0][1 rgb <0,1,0>]}]
    [function{FBlu(x,y,z)*3} color_map{[0 rgb 0][1 rgb <0,0,1>]}]
  }
}


-tgq


Post a reply to this message

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