POV-Ray : Newsgroups : povray.advanced-users : Reproducing pigment from functions ... Server Time
29 Jul 2024 16:33:08 EDT (-0400)
  Reproducing pigment from functions ... (Message 4 to 13 of 13)  
<<< Previous 3 Messages Goto Initial 10 Messages
From: Warp
Subject: Re: Reproducing pigment from functions ...
Date: 10 Apr 2002 15:21:25
Message: <3cb490b4@news.povray.org>
Michael Andrews <m.c### [at] readingacuk> wrote:
> #declare REBUILD = pigment { ... }

> how do you define REBUILD to give the same pigment as PIG, based on
> FNPIG?

  AFAIK, it's not currently possible.

-- 
#macro N(D)#if(D>99)cylinder{M()#local D=div(D,104);M().5,2pigment{rgb M()}}
N(D)#end#end#macro M()<mod(D,13)-6mod(div(D,13)8)-3,10>#end blob{
N(11117333955)N(4254934330)N(3900569407)N(7382340)N(3358)N(970)}//  - Warp -


Post a reply to this message

From: Michael Andrews
Subject: Re: Reproducing pigment from functions ...
Date: 11 Apr 2002 08:09:50
Message: <3CB57F12.36BE6832@reading.ac.uk>
Warp wrote:
> 
> Michael Andrews <m.c### [at] readingacuk> wrote:
> > #declare REBUILD = pigment { ... }
> 
> > how do you define REBUILD to give the same pigment as PIG, based on
> > FNPIG?
> 
>   AFAIK, it's not currently possible.
>
Well, yes it is possible (see the picture I just posted in Gilles' fast
cloud thread on p.b.i) but the method I've found is pretty brute-force
and klutzy. I was hoping somone would have a bright idea on how to do it
better than I have. That's why I haven't posted my attempt yet - I don't
want to predispose folks to look at the problem from one direction.

If noone comes up with anything by the weekend I'll post my solution.

Bye for now,
	Mike Andrews.


Post a reply to this message

From:
Subject: Re: Reproducing pigment from functions ...
Date: 11 Apr 2002 09:55:57
Message: <4d5bbu06jsaojahr97a8eeoscld0a0sv27@4ax.com>
On Thu, 11 Apr 2002 13:18:26 +0100, Michael Andrews <m.c### [at] readingacuk>
wrote:
> If noone comes up with anything by the weekend I'll post my solution.

layers ?

ABX


Post a reply to this message

From: RAY
Subject: Re: Reproducing pigment from functions ...
Date: 12 Apr 2002 15:27:13
Message: <3cb73511@news.povray.org>
--
__________________
 RAY
"Michael Andrews" <m.c### [at] readingacuk> wrote in message
news:3CB### [at] readingacuk...
> Hi Folks,
>
> I was playing with Gilles' cloud pigment and hit a problem: what is the
> best (ie fastest rendering) way to reproduce an arbitrary pigment from
> it's function?
>
> For example, given
>
> #declare PIG = pigment { bozo colour_map {[0.2 rgbf 1][0.5 rgb
> y*1.3][0.7 rgb x transmit 1] } }
> #declare FNPIG = function { pigment { PIG } }
>
> #declare REBUILD = pigment { ... }
>
> how do you define REBUILD to give the same pigment as PIG, based on
> FNPIG?
>
> Normally it's just a matter of
>
> #declare REBUILD = pigment {
>   average
>   pigment_map {
>     [1 function { FNPIG(x,y,z).x } colour_map {[0 rgb 0][1 rgb 3*x]} ]
>     [1 function { FNPIG(x,y,z).y } colour_map {[0 rgb 0][1 rgb 3*y]} ]
>     [1 function { FNPIG(x,y,z).z } colour_map {[0 rgb 0][1 rgb 3*z]} ]
>   }
> }

would #declare REBUILD = pigment {function {FNPIG}}; work

> but with filter, transmit or colours with values greater than one this
> doesn't work.
>
> I've come up with one structure which works, but is very slow for how I
> am using it.
>
> So, I was hoping someone can come up with a better method. Any takers?
Yes ;-)


Post a reply to this message

From: Abe
Subject: Re: Reproducing pigment from functions ...
Date: 12 Apr 2002 16:33:53
Message: <3CB743C8.C1816CA2@taconic.net>
#declare REBUILD = pigment {
average
pigment_map {
   [1 function{FNPIG(x,y,z).red}     colour_map {[0 rgbft<-2, 0, 0, 0,
0>][1 rgbft< 3, 0, 0, 0, 0>]}]
   [1 function{FNPIG(x,y,z).green}   colour_map {[0 rgbft< 0,-2, 0, 0,
0>][1 rgbft< 0, 3, 0, 0, 0>]}]
   [1 function{FNPIG(x,y,z).blue}    colour_map {[0 rgbft< 0, 0,-2, 0,
0>][1 rgbft< 0, 0, 3, 0, 0>]}]
   [1 function{FNPIG(x,y,z).filter}  colour_map {[0 rgbft< 1, 1, 1, 0,
0>][1 rgbft< 1, 1, 1, 5, 0>]}]
   [1 function{FNPIG(x,y,z).transmit}colour_map {[0 rgbft< 1, 1, 1, 0,
0>][1 rgbft< 1, 1, 1, 0, 5>]}]
 }
}

This seems to work. I'm fairly certain the math is OK, but I still have
to mull it over. Seemed to worked in a visual comparison test with the
original and rebuilt pigments side by side.

Michael Andrews wrote:
> 
> Warp wrote:
> >
> > Michael Andrews <m.c### [at] readingacuk> wrote:
> > > #declare REBUILD = pigment { ... }
> >
> > > how do you define REBUILD to give the same pigment as PIG, based on
> > > FNPIG?
> >
> >   AFAIK, it's not currently possible.
> >
> Well, yes it is possible (see the picture I just posted in Gilles' fast
> cloud thread on p.b.i) but the method I've found is pretty brute-force
> and klutzy. I was hoping somone would have a bright idea on how to do it
> better than I have. That's why I haven't posted my attempt yet - I don't
> want to predispose folks to look at the problem from one direction.
> 
> If noone comes up with anything by the weekend I'll post my solution.
> 
> Bye for now,
>         Mike Andrews.


Post a reply to this message

From: Abe
Subject: Re: Reproducing pigment from functions ...
Date: 12 Apr 2002 18:00:54
Message: <3CB75832.881C4B28@taconic.net>
...except it still will not work for color component values outside of
the range of 0 to 1 since the technique is limited by the color_map
index range. A workaround (if one knew beforehand the color range) would
involve scaling FNPIG by 1/[maximum expected color range] and setting up
the color_map entries to cover the maximum expected color range.

Abe

Abe wrote:
> 
> #declare REBUILD = pigment {
> average
> pigment_map {
>    [1 function{FNPIG(x,y,z).red}     colour_map {[0 rgbft<-2, 0, 0, 0,
> 0>][1 rgbft< 3, 0, 0, 0, 0>]}]
>    [1 function{FNPIG(x,y,z).green}   colour_map {[0 rgbft< 0,-2, 0, 0,
> 0>][1 rgbft< 0, 3, 0, 0, 0>]}]
>    [1 function{FNPIG(x,y,z).blue}    colour_map {[0 rgbft< 0, 0,-2, 0,
> 0>][1 rgbft< 0, 0, 3, 0, 0>]}]
>    [1 function{FNPIG(x,y,z).filter}  colour_map {[0 rgbft< 1, 1, 1, 0,
> 0>][1 rgbft< 1, 1, 1, 5, 0>]}]
>    [1 function{FNPIG(x,y,z).transmit}colour_map {[0 rgbft< 1, 1, 1, 0,
> 0>][1 rgbft< 1, 1, 1, 0, 5>]}]
>  }
> }
> 
> This seems to work. I'm fairly certain the math is OK, but I still have
> to mull it over. Seemed to worked in a visual comparison test with the
> original and rebuilt pigments side by side.
> 
> Michael Andrews wrote:
> >
> > Warp wrote:
> > >
> > > Michael Andrews <m.c### [at] readingacuk> wrote:
> > > > #declare REBUILD = pigment { ... }
> > >
> > > > how do you define REBUILD to give the same pigment as PIG, based on
> > > > FNPIG?
> > >
> > >   AFAIK, it's not currently possible.
> > >
> > Well, yes it is possible (see the picture I just posted in Gilles' fast
> > cloud thread on p.b.i) but the method I've found is pretty brute-force
> > and klutzy. I was hoping somone would have a bright idea on how to do it
> > better than I have. That's why I haven't posted my attempt yet - I don't
> > want to predispose folks to look at the problem from one direction.
> >
> > If noone comes up with anything by the weekend I'll post my solution.
> >
> > Bye for now,
> >         Mike Andrews.


Post a reply to this message

From: David Wallace
Subject: Re: Reproducing pigment from functions ...
Date: 12 Apr 2002 20:58:22
Message: <3cb782ae$1@news.povray.org>
"RAY" <RAY### [at] yahoocom> wrote in message news:3cb73511@news.povray.org...
>
>
> --
> __________________
>  RAY
> "Michael Andrews" <m.c### [at] readingacuk> wrote in message
> news:3CB### [at] readingacuk...
> > Hi Folks,
> >
> > I was playing with Gilles' cloud pigment and hit a problem: what is the
> > best (ie fastest rendering) way to reproduce an arbitrary pigment from
> > it's function?
> >
> > For example, given
> >
> > #declare PIG = pigment { bozo colour_map {[0.2 rgbf 1][0.5 rgb
> > y*1.3][0.7 rgb x transmit 1] } }
> > #declare FNPIG = function { pigment { PIG } }

Replace this with a five-parameter function:

#declare FNPIG = function(rd,gr,bl,ft,tr) { pigment { PIG } }

> >
> > #declare REBUILD = pigment { ... }
> >
> > how do you define REBUILD to give the same pigment as PIG, based on
> > FNPIG?
> >
> > Normally it's just a matter of
> >
> > #declare REBUILD = pigment {
> >   average
> >   pigment_map {
> >     [1 function { FNPIG(x,y,z).x } colour_map {[0 rgb 0][1 rgb 3*x]} ]
> >     [1 function { FNPIG(x,y,z).y } colour_map {[0 rgb 0][1 rgb 3*y]} ]
> >     [1 function { FNPIG(x,y,z).z } colour_map {[0 rgb 0][1 rgb 3*z]} ]
> >   }
> > }
>
> would #declare REBUILD = pigment {function {FNPIG}}; work

After replacing the FNPIG function, the simple declare should work:

#declare REBUILD = pigment { function(rd,gr,bl,ft,tr) {FNPIG}}

>
> > but with filter, transmit or colours with values greater than one this
> > doesn't work.
> >
> > I've come up with one structure which works, but is very slow for how I
> > am using it.
> >
> > So, I was hoping someone can come up with a better method. Any takers?
> Yes ;-)
>
>


Post a reply to this message

From: Warp
Subject: Re: Reproducing pigment from functions ...
Date: 12 Apr 2002 21:16:47
Message: <3cb786ff$1@news.povray.org>
David Wallace <dar### [at] earthlinknet> wrote:
> #declare REBUILD = pigment { function(rd,gr,bl,ft,tr) {FNPIG}}

  Have you actually tried that?

-- 
#macro M(A,N,D,L)plane{-z,-9pigment{mandel L*9translate N color_map{[0rgb x]
[1rgb 9]}scale<D,D*3D>*1e3}rotate y*A*8}#end M(-3<1.206434.28623>70,7)M(
-1<.7438.1795>1,20)M(1<.77595.13699>30,20)M(3<.75923.07145>80,99)// - Warp -


Post a reply to this message

From: David Wallace
Subject: Re: Reproducing pigment from functions ...
Date: 12 Apr 2002 22:29:14
Message: <3cb797fa@news.povray.org>
"Michael Andrews" <m.c### [at] readingacuk> wrote in message
news:3CB45A4F.413CA07F@reading.ac.uk...

>

>
> >     [1 function { FNPIG(x,y,z).filter } colour_map {[0 rgb 0][1 filter
5]} ]
>
> Sorry, no, this is always black :-/
>
> I hadn't thought of trying this way though ...
>
> Bye for now,
> Mike Andrews.

I tried a 5-parameter function thinking that the results would be truncated
otherwise... POV rejected it as an error:
"Function parameters for pigment functions are not allowed."

I suspect that your problem is that any 5D color vector that is interpreted
in a function block is truncated to 3D RGB form.  If that's so then you're
SOL.


Post a reply to this message

From: Thorsten Froehlich
Subject: Re: Reproducing pigment from functions ...
Date: 13 Apr 2002 16:45:08
Message: <3cb898d4@news.povray.org>
In article <3cb797fa@news.povray.org> , "David Wallace" 
<dar### [at] earthlinknet> wrote:

> I tried a 5-parameter function thinking that the results would be truncated
> otherwise... POV rejected it as an error:
> "Function parameters for pigment functions are not allowed."
>
> I suspect that your problem is that any 5D color vector that is interpreted
> in a function block is truncated to 3D RGB form.  If that's so then you're
> SOL.

No, this is not the case.  The error message simply says you may not specify
function parameters for functions with a fixed parameter list, which is
explained in the documentation.


    Thorsten


Post a reply to this message

<<< Previous 3 Messages Goto Initial 10 Messages

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