POV-Ray : Newsgroups : povray.advanced-users : Problems with macro (3.6) : Re: Problems with macro (3.6) Server Time
29 Jun 2024 02:22:45 EDT (-0400)
  Re: Problems with macro (3.6)  
From: clipka
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

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