POV-Ray : Newsgroups : povray.newusers : adding 2 pigments Server Time
28 Nov 2024 03:27:51 EST (-0500)
  adding 2 pigments (Message 1 to 10 of 11)  
Goto Latest 10 Messages Next 1 Messages >>>
From: Elias Pschernig
Subject: adding 2 pigments
Date: 11 Oct 2001 17:00:49
Message: <3bc60881@news.povray.org>
Is there a way to add 2 pigments together into a new pigment? Something like
"average", but only adding the values, without dividing afterwards. I tried
all sort of things, even splitting both pigments into different color
channel functions, adding the functions, and then combining them again into
the new pigment.. but it's quite complicated and messy, only for such a
simple thing. I think there must be a simpler solution and I'm just not
seeing it.

For example, I have one pigment which is <0,0,0> everywhere and has a stripe
of <1,0,0> somewhere, and another pigment which also is black and has
another red stripe. The resulting pigment should be black as well, but have
both stripes. If I use average, it has both stripes, but they get very
dark. I must be overlooking something..

Right now I have this, which does not what I want:

#declare Pigment3 = pigment {
   average
   pigment_map {
      [1 Pigment1]
      [1 Pigment2]
   }
}

Any ideas?

-- 
#macro C(X,Y)cylinder{X*x<X,0,-Y/2>.1}#end#macro U(R,X,Y)intersection{torus{.9
.1}box{-1 0rotate y*R*90}translate<X,0,Y>scale 1-z*.5}#end union{U(0,0,0)U(1,0
,0)U(2,-1,-1)U(1,1,0)U(1,1.5,-3)U(1,2,0)U(3,1,0)U(2,2,0)U(0,3,0)U(3,2,.5)C(.1,
2)C(.8,1)C(.8,-1)C(1.1,1)C(1.9,-1)pigment{rgb 10}rotate x*90translate<-1,0,4>}


Post a reply to this message

From: Ron Parker
Subject: Re: adding 2 pigments
Date: 11 Oct 2001 17:48:16
Message: <slrn9sc4t3.d4h.ron.parker@fwi.com>
On Thu, 11 Oct 2001 23:00:48 +0200, Elias Pschernig wrote:
>Is there a way to add 2 pigments together into a new pigment? Something like
>"average", but only adding the values, without dividing afterwards. I tried
>all sort of things, even splitting both pigments into different color
>channel functions, adding the functions, and then combining them again into
>the new pigment.. but it's quite complicated and messy, only for such a
>simple thing. I think there must be a simpler solution and I'm just not
>seeing it.
>
>For example, I have one pigment which is <0,0,0> everywhere and has a stripe
>of <1,0,0> somewhere, and another pigment which also is black and has
>another red stripe. The resulting pigment should be black as well, but have
>both stripes. If I use average, it has both stripes, but they get very
>dark. I must be overlooking something..

You can use larger values in the declarations of the two source pigments.
If you make your red stripes be rgb <2,0,0> it should balance out in the end.


-- 
#local R=rgb 99;#local P=R-R;#local F=pigment{gradient x}box{0,1pigment{gradient
y pigment_map{[.5F pigment_map{[.3R][.3F color_map{[.15red 99][.15P]}rotate z*45
translate x]}]#local H=pigment{gradient y color_map{[.5P][.5R]}scale 1/3}[.5F
pigment_map{[.3R][.3H][.7H][.7R]}]}}}camera{location.5-3*z}//only my opinions


Post a reply to this message

From: Elias Pschernig
Subject: Re: adding 2 pigments
Date: 12 Oct 2001 04:22:21
Message: <3bc6a83d@news.povray.org>
> You can use larger values in the declarations of the two source pigments.
> If you make your red stripes be rgb <2,0,0> it should balance out in the end.

Yes, that's what I'm doing in my complicated method, but it only works for
patterns, not pigments. Or is there an easy way to take a pigment, and
multiply it by 2?

-- 
#macro C(X,Y)cylinder{X*x<X,0,-Y/2>.1}#end#macro U(R,X,Y)intersection{torus{.9
.1}box{-1 0rotate y*R*90}translate<X,0,Y>scale 1-z*.5}#end union{U(0,0,0)U(1,0
,0)U(2,-1,-1)U(1,1,0)U(1,1.5,-3)U(1,2,0)U(3,1,0)U(2,2,0)U(0,3,0)U(3,2,.5)C(.1,
2)C(.8,1)C(.8,-1)C(1.1,1)C(1.9,-1)pigment{rgb 10}rotate x*90translate<-1,0,4>}


Post a reply to this message

From: Simon
Subject: Re: adding 2 pigments
Date: 12 Oct 2001 05:06:19
Message: <3bc6b28b@news.povray.org>
Elias Pschernig <eli### [at] aonat> schrieb in im Newsbeitrag:
3bc60881@news.povray.org...
> Is there a way to add 2 pigments together into a new pigment? Something
like
> "average", but only adding the values, without dividing afterwards. I
tried
> all sort of things, even splitting both pigments into different color
> channel functions, adding the functions, and then combining them again
into
> the new pigment.. but it's quite complicated and messy, only for such a
> simple thing. I think there must be a simpler solution and I'm just not
> seeing it.
>
> For example, I have one pigment which is <0,0,0> everywhere and has a
stripe
> of <1,0,0> somewhere, and another pigment which also is black and has
> another red stripe. The resulting pigment should be black as well, but
have
> both stripes. If I use average, it has both stripes, but they get very
> dark. I must be overlooking something..
>
> Right now I have this, which does not what I want:
>
> #declare Pigment3 = pigment {
>    average
>    pigment_map {
>       [1 Pigment1]
>       [1 Pigment2]
>    }
> }
>
> Any ideas?
You could put both pigments in a function then add the to functions in
another function and use this as your pigment.


Post a reply to this message

From: Trevor Quayle
Subject: Re: adding 2 pigments
Date: 12 Oct 2001 07:43:19
Message: <3bc6d757$1@news.povray.org>
You can add, subtract, divide and multiply pigment vectors the same as any
other vector:

rgb <1,1,1>*5
rgb <1,0,0>+<1,1,0>
rgb <1,1,1>*<1,2,1>
....etc.


-tgq


"Elias Pschernig" <eli### [at] aonat> wrote in message
news:3bc6a83d@news.povray.org...
> > You can use larger values in the declarations of the two source
pigments.
> > If you make your red stripes be rgb <2,0,0> it should balance out in the
end.
>
> Yes, that's what I'm doing in my complicated method, but it only works for
> patterns, not pigments. Or is there an easy way to take a pigment, and
> multiply it by 2?
>
> --
> #macro C(X,Y)cylinder{X*x<X,0,-Y/2>.1}#end#macro
U(R,X,Y)intersection{torus{.9
> .1}box{-1 0rotate y*R*90}translate<X,0,Y>scale 1-z*.5}#end
union{U(0,0,0)U(1,0
>
,0)U(2,-1,-1)U(1,1,0)U(1,1.5,-3)U(1,2,0)U(3,1,0)U(2,2,0)U(0,3,0)U(3,2,.5)C(.
1,
> 2)C(.8,1)C(.8,-1)C(1.1,1)C(1.9,-1)pigment{rgb 10}rotate
x*90translate<-1,0,4>}
>


Post a reply to this message

From: Elias Pschernig
Subject: Re: adding 2 pigments
Date: 12 Oct 2001 09:57:37
Message: <3bc6f6d1$1@news.povray.org>
> You can add, subtract, divide and multiply pigment vectors the same as any
> other vector:
> 
> rgb <1,1,1>*5
> rgb <1,0,0>+<1,1,0>
> rgb <1,1,1>*<1,2,1>
> ....etc.

Yes, vectors, but not pigments. Not even pigment functions. By now I think I
already have the simplest solution for what I want to do, but it is very
complicated:

(All it does is adding two pigments)

#declare PigmentFunction1 = function { pigment { InputPigment1 } }
#declare PigmentFunction2 = function { pigment { InputPigment2 } }

#declare PatternRed1 =  function { pattern { function { PigmentFunction1(x, y, z).x }
} }  
#declare PatternGreen1 =  function { pattern { function { PigmentFunction1(x, y, z).y
} } }
#declare PatternBlue1 = function { pattern { function { PigmentFunction1(x, y, z).z }
} }
#declare PatternAlpha1 = function { pattern { function { PigmentFunction1(x, y, z).t }
} }

#declare PatternRed2 = function { pattern { function { PigmentFunction2(x, y, z).x } }
}
#declare PatternGreen2 = function { pattern { function { PigmentFunction2(x, y, z).y }
} }
#declare PatternBlue2 = function { pattern { function { PigmentFunction2(x, y, z).z }
} }
#declare PatternAlpha2 = function { pattern { function { PigmentFunction2(x, y, z).t }
} }
              
#declare PatternRed = function {
   PatternRed1(x, y, z) + PatternRed2(x, y, z)
}   

#declare PatternGreen = function {
   PatternGreen1(x, y, z) + PatternGreen2(x, y, z)
}   

#declare PatternBlue = function {
   PatternBlue1(x, y, z) + PatternBlue2(x, y, z)
}                   

#declare PatternAlpha = function {
   PatternAlpha1(x, y, z) + PatternAlpha2(x, y, z)
}   
              
#declare OutputPigment = pigment {
   average
   pigment_map {
      [function { PatternRed(x, y, z) } color_map {[0 rgb 0][1 rgb x * 4]}]
      [function { PatternGreen(x, y, z) } color_map {[0 rgb 0][1 rgb y * 4]}]
      [function { PatternBlue(x, y, z) } color_map {[0 rgb 0][1 rgb z * 4]}]  
      [function { PatternAlpha(x, y, z) } color_map {[0 rgb 0][1 rgbt t * 4]}]
   }       
} 

Now it is understandable why I thought there's a simpler solution I guess :)
I still hope someone can simplify it..

-- 
#macro C(X,Y)cylinder{X*x<X,0,-Y/2>.1}#end#macro U(R,X,Y)intersection{torus{.9
.1}box{-1 0rotate y*R*90}translate<X,0,Y>scale 1-z*.5}#end union{U(0,0,0)U(1,0
,0)U(2,-1,-1)U(1,1,0)U(1,1.5,-3)U(1,2,0)U(3,1,0)U(2,2,0)U(0,3,0)U(3,2,.5)C(.1,
2)C(.8,1)C(.8,-1)C(1.1,1)C(1.9,-1)pigment{rgb 10}rotate x*90translate<-1,0,4>}


Post a reply to this message

From: Tor Olav Kristensen
Subject: Re: adding 2 pigments
Date: 16 Oct 2001 14:49:25
Message: <3BCC80B5.51E34E83@hotmail.com>
Elias Pschernig wrote:
> 
> > You can add, subtract, divide and multiply pigment vectors the same as any
> > other vector:
> >
> > rgb <1,1,1>*5
> > rgb <1,0,0>+<1,1,0>
> > rgb <1,1,1>*<1,2,1>
> > ....etc.
> 
> Yes, vectors, but not pigments. Not even pigment functions. By now I think I
> already have the simplest solution for what I want to do, but it is very
> complicated:
> 
> (All it does is adding two pigments)
>...

>...
> Now it is understandable why I thought there's a simpler solution I guess :)
> I still hope someone can simplify it..

Elias, see my code below.

It isn't tested much...
- Maybe you can give it a few tests ?


Tor Olav


// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7 =
// Copyright 2001 by Tor Olav Kristensen
// mailto:tor### [at] hotmailcom
// http://www.crosswinds.net/~tok
// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7 =

#version 3.5;

#include "colors.inc"

// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7 =

#macro MixPigments(Pigment1, Pigment2)

  #local Alpha = color rgbt <0, 0, 0, 1>;
  #local PFn1 = function { pigment { Pigment1 } }
  #local PFn2 = function { pigment { Pigment2 } }
  #local R_Pigment =
  pigment {
    function { PFn1(x, y, z).x + PFn2(x, y, z).x }
    color_map { [ 0 color Black ] [ 1 color 4*Red   ] }
  }
  #local G_Pigment =
  pigment {
    function { PFn1(x, y, z).y + PFn2(x, y, z).y }
    color_map { [ 0 color Black ] [ 1 color 4*Green ] }
  }
  #local B_Pigment =
  pigment {
    function { PFn1(x, y, z).z + PFn2(x, y, z).z }
    color_map { [ 0 color Black ] [ 1 color 4*Blue  ] }
  }
  #local T_Pigment =
  pigment {
    function { PFn1(x, y, z).t + PFn2(x, y, z).t }
    color_map { [ 0 color Black ] [ 1 color 4*Alpha ] }
  }
  #local MixedPigment =
  pigment {
     average
     pigment_map {
        [ R_Pigment ]
        [ G_Pigment ]
        [ B_Pigment ]
        [ T_Pigment ]
     }       
  }
  
  MixedPigment

#end // macro MixPigments

// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7 =

#declare InputPigment1 =
pigment {
  bozo
  scale 0.3
  color_map {
    [ 0 color Cyan ]
    [ 1 color Magenta ]
  }
}
  

#declare InputPigment2 =
pigment {
  gradient y
  turbulence 0.3
  color_map {
    [ 0 color Yellow ]
    [ 1 color Blue ]
  }
}


sphere {
  <0, 0, 0>, 1
  pigment { MixPigments(InputPigment1, InputPigment2) }
}

// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7 =

light_source { <1, 2, -2>*100 color White }

camera {
  location <0, 0, -5>
  look_at <0, 0, 0>
}

// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7 =


Post a reply to this message

From: Elias Pschernig
Subject: Re: adding 2 pigments
Date: 17 Oct 2001 05:58:39
Message: <3bcd564f$1@news.povray.org>
> Elias, see my code below.
> 
> It isn't tested much...
> - Maybe you can give it a few tests ?
> 
> 

[...]

Yes, that looks better :) Especially not defining separate pattern functions,
it is what looked worst in my approach. Btw, I discovered that the transparent
component doesn't work, it seems to be a limitation of pigment functions. I'm
not sure yet if it is a bug, but the .t always returns 0, no matter what the
transparency of the pigment used is. (The transparency in my code doesn't work
as well)

-- 
#macro C(X,Y)cylinder{X*x<X,0,-Y/2>.1}#end#macro U(R,X,Y)intersection{torus{.9
.1}box{-1 0rotate y*R*90}translate<X,0,Y>scale 1-z*.5}#end union{U(0,0,0)U(1,0
,0)U(2,-1,-1)U(1,1,0)U(1,1.5,-3)U(1,2,0)U(3,1,0)U(2,2,0)U(0,3,0)U(3,2,.5)C(.1,
2)C(.8,1)C(.8,-1)C(1.1,1)C(1.9,-1)pigment{rgb 10}rotate x*90translate<-1,0,4>}


Post a reply to this message

From: Bob H 
Subject: Re: adding 2 pigments
Date: 17 Oct 2001 09:27:13
Message: <3bcd8731@news.povray.org>
"Elias Pschernig" <eli### [at] aonat> wrote in message
news:3bcd564f$1@news.povray.org...
>
>  I discovered that the transparent
> component doesn't work, it seems to be a limitation of pigment functions.
I'm
> not sure yet if it is a bug, but the .t always returns 0, no matter what
the
> transparency of the pigment used is. (The transparency in my code doesn't
work
> as well)

't' is the fourth float in a 4D vector, as used in julia_fractal for
example.  That's why it remains zero, it isn't seeing a 4D vector present.
I don't know of a dot to get filter or transmit.

Bob H.


Post a reply to this message

From: Elias Pschernig
Subject: Re: adding 2 pigments
Date: 17 Oct 2001 11:17:54
Message: <3bcda122@news.povray.org>
> 
> 't' is the fourth float in a 4D vector, as used in julia_fractal for
> example.  That's why it remains zero, it isn't seeing a 4D vector present.
> I don't know of a dot to get filter or transmit.
> 

Yes, thanks, I actually knew that once and forgot it again :) Looking at the
docs, it seems I can use .red .green .blue .transmit and .filter, and .x .y
.z works for the first 3 (but .t not for the 4th).

-- 
#macro C(X,Y)cylinder{X*x<X,0,-Y/2>.1}#end#macro U(R,X,Y)intersection{torus{.9
.1}box{-1 0rotate y*R*90}translate<X,0,Y>scale 1-z*.5}#end union{U(0,0,0)U(1,0
,0)U(2,-1,-1)U(1,1,0)U(1,1.5,-3)U(1,2,0)U(3,1,0)U(2,2,0)U(0,3,0)U(3,2,.5)C(.1,
2)C(.8,1)C(.8,-1)C(1.1,1)C(1.9,-1)pigment{rgb 10}rotate x*90translate<-1,0,4>}


Post a reply to this message

Goto Latest 10 Messages Next 1 Messages >>>

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