POV-Ray : Newsgroups : povray.binaries.images : Re: Color question Server Time
17 Aug 2024 04:11:13 EDT (-0400)
  Re: Color question (Message 11 to 19 of 19)  
<<< Previous 10 Messages Goto Initial 10 Messages
From: Mike Williams
Subject: Re: Color question
Date: 24 Nov 2001 13:11:57
Message: <MG40OLAWy9$7Ew8Y@econym.demon.co.uk>
Wasn't it Bob H. who wrote:
>"Mike Williams" <mik### [at] nospamplease> wrote in message
>news:R4lTREAhsz$7Ewc3@econym.demon.co.uk...
>>
>> #include "colors"
>> //#declare MyColour = White - Gray25;
>> //#declare MyColour = 1 - Gray25;
>> #declare MyColour = rgb 1 - Gray25;
>>
>> #debug str(MyColour.red,0,2)
>> #debug ", "
>> #debug str(MyColour.green,0,2)
>> #debug ", "
>> #debug str(MyColour.blue,0,2)
>> #debug ", "
>> #debug str(MyColour.filter,0,2)
>> #debug ", "
>> #debug str(MyColour.transmit,0,2)
>> #debug "\n"
>>
>>
>> It could be argued that "rgb" should force the filter and transmit
>> values to zero, rather than just display the warning and accept non-zero
>> filters and/or transmits. (You did notice that you were getting the
>> warning "Suspicious expression after rgb.", didn't you?)
>
>Wait a minute.  What's rgb 1 doing becoming rgbft 1 anyway.

It doesn't. If you try "#declare MyColour = rgb 1" in the above code
you'll see it becomes <1,1,1,0,0>. 

-- 
Mike Williams
Gentleman of Leisure


Post a reply to this message

From: Nathan Kopp
Subject: Re: Color question
Date: 24 Nov 2001 13:12:05
Message: <3bffe2f5$1@news.povray.org>
"Bob H." <omn### [at] msncom> wrote...
>
> Wait a minute.  What's rgb 1 doing becoming rgbft 1 anyway.  Isn't this a
> bug then?  I knew color 1 became rgbft 1 but with rgb specified this
> shouldn't be happening, right?

Actually, "rgb 1" does not become <1,1,1,1,1>.  It will become <1,1,1,0,0>.
However, "rgb 1" is NOT what we have here.

The issue is that the parser interprets "rgb 1 - Gray25" as
    "rgb (1 - Gray25) "
which promotes to
    "rgb (<1,1,1,1,1> - Gray25)"
which becomes
    "rgb (<0.75,0.75,0.75,1,1>)"
and then the "rgb" gets ignored.

Instead you probably desired this:
    "(rgb 1) - Gray25"

Unfortunately, the parser won't accept that second version (with the "rgb 1"
wrapped in parentheses) as I wrote it above, but there are plenty of other
ways to work around this quirk in the POV parser.  Examples have been given
in previous replies.

-Nathan


Post a reply to this message

From: bob h
Subject: Re: Color question
Date: 24 Nov 2001 21:40:39
Message: <3c005a27@news.povray.org>
"Nathan Kopp" <nat### [at] koppcom> wrote in message
news:3bffe2f5$1@news.povray.org...
>
> Actually, "rgb 1" does not become <1,1,1,1,1>.  It will become
<1,1,1,0,0>.
> However, "rgb 1" is NOT what we have here.
>
> The issue is that the parser interprets "rgb 1 - Gray25" as
>     "rgb (1 - Gray25) "
> which promotes to
>     "rgb (<1,1,1,1,1> - Gray25)"
> which becomes
>     "rgb (<0.75,0.75,0.75,1,1>)"
> and then the "rgb" gets ignored.
>
> Instead you probably desired this:
>     "(rgb 1) - Gray25"
>
> Unfortunately, the parser won't accept that second version (with the "rgb
1"
> wrapped in parentheses) as I wrote it above, but there are plenty of other
> ways to work around this quirk in the POV parser.  Examples have been
given
> in previous replies.


Yes, but when I was checking on this I made Gray25 in the colors.inc deal
only with 3 float vectors instead of what had been there previously, which
was rgb 1 as well for White.  White was then made into Gray25 by doing
Gray25=White*0.25.  I made that be <0.25,0.25,0.25>, so in theory all were 3
float vectors until the final rgb 1 - Gray25 was done.  What you're saying
then would mean even then the rgb 1 gets changed into <1,1,1,1,1> once the
math on it exists.  I can't see that as being correct.

rgb 1 - <1,1,1,0,0>*<.25,.25,.25,0,0> = <.75,.75,.75,1,1>

How can that be right?

--
text{ttf"arial","bob h",.1,0pigment{rgb 9}translate<-1,-.2,3>}


Post a reply to this message

From: Marc-Hendrik Bremer
Subject: Re: Color question
Date: 25 Nov 2001 04:31:18
Message: <3c00ba66$1@news.povray.org>
bob h schrieb in Nachricht <3c005a27@news.povray.org>...

>rgb 1 - <1,1,1,0,0>*<.25,.25,.25,0,0> = <.75,.75,.75,1,1>


Why not? As the multiplication is prior to the subtraction you get
<1,1,1,1,1> - <0.25,0.25,0.25,0,0> which gives you the result you mentioned.

Marc-Hendrik


Post a reply to this message

From: bob h
Subject: Re: Color question
Date: 25 Nov 2001 04:57:29
Message: <3c00c089@news.povray.org>
Well, my point about this is how rgb ought to prevent rgbft from being used.
I can see how your logic would work were there no "rgb" but its presence
should mean anything following it is a 3 float vector.  And even though my
example had all 5 it still does the promotion to 5 when all are only 3.  The
filter and transmit keywords should be what is needed to get back to all 5
again from that rgb color value.

That's my reasoning anyway.

What you've said is essentially that a <red,green,blue,filter,transmit> is
omnipresent regardless of choosing to use rgb alone.  Again, I can see that
being likely once using the 5 floats vector afterward but they are set to
zero.  1-0=1 but only if rgb 1 = rgbft 1.

Hope I'm not losing you, Mike Williams had said the same thing really.

--
text{ttf"arial","bob h",.1,0pigment{rgb 9}translate<-1,-.2,3>}

"Marc-Hendrik Bremer" <Mar### [at] t-onlinede> wrote in message
news:3c00ba66$1@news.povray.org...
>
> bob h schrieb in Nachricht <3c005a27@news.povray.org>...
>
> >rgb 1 - <1,1,1,0,0>*<.25,.25,.25,0,0> = <.75,.75,.75,1,1>
>
>
> Why not? As the multiplication is prior to the subtraction you get
> <1,1,1,1,1> - <0.25,0.25,0.25,0,0> which gives you the result you
mentioned.
>
> Marc-Hendrik
>


Post a reply to this message

From: Marc-Hendrik Bremer
Subject: Re: Color question
Date: 25 Nov 2001 06:15:01
Message: <3c00d2b5@news.povray.org>
bob h schrieb in Nachricht <3c00c089@news.povray.org>...

>What you've said is essentially that a <red,green,blue,filter,transmit> is
>omnipresent regardless of choosing to use rgb alone.  Again, I can see that
>being likely once using the 5 floats vector afterward but they are set to
>zero.  1-0=1 but only if rgb 1 = rgbft 1.
>
>Hope I'm not losing you, Mike Williams had said the same thing really.


It seems like being all about apples and pears.

 #declare ThreeComps= <0,0,1>;
 #declare MyColour = rgb 1-ThreeComps;

evaluates to <1,1,0,0,0>.

But
#declare ThreeComps= rgb <0,0,1>;
#declare MyColour = rgb 1-ThreeComps;

evaluates to <1,1,0,1,1>.

In the first case, the math is done with vectors of any kind. In the second
case it's done with color vectors which are always 5 component vectors.
I agree however, that rgb Whatever should result in a 5 component vector
with filter and transmit set to 0. Is there a reason why this is not the
case (or why rgb is ignored as Nathan said)?

Marc-Hendrik


Post a reply to this message

From: Nathan Kopp
Subject: Re: Color question
Date: 18 Jan 2002 00:03:51
Message: <3c47acb7$1@news.povray.org>
"Marc-Hendrik Bremer" <Mar### [at] t-onlinede> wrote...
>
> It seems like being all about apples and pears.
>
>  #declare ThreeComps= <0,0,1>;
>  #declare MyColour = rgb 1-ThreeComps;
>
> evaluates to <1,1,0,0,0>.
>
> But
> #declare ThreeComps= rgb <0,0,1>;
> #declare MyColour = rgb 1-ThreeComps;
>
> evaluates to <1,1,0,1,1>.
>
> In the first case, the math is done with vectors of any kind. In the
second
> case it's done with color vectors which are always 5 component vectors.
> I agree however, that rgb Whatever should result in a 5 component vector
> with filter and transmit set to 0. Is there a reason why this is not the
> case (or why rgb is ignored as Nathan said)?

I'm sorry this reply is so late. (Probably nobody will read it because it is
in an ancient thread, but I'll post anyway.)

My original point still holds true.  the "rgb" is NOT ignored.  However, it
is applied AFTER doing the math, NOT BEFORE.  Also, the "rgb" keyword will
never decrease the number of components in an existing vector.  It only
defines how things should be expanded.  Therefore, the "rgb" keyword has no
effect in these situations.

POV interprets your first example as
    #declare MyColour = rgb (1-ThreeComps);
Substitution gives us this:
    #declare MyColour = rgb (1-<0,0,1>);
Because the highest dimensionality is 3 (ThreeComps is a three component
vector), POV expands this as:
    #declare MyColour = rgb (<1,1,1>-<0,0,1>);
Compute:
    #declare MyColour = rgb (<1,1,0>);
NOW we finally apply the "rgb" keyword, and it has no effect:
    MyColour = <1,1,0>

Here's the second example:
    #declare MyColour = rgb (1-ThreeComps);
Because ThreeComps is a COLOR, substitution gives us this:
    #declare MyColour = rgb (1-<0,0,1,0,0>);
Because the highest dimensionality is 5 (ThreeComps is a color), POV expands
everything to 5 components, like this:
    #declare MyColour = rgb (<1,1,1,1,1>-<0,0,1,0,0>);
Compute:
    #declare MyColour = rgb (<1,1,0,1,1>);
NOW we finally apply the "rgb" keyword, and it has no effect (because "rgb"
will not reduce the number of components):
    MyColour = <1,1,0,1,1>

-Nathan


Post a reply to this message

From: Hugo
Subject: Re: Color question
Date: 18 Jan 2002 03:50:55
Message: <3c47e1ef$1@news.povray.org>
> I'm sorry this reply is so late. (Probably nobody will read it because it
is
> in an ancient thread, but I'll post anyway.)

Outlook express shows such posts as new ones so probably many of us notice
your reply.  :o)


Hugo


Post a reply to this message

From: JPGargoyle
Subject: Re: Color question
Date: 18 Jan 2002 15:52:13
Message: <3c488afd$1@news.povray.org>
Hmmm.

These little details can be real tricky, and lead to some unexpected results
(like what happened to me) and be hard to figure what was wrong.

But now I am aware of them he he he :))


Thnxs Nathan

Best regards


Post a reply to this message

<<< Previous 10 Messages Goto Initial 10 Messages

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