POV-Ray : Newsgroups : povray.general : Bad operands Server Time
26 Nov 2024 16:31:20 EST (-0500)
  Bad operands (Message 1 to 10 of 10)  
From: Thomas de Groot
Subject: Bad operands
Date: 20 May 2010 03:11:36
Message: <4bf4e0a8$1@news.povray.org>
I do not understand this. The following macro

#macro GammaColort(Color,Gamma)
  rgbt <pow(Color.red,Gamma), pow(Color.green,Gamma), pow(Color.blue,Gamma), 
Color.transmit>
#end

gives a parse error: "Bad operands for period operators"

while the following macros work just fine:

#macro GammaColorf(Color,Gamma)
  rgbf <pow(Color.red,Gamma), pow(Color.green,Gamma), pow(Color.blue,Gamma), 
Color.filter>
#end

#macro GammaColorft(Color,Gamma)
  rgbft <pow(Color.red,Gamma), pow(Color.green,Gamma), 
pow(Color.blue,Gamma), Color.filter, Color.transmit>
#end

Can somebody tell me what I do wrong?


Thomas


Post a reply to this message

From: Paolo Gibellini
Subject: Re: Bad operands
Date: 20 May 2010 04:21:20
Message: <4bf4f100$1@news.povray.org>
>Thomas de Groot  on date 20/05/2010 09:11 wrote:
> I do not understand this. The following macro
>
> #macro GammaColort(Color,Gamma)
>    rgbt<pow(Color.red,Gamma), pow(Color.green,Gamma), pow(Color.blue,Gamma),
> Color.transmit>
> #end
>
> gives a parse error: "Bad operands for period operators"
>
> while the following macros work just fine:
>
> #macro GammaColorf(Color,Gamma)
>    rgbf<pow(Color.red,Gamma), pow(Color.green,Gamma), pow(Color.blue,Gamma),
> Color.filter>
> #end
>
> #macro GammaColorft(Color,Gamma)
>    rgbft<pow(Color.red,Gamma), pow(Color.green,Gamma),
> pow(Color.blue,Gamma), Color.filter, Color.transmit>
> #end
>
> Can somebody tell me what I do wrong?
>
>
> Thomas
>
>
>
Perhaps your color doesn't have the transmit component.
An example:
with the color <0.8,0.6,0.7,0.5,0.8> the three macros works fine (I've 
tested with 3.6.2 version).
With the color <0.8,0.6,0.7,0.5> I've the "Bad operands for period 
operators" error for both GammaColort and GammaColorft macro.

Paolo


Post a reply to this message

From: clipka
Subject: Re: Bad operands
Date: 20 May 2010 04:23:53
Message: <4bf4f199$1@news.povray.org>
Am 20.05.2010 09:11, schrieb Thomas de Groot:
> I do not understand this. The following macro
>
> #macro GammaColort(Color,Gamma)
>    rgbt<pow(Color.red,Gamma), pow(Color.green,Gamma), pow(Color.blue,Gamma),
> Color.transmit>
> #end
>
> gives a parse error: "Bad operands for period operators"
>
> while the following macros work just fine:
>
> #macro GammaColorf(Color,Gamma)
>    rgbf<pow(Color.red,Gamma), pow(Color.green,Gamma), pow(Color.blue,Gamma),
> Color.filter>
> #end
>
> #macro GammaColorft(Color,Gamma)
>    rgbft<pow(Color.red,Gamma), pow(Color.green,Gamma),
> pow(Color.blue,Gamma), Color.filter, Color.transmit>
> #end
>
> Can somebody tell me what I do wrong?

I guess something's fishy about the values you pass into the macros.

For instance, if you call

     GammaColort(<R,G,B,T>,G)

then at the time of the macro invocation POV-Ray has no way of knowing 
that "T" is intended to represent a transmit component; to POV-Ray, 
<R,G,B,T> is just another 4-component vector.

So when POV-Ray parses the GammaColort macro body, it will translate it to:

     rgbt <
         pow(<R,G,B,T>.red,   G),
         pow(<R,G,B,T>.green, G),
         pow(<R,G,B,T>.blue,  G),
         pow(<R,G,B,T>.transmit)
     >

Enter POV-Ray's bivalence regarding colors and vectors: To POV-Ray, 
colors and vectors are just the same - with colors being vectors with up 
to five components, ordered as <red,green,blue,filter,transmit> = 
<x,y,z,t,_unnamed_> (note that "t" here denotes time, /not/ transmit). 
Thus, when you specify "Color.transmit", you're actually accessing the 
5th component of whatever vector expression "Color" happens to be.

But <R,G,B,T> only has 4 components. Duh!


The issue can easily be solved when considering that

     rgbt <A,B,C,D>

is /fully/ equivalent to

     <A,B,C,0,D>

Thus, you actually need only a single macro and use it as follows:

     #macro GammaColor(Color,Gamma)
       rgbft<pow(Color.red,Gamma), pow(Color.green,Gamma),
       pow(Color.blue,Gamma), Color.filter, Color.transmit>
     #end
     ...
     #declare MyColor = GammaColor(rgbt <R,G,B,T>, G);

You can even use constructs like

     #declare MyColor = GammaColor(red R transmit T, G);

because

     red R transmit T

is just another way of writing

     <R,0,0,0,T>


Post a reply to this message

From: Thomas de Groot
Subject: Re: Bad operands
Date: 20 May 2010 04:59:00
Message: <4bf4f9d4$1@news.povray.org>
Thanks indeed Paolo and Christoph. I understand better now.

My error was to assume that in *rgbt*, the *t* would always be interpreted 
by POV-Ray as a transmit value, which it is apparently not. This is a bit 
confusing, but there it is. I seem to remember now that this has been 
discussed before here, maybe a year ago.

Thomas


Post a reply to this message

From: Thomas de Groot
Subject: Re: Bad operands
Date: 21 May 2010 05:05:02
Message: <4bf64cbe$1@news.povray.org>
"clipka" <ano### [at] anonymousorg> schreef in bericht 
news:4bf4f199$1@news.povray.org...
> Thus, you actually need only a single macro and use it as follows:
>
>     #macro GammaColor(Color,Gamma)
>       rgbft<pow(Color.red,Gamma), pow(Color.green,Gamma),
>       pow(Color.blue,Gamma), Color.filter, Color.transmit>
>     #end
>     ...
>     #declare MyColor = GammaColor(rgbt <R,G,B,T>, G);
>

Strange....
Now, when I declare the macro above at the start of my scene, I get again 
the same parse error, within the macro declaration, with the cursor blinking 
at Color.filter

Thomas


Post a reply to this message

From: Christian Froeschlin
Subject: Re: Bad operands
Date: 21 May 2010 06:12:42
Message: <4bf65c9a$1@news.povray.org>
Thomas de Groot wrote:

> Now, when I declare the macro above at the start of my scene, I get again 
> the same parse error, within the macro declaration, with the cursor blinking 
> at Color.filter

You should check all invocations of GammaColor in your scene file then.
You're likely calling it with a 3 component vector but without rgb.


Post a reply to this message

From: Thomas de Groot
Subject: Re: Bad operands
Date: 21 May 2010 07:11:31
Message: <4bf66a63@news.povray.org>
"Christian Froeschlin" <chr### [at] chrfrde> schreef in bericht 
news:4bf65c9a$1@news.povray.org...
>
> You should check all invocations of GammaColor in your scene file then.
> You're likely calling it with a 3 component vector but without rgb.

Yes... that must be it because in a test scene this is exactly what makes 
the error appear... Thanks! Good hint!

Thomas


Post a reply to this message

From: clipka
Subject: Re: Bad operands
Date: 21 May 2010 09:07:49
Message: <4bf685a5$1@news.povray.org>
Am 21.05.2010 13:11, schrieb Thomas de Groot:

>> You should check all invocations of GammaColor in your scene file then.
>> You're likely calling it with a 3 component vector but without rgb.
>
> Yes... that must be it because in a test scene this is exactly what makes
> the error appear... Thanks! Good hint!

Unless you really badly need the gamma-correction macro for a current 
project, you may want to wait for the next beta anyway, which will 
probably make you want to ditch your macros anyway.

I mean, who'll want to use macros when you can just write

   pigment { color rgb <0.2,0.4,0.7> gamma 2.2 }

;-)


Post a reply to this message

From: Thomas de Groot
Subject: Re: Bad operands
Date: 21 May 2010 11:09:37
Message: <4bf6a231$1@news.povray.org>
"clipka" <ano### [at] anonymousorg> schreef in bericht 
news:4bf685a5$1@news.povray.org...
> Unless you really badly need the gamma-correction macro for a current 
> project, you may want to wait for the next beta anyway, which will 
> probably make you want to ditch your macros anyway.
>
> I mean, who'll want to use macros when you can just write
>
>   pigment { color rgb <0.2,0.4,0.7> gamma 2.2 }
>
> ;-)

Of course, that would be much more sensible, but inthe mean time, and since 
a few betas now, I have used the macros quite happily (except for that 
stupid thing I posted about). However, with the next beta, of course I shall 
be pleased to ditch my macros :-)  . My workaround is an intermediate stage, 
with some extra work to do but which "keeps me from the street" (as they say 
here).

Thomas


Post a reply to this message

From: Reactor
Subject: Re: Bad operands
Date: 22 May 2010 21:00:01
Message: <web.4bf87cf8385d79cdf886c6d60@news.povray.org>
"Thomas de Groot" <tDOTdegroot@interDOTnlANOTHERDOTnet> wrote:
> "Christian Froeschlin" <chr### [at] chrfrde> schreef in bericht
> news:4bf65c9a$1@news.povray.org...
> >
> > You should check all invocations of GammaColor in your scene file then.
> > You're likely calling it with a 3 component vector but without rgb.
>
> Yes... that must be it because in a test scene this is exactly what makes
> the error appear... Thanks! Good hint!
>
> Thomas


You can also change the input vector to a 5 component color vector if you do
something like this:

#local OldVar = <1.0,0.5,0.2>;

Inside of the macro:

#local NewVar = color rgbft (<0,0,0,0> + OldVar);

Now NewVar is a 5 component color.

-Reactor


Post a reply to this message

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