POV-Ray : Newsgroups : povray.advanced-users : Problems with macro (3.6) Server Time
23 Nov 2024 23:02:53 EST (-0500)
  Problems with macro (3.6) (Message 1 to 10 of 10)  
From: SharkD
Subject: Problems with macro (3.6)
Date: 9 Jun 2010 17:22:25
Message: <4c100611$1@news.povray.org>
I've written the following macro to tweak some color values:

#macro gamma_color_adjust(in_color, in_transmit)
	#local out_gamma = 2.2;
	#if (in_transmit)
		VPow(in_color,out_gamma) + <0,0,0,in_transmit,>
	#else
		VPow(in_color,out_gamma)
	#end
#end

The macro takes a three component color vector as the first parameter, 
and a single transmit parameter as the second parameter. I keep getting 
the error, "Expected 6 parameters but only 5 found." What did I do wrong?


-- 
http://isometricland.com


Post a reply to this message

From: clipka
Subject: Re: Problems with macro (3.6)
Date: 9 Jun 2010 18:40:00
Message: <4c101840$1@news.povray.org>
Am 09.06.2010 23:22, schrieb SharkD:
> I've written the following macro to tweak some color values:
>
> #macro gamma_color_adjust(in_color, in_transmit)
> #local out_gamma = 2.2;
> #if (in_transmit)
> VPow(in_color,out_gamma) + <0,0,0,in_transmit,>
> #else
> VPow(in_color,out_gamma)
> #end
> #end
>
> The macro takes a three component color vector as the first parameter,
> and a single transmit parameter as the second parameter. I keep getting
> the error, "Expected 6 parameters but only 5 found." What did I do wrong?

Not sure what's wrong there (sounds pretty strange), but I suggest a 
different approach to the macro anyway:

     #macro Gamma_Adjust(In_Color)
     #local Out_Gamma = 2.2;
       rgbft <
         pow(In_Color.red,   Out_Gamma),
         pow(In_Color.green, Out_Gamma),
         pow(In_Color.blue,  Out_Gamma),
         In_Color.filter,
         In_Color.transmit
       >
     #end

Using three separate calls to pow isn't any slower than VPow (actually 
it's faster, because VPow is just another macro that itself calls pow 
thrice), and you also don't need separate parameters; just replace (e.g.)

     color rgbt <R,G,B,T>

with

     color Gamma_Adjust( rgbt <R,G,B,T> )

It should work with any color literal syntax you can imagine, such as 
"color red R", "color rgb GREY filter F", "color rgbft <R,G,B,F,T>", or 
what-have-you.

(BTW, I suggest using Mixed_Case identifiers for anything you name 
yourself, as lower_case identifiers pose a risk of conflicting with 
future SDL keywords.)


Post a reply to this message

From: Reactor
Subject: Re: Problems with macro (3.6)
Date: 9 Jun 2010 18:55:01
Message: <web.4c101ab385f50d43e69105fc0@news.povray.org>
SharkD <pos### [at] gmailcom> wrote:
> I've written the following macro to tweak some color values:
>
> #macro gamma_color_adjust(in_color, in_transmit)
>  #local out_gamma = 2.2;
>  #if (in_transmit)
>   VPow(in_color,out_gamma) + <0,0,0,in_transmit,>
>  #else
>   VPow(in_color,out_gamma)
>  #end
> #end
>
> The macro takes a three component color vector as the first parameter,
> and a single transmit parameter as the second parameter. I keep getting
> the error, "Expected 6 parameters but only 5 found." What did I do wrong?
>
>
> --
> http://isometricland.com


I didn't try it, but I noticed that there is a trailing comma after in_transmit,
which could make povray think that there should be another value.  If this is a
direct copy&paste, double check that comma.

    HTH
-Reactor


Post a reply to this message

From: SharkD
Subject: Re: Problems with macro (3.6)
Date: 9 Jun 2010 19:51:25
Message: <4c1028fd$1@news.povray.org>
On 6/9/2010 6:50 PM, Reactor wrote:
> I didn't try it, but I noticed that there is a trailing comma after in_transmit,
> which could make povray think that there should be another value.  If this is a
> direct copy&paste, double check that comma.
>
>      HTH
> -Reactor
>
>

IIRC, trailing commas after vector components are legal. I will try 
without though.

-- 
http://isometricland.com


Post a reply to this message

From: SharkD
Subject: Re: Problems with macro (3.6)
Date: 9 Jun 2010 20:15:14
Message: <4c102e92$1@news.povray.org>
On 6/9/2010 6:39 PM, clipka wrote:
> It should work with any color literal syntax you can imagine, such as
> "color red R", "color rgb GREY filter F", "color rgbft <R,G,B,F,T>", or
> what-have-you.
>
> (BTW, I suggest using Mixed_Case identifiers for anything you name
> yourself, as lower_case identifiers pose a risk of conflicting with
> future SDL keywords.)

It didn't work for me, in 3.6 at least. Example:

     #macro Gamma_Adjust(In_Color)
     #local Out_Gamma = 2.2;
       rgbft <
         pow(In_Color.red,   Out_Gamma),
         pow(In_Color.green, Out_Gamma),
         pow(In_Color.blue,  Out_Gamma),
         In_Color.filter,
         In_Color.transmit
       >
     #end

     #declare test_color = Gamma_Adjust(<1,1,1>);

Results in an "Bad operands for period operator" error.

-- 
http://isometricland.com


Post a reply to this message

From: Thomas de Groot
Subject: Re: Problems with macro (3.6)
Date: 10 Jun 2010 03:04:21
Message: <4c108e75$1@news.povray.org>
"SharkD" <pos### [at] gmailcom> schreef in bericht 
news:4c102e92$1@news.povray.org...
> Results in an "Bad operands for period operator" error.

You certainly have seen my thread in povray.general: "Bad operands", on 
20-5-2010?  :-)

Thomas


Post a reply to this message

From: clipka
Subject: Re: Problems with macro (3.6)
Date: 10 Jun 2010 07:58:56
Message: <4c10d380@news.povray.org>
Am 10.06.2010 02:15, schrieb SharkD:
> On 6/9/2010 6:39 PM, clipka wrote:
>> It should work with any color literal syntax you can imagine, such as
>> "color red R", "color rgb GREY filter F", "color rgbft <R,G,B,F,T>", or
>> what-have-you.
>>
>> (BTW, I suggest using Mixed_Case identifiers for anything you name
>> yourself, as lower_case identifiers pose a risk of conflicting with
>> future SDL keywords.)
>
> It didn't work for me, in 3.6 at least. Example:
>
> #declare test_color = Gamma_Adjust(<1,1,1>);
>
> Results in an "Bad operands for period operator" error.

<1,1,1> is not a color (=5D vector), but a 3D vector. Try this instead:

    #declare test_color = Gamma_Adjust( rgb <1,1,1> );


Post a reply to this message

From: SharkD
Subject: Re: Problems with macro (3.6)
Date: 10 Jun 2010 23:33:38
Message: <4c11ae92@news.povray.org>
On 6/10/2010 3:04 AM, Thomas de Groot wrote:
> "SharkD"<pos### [at] gmailcom>  schreef in bericht
> news:4c102e92$1@news.povray.org...
>> Results in an "Bad operands for period operator" error.
>
> You certainly have seen my thread in povray.general: "Bad operands", on
> 20-5-2010?  :-)
>
> Thomas
>
>


No, I didn't. Was the problem ever resolved?

-- 
http://isometricland.com


Post a reply to this message

From: SharkD
Subject: Re: Problems with macro (3.6)
Date: 10 Jun 2010 23:57:37
Message: <4c11b431@news.povray.org>
I changed the macro to this and it seems to work OK:


#macro gamma_color_adjust(in_color)
	#local out_gamma = 2.2;
	#local in_color = in_color + <0,0,0,0,0>;
	<
		pow(in_color.red, out_gamma),
		pow(in_color.green, out_gamma),
		pow(in_color.blue, out_gamma),
		in_color.filter,
		in_color.transmit
	>
#end


-- 
http://isometricland.com


Post a reply to this message

From: Thomas de Groot
Subject: Re: Problems with macro (3.6)
Date: 11 Jun 2010 03:21:37
Message: <4c11e401@news.povray.org>
"SharkD" <pos### [at] gmailcom> schreef in bericht 
news:4c11ae92@news.povray.org...
>
> No, I didn't. Was the problem ever resolved?
>

Yes. Clipka explained it all very well there.

Thomas


Post a reply to this message

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