POV-Ray : Newsgroups : povray.advanced-users : Reproducing pigment from functions ... Server Time
29 Jul 2024 14:18:11 EDT (-0400)
  Reproducing pigment from functions ... (Message 1 to 10 of 13)  
Goto Latest 10 Messages Next 3 Messages >>>
From: Michael Andrews
Subject: Reproducing pigment from functions ...
Date: 10 Apr 2002 09:03:40
Message: <3CB43A2F.651B5B6@reading.ac.uk>
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]} ]
  }
}

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?

Bye for now,
	Mike Andrews.


Post a reply to this message

From:
Subject: Re: Reproducing pigment from functions ...
Date: 10 Apr 2002 09:45:08
Message: <dcf8bu4dmj97i0pp75r9rrb0559doesk0j@4ax.com>
On Wed, 10 Apr 2002 14:12:15 +0100, Michael Andrews <m.c### [at] readingacuk>
wrote:
>#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]} ]
>  }
>}
>
>but with filter, transmit or colours with values greater than one this
>doesn't work.

have you teste below ? I'm not sure but I think it should work

#declare REBUILD = pigment {
  average
  pigment_map {
    [1 function { FNPIG(x,y,z).red } colour_map {[0 rgb 0][1 red 5]} ]
    [1 function { FNPIG(x,y,z).green } colour_map {[0 rgb 0][1 green 5]} ]
    [1 function { FNPIG(x,y,z).blue } colour_map {[0 rgb 0][1 blue 5]} ]
    [1 function { FNPIG(x,y,z).filter } colour_map {[0 rgb 0][1 filter 5]} ]
    [1 function { FNPIG(x,y,z).transmit } colour_map {[0 rgb 0][1 transmit 5]} ]
  }
}

ABX


Post a reply to this message

From: Michael Andrews
Subject: Re: Reproducing pigment from functions ...
Date: 10 Apr 2002 11:20:44
Message: <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.


Post a reply to this message

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

Goto Latest 10 Messages Next 3 Messages >>>

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