|
|
|
|
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Hi everybody!
It has been quite a long time since I last posted here - or used POV
for that matter. Probably a year. For my defence I must say I had no
occasion to do so - no time, no computer and/or no phone line (hence no
Internet access). I now have my computer back, some more time and a
good connection at work (ISDN).
I have been browsing news.povray silently for two weeks. It is really
good to read all of you again.
SO
As I am back to using POV, I am back to having problems with it. Can
anybody tell me what's wrong here?
I got a problem with colour component extraction. It seems that when
you use colour component extraction and use the result immediately,
what you got is a float. But if there is an intermediate step
(#declare, #local or pass as a macro argument), it reverts to a colour.
In other word:
floatFunction(aColor.red) is OK, but
#declare myFloat=aColor.red is not a float but a colour
I suspect this is a bug. But of course I could be wrong (would not be
the first time). Could you please check? I browsed p.bugreports but
could find nothing related.
Here is an illustration of the problem, along with some tests to narrow
it:
(All the lines that cause an error before 'no object in scene' are
commented.) (All 'should work' or 'should fail' are based on what I
expect POV to do.)
*/
#declare LightBrown=color rgb <1,.5,.3>; // declare a color
#declare BlueComponent=LightBrown.blue; // extract blue component
// this should be a float
/* Quote from doc :
You may use the dot operator to extract a single component from a
color. Suppose the identifier Shade was previously defined as a color.
Then Shade.red is the float value of the red component of Shade.
Similarly Shade.green, Shade.blue, Shade.filter and Shade.transmit
extract the float value of the other color components.
*/
// The simplest illustration
#declare Test1=abs(LightBrown.blue); // this works
// #declare Test2=abs(BlueComponent); // this fails
// With macros:
// Direct return without assignment
#macro Test3Macro(cColor)
cColor.blue
#end
#declare Test3=abs(Test3Macro(LightBrown)); // this works
/*
// Return with #local
#macro Test4Macro(cColor)
#local Test4Return=cColor.blue;
Test4Return
#end
#declare Test4=abs(Test4Macro(LightBrown)); // this fails
*/
/*
// Color component as an argument
#macro Test5Macro(fFloat)
abs(fFloat);
#end
#declare Test5=Test5Macro(LightBrown.blue); // this fails
*/
// Q: What type is BlueComponent?
// A: color!
// #declare BlueComponent=LightBrown; // this works and should not
// #declare BlueComponent=pi; // this fails but should work
#declare BlueBlueComponent=BlueComponent.blue; // this works OK
// #declare BlueBlueComponent=pi; // this fails but should work
// Q: If BlueComponent is a color, is it rgbft<0,0,blue,0,0>?
// A: It seems BlueComponent = color blue, giving
// rgbft <blue,blue,blue,blue,blue> with operator promotion.
// read the #debug stream
#debug "\n\n BlueComponent=rgbft < "
#debug str(BlueComponent.red,2,2)
#debug ", "
#debug str(BlueComponent.green,2,2)
#debug ", "
#debug str(BlueComponent.blue,2,2)
#debug ", "
#debug str(BlueComponent.filter,2,2)
#debug ", "
#debug str(BlueComponent.transmit,2,2)
#debug " >\n\n"
// Q: What about the other components?
// A: Same problem.
#declare RedComponent=LightBrown.red;
// #declare Test9=abs(RedComponent); // this fails but should work
#declare GreenComponent=LightBrown.green;
// #declare Test10=abs(GreenComponent); // this fails but should work
#declare FilterComponent=LightBrown.filter;
// #declare Test11=abs(FilterComponent); // this fails but should work
#declare TransmitComponent=LightBrown.transmit;
// #declare Test12=abs(TransmitComponent); // this fails but should work
// Testing myself for sanity
// #declare test13=pi.blue; // this fails OK - as it should
// #declare test14=abs(LightBrown); // this fails OK
#declare test15=<1,2,3>.x;
#declare test15=pi; // this works OK
#declare test16=<1,2,3>.red;
#declare test16=pi; // this works OK
#declare test17=rgb <1,2,3>;
#declare test17=test17.blue; // this works and should not
// #declare test17=pi; // this fails OK
#declare test18=color rgb <1,2,3>;
#declare test18=test18.blue; // this works and should not
#declare test18=test18.x; // this works and should not
// #declare test18=pi; // this fails OK
// #declare test19=color <1>; // this fails OK
#declare test20=color 1; // this works
#declare test21=abs(LightBrown.blue);// this works OK
#declare test21=pi; // this works OK
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Read the section titled Common Color Pitfalls, explains there that this is a
known problem not a bug. Suggests workarounds, one way being to enclose the
dot product in parentheses, like so: #declare RedFloat=(Shade.red)
Bob
Philippe Debar <phi### [at] hotmailcom> wrote in message
news:380d7086@news.povray.org...
> Hi everybody!
>
>
> It has been quite a long time since I last posted here - or used POV
> for that matter. Probably a year. For my defence I must say I had no
> occasion to do so - no time, no computer and/or no phone line (hence no
> Internet access). I now have my computer back, some more time and a
> good connection at work (ISDN).
>
> I have been browsing news.povray silently for two weeks. It is really
> good to read all of you again.
>
>
> SO
>
> As I am back to using POV, I am back to having problems with it. Can
> anybody tell me what's wrong here?
>
> I got a problem with colour component extraction. It seems that when
> you use colour component extraction and use the result immediately,
> what you got is a float. But if there is an intermediate step
> (#declare, #local or pass as a macro argument), it reverts to a colour.
>
> In other word:
> floatFunction(aColor.red) is OK, but
> #declare myFloat=aColor.red is not a float but a colour
>
> I suspect this is a bug. But of course I could be wrong (would not be
> the first time). Could you please check? I browsed p.bugreports but
> could find nothing related.
>
> Here is an illustration of the problem, along with some tests to narrow
> it:
> (All the lines that cause an error before 'no object in scene' are
> commented.) (All 'should work' or 'should fail' are based on what I
> expect POV to do.)
> */
>
>
>
> #declare LightBrown=color rgb <1,.5,.3>; // declare a color
> #declare BlueComponent=LightBrown.blue; // extract blue component
> // this should be a float
> /* Quote from doc :
> You may use the dot operator to extract a single component from a
> color. Suppose the identifier Shade was previously defined as a color.
> Then Shade.red is the float value of the red component of Shade.
> Similarly Shade.green, Shade.blue, Shade.filter and Shade.transmit
> extract the float value of the other color components.
> */
>
>
>
>
> // The simplest illustration
>
> #declare Test1=abs(LightBrown.blue); // this works
> // #declare Test2=abs(BlueComponent); // this fails
>
>
>
>
> // With macros:
>
> // Direct return without assignment
> #macro Test3Macro(cColor)
> cColor.blue
> #end
> #declare Test3=abs(Test3Macro(LightBrown)); // this works
>
>
> /*
> // Return with #local
> #macro Test4Macro(cColor)
> #local Test4Return=cColor.blue;
> Test4Return
> #end
> #declare Test4=abs(Test4Macro(LightBrown)); // this fails
> */
>
> /*
> // Color component as an argument
> #macro Test5Macro(fFloat)
> abs(fFloat);
> #end
> #declare Test5=Test5Macro(LightBrown.blue); // this fails
> */
>
>
>
>
> // Q: What type is BlueComponent?
> // A: color!
>
> // #declare BlueComponent=LightBrown; // this works and should not
> // #declare BlueComponent=pi; // this fails but should work
>
> #declare BlueBlueComponent=BlueComponent.blue; // this works OK
> // #declare BlueBlueComponent=pi; // this fails but should work
>
>
>
>
> // Q: If BlueComponent is a color, is it rgbft<0,0,blue,0,0>?
> // A: It seems BlueComponent = color blue, giving
> // rgbft <blue,blue,blue,blue,blue> with operator promotion.
> // read the #debug stream
>
> #debug "\n\n BlueComponent=rgbft < "
> #debug str(BlueComponent.red,2,2)
> #debug ", "
> #debug str(BlueComponent.green,2,2)
> #debug ", "
> #debug str(BlueComponent.blue,2,2)
> #debug ", "
> #debug str(BlueComponent.filter,2,2)
> #debug ", "
> #debug str(BlueComponent.transmit,2,2)
> #debug " >\n\n"
>
>
>
> // Q: What about the other components?
> // A: Same problem.
>
> #declare RedComponent=LightBrown.red;
> // #declare Test9=abs(RedComponent); // this fails but should work
>
> #declare GreenComponent=LightBrown.green;
> // #declare Test10=abs(GreenComponent); // this fails but should work
>
> #declare FilterComponent=LightBrown.filter;
> // #declare Test11=abs(FilterComponent); // this fails but should work
>
> #declare TransmitComponent=LightBrown.transmit;
> // #declare Test12=abs(TransmitComponent); // this fails but should work
>
>
>
>
> // Testing myself for sanity
>
> // #declare test13=pi.blue; // this fails OK - as it should
> // #declare test14=abs(LightBrown); // this fails OK
> #declare test15=<1,2,3>.x;
> #declare test15=pi; // this works OK
> #declare test16=<1,2,3>.red;
> #declare test16=pi; // this works OK
>
> #declare test17=rgb <1,2,3>;
> #declare test17=test17.blue; // this works and should not
> // #declare test17=pi; // this fails OK
>
> #declare test18=color rgb <1,2,3>;
> #declare test18=test18.blue; // this works and should not
> #declare test18=test18.x; // this works and should not
> // #declare test18=pi; // this fails OK
>
> // #declare test19=color <1>; // this fails OK
> #declare test20=color 1; // this works
>
> #declare test21=abs(LightBrown.blue);// this works OK
> #declare test21=pi; // this works OK
>
>
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Philippe Debar wrote:
> I got a problem with colour component extraction. It seems that when
> you use colour component extraction and use the result immediately,
> what you got is a float. But if there is an intermediate step
> (#declare, #local or pass as a macro argument), it reverts to a colour.
>
> In other word:
> floatFunction(aColor.red) is OK, but
> #declare myFloat=aColor.red is not a float but a colour
>
> I suspect this is a bug. But of course I could be wrong (would not be
> the first time). Could you please check? I browsed p.bugreports but
> could find nothing related.
>
AFAIK this is due to the fact that pov uses the first thing it
encouters after the "=" sign to determine the type of the variable.
#declare myFloat=aColor.red is a color because aColor is used to
determine the type, but:
#declare myFloat=0+aColor.red is a float as expected...
Jerome
--
*******************************
* they'll tell you what can't * mailto:ber### [at] inamecom
* be done and why... * http://www.enst.fr/~jberger
* Then do it. *
*******************************
Post a reply to this message
|
|
| |
| |
|
|
From: Philippe Debar
Subject: Re: A color component extraction bug?
Date: 22 Oct 1999 02:59:50
Message: <38100b66@news.povray.org>
|
|
|
| |
| |
|
|
omniVERSE <inv### [at] aolcom> wrote in message
news:380df7e9@news.povray.org...
> Read the section titled Common Color Pitfalls, explains there that this is
a
> known problem not a bug. Suggests workarounds, one way being to enclose
the
> dot product in parentheses, like so: #declare RedFloat=(Shade.red)
>
> Bob
Thank you! I think I didn't check that section of the doc since v2.x ... I
thought it was stuff like 'if you define color rgbf 0 you get a black
object, not an invisible one'.
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Jerome M. BERGER <jbe### [at] enstfr> wrote in message
news:380DF833.21FC33F8@enst.fr...
> AFAIK this is due to the fact that pov uses the first thing it
> encouters after the "=" sign to determine the type of the variable.
Many thanks for the explanation.
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
|
|