POV-Ray : Newsgroups : povray.beta-test : Calling a macro in layered texture Server Time
23 Dec 2024 09:27:46 EST (-0500)
  Calling a macro in layered texture (Message 1 to 8 of 8)  
From: Thomas de Groot
Subject: Calling a macro in layered texture
Date: 29 Jan 2010 08:29:08
Message: <4b62e2a4@news.povray.org>
I wonder if this is a bug or not. Happens as well in 3.7 as in 3.6:

The following code works fine:

#declare MyTex =
texture{ pigment {color GammaColor(<0.83,0.83,0.83>,Gamma) }}
texture{ pigment{uv_mapping p_map16 transmit  0.17}}

The following gives a parse error stating that it cannot find the closing 
pigment brace but finds a macro identifier instead:

#declare MyTex =
texture{ pigment{uv_mapping p_map16 }}
texture{ pigment {color GammaColor(<0.83,0.83,0.83>,Gamma) transmit  0.17}}


What do you think? If not a bug, why does this happen?

Thomas


Post a reply to this message

From: Kenneth
Subject: Re: Calling a macro in layered texture
Date: 29 Jan 2010 11:20:00
Message: <web.4b630a2ad2525f1a65f302820@news.povray.org>
"Thomas de Groot" <tDOTdegroot@interDOTnlANOTHERDOTnet> wrote:
>
> The following gives a parse error stating that it cannot find the closing
> pigment brace but finds a macro identifier instead:
>
> #declare MyTex =
> texture{ pigment{uv_mapping p_map16 }}
> texture{ pigment {color GammaColor(<0.83,0.83,0.83>,Gamma) transmit  0.17}}
>

Just a simplistic question before posting further--and it might be a nonsense
question ;-)  Does the following work, or does it also cause the error? I just
reversed the order of the textures...

#declare MyTex =
texture{ pigment {color GammaColor(<0.83,0.83,0.83>,Gamma) transmit  0.17}}
texture{ pigment{uv_mapping p_map16 }}

In any case, it might be easier to track down with just
#declare MyTex =
texture{ pigment {color GammaColor(<0.83,0.83,0.83>,Gamma) transmit  0.17}}

.....that is, eliminating as many extraneous things as possible. As I see it at
present, the addition of 'transmit' after the macro seems to be the cause
of the problem (for whatever reason); the code works OK without it.

I've come across what I believe to be similar situations as well--POV expecting
to see one 'thing' but seeing another...and I've usually tracked it down/solved
it by putting a semi-colon 'separator' in a particular place (or some other odd
workaround.) Don't know if that has any relation to your situation, though.

Ken


Post a reply to this message

From: Thorsten Froehlich
Subject: Re: Calling a macro in layered texture
Date: 29 Jan 2010 15:53:56
Message: <4B634AE3.50907@trf.de>
On 29.01.10 14:29, Thomas de Groot wrote:
> I wonder if this is a bug or not. Happens as well in 3.7 as in 3.6:
>
> The following code works fine:
>
> #declare MyTex =
> texture{ pigment {color GammaColor(<0.83,0.83,0.83>,Gamma) }}
> texture{ pigment{uv_mapping p_map16 transmit  0.17}}
>
> The following gives a parse error stating that it cannot find the closing
> pigment brace but finds a macro identifier instead:
>
> #declare MyTex =
> texture{ pigment{uv_mapping p_map16 }}
> texture{ pigment {color GammaColor(<0.83,0.83,0.83>,Gamma) transmit  0.17}}
>
>
> What do you think? If not a bug, why does this happen?

The question is: What does the macro return? A vector? - If so, that vector 
is interpreted to be a 5-component vector (or extended accordingly). If a 
vector is returned, the error message is correct 
(http://www.povray.org/documentation/view/3.6.1/230/) because the transmit 
would be a second color you are specifying, which is of course "unexpected".

	Thorsten


Post a reply to this message

From: Kenneth
Subject: Re: Calling a macro in layered texture
Date: 30 Jan 2010 12:35:00
Message: <web.4b646b1dd2525f1a65f302820@news.povray.org>
Thorsten Froehlich <tho### [at] trfde> wrote:>

> > [Thomas wrote:]
> > The following gives a parse error stating that it cannot find the closing
> > pigment brace but finds a macro identifier instead:
> >
> > #declare MyTex =
> > texture{ pigment{uv_mapping p_map16 }}
> > texture{ pigment {color GammaColor(<0.83,0.83,0.83>,Gamma) transmit  0.17}}
> >
>
> The question is: What does the macro return? A vector? - If so, that vector
> is interpreted to be a 5-component vector (or extended accordingly). If a
> vector is returned, the error message is correct
> (http://www.povray.org/documentation/view/3.6.1/230/) because the transmit
> would be a second color you are specifying, which is of course "unexpected".
>

I want to make sure I understand this myself. (I just re-read the "common color
pitfalls" section of the docs, but don't quite know which part is applicable
here.) Let's assume that Thomas's macro returns a simple 3-component vector.
Would adding 'rgb' solve his problem?

texture{ pigment {color rgb GammaColor(<0.83,0.83,0.83>,Gamma) transmit  0.17}}

Ken


Post a reply to this message

From: Thorsten Froehlich
Subject: Re: Calling a macro in layered texture
Date: 30 Jan 2010 14:19:37
Message: <4b648649@news.povray.org>
On 30.01.10 18:30, Kenneth wrote:
> Thorsten Froehlich<tho### [at] trfde>  wrote:>
>
>>> [Thomas wrote:]
>>> The following gives a parse error stating that it cannot find the closing
>>> pigment brace but finds a macro identifier instead:
>>>
>>> #declare MyTex =
>>> texture{ pigment{uv_mapping p_map16 }}
>>> texture{ pigment {color GammaColor(<0.83,0.83,0.83>,Gamma) transmit  0.17}}
>>>
>>
>> The question is: What does the macro return? A vector? - If so, that vector
>> is interpreted to be a 5-component vector (or extended accordingly). If a
>> vector is returned, the error message is correct
>> (http://www.povray.org/documentation/view/3.6.1/230/) because the transmit
>> would be a second color you are specifying, which is of course "unexpected".
>>
>
> I want to make sure I understand this myself. (I just re-read the "common color
> pitfalls" section of the docs, but don't quite know which part is applicable
> here.) Let's assume that Thomas's macro returns a simple 3-component vector.
> Would adding 'rgb' solve his problem?
>
> texture{ pigment {color rgb GammaColor(<0.83,0.83,0.83>,Gamma) transmit  0.17}}

Yes, I think so. But it may depend on what exactly the macro does. The color 
parsing is a bit messy though because it allows so many variants to do the 
same thing.

	Thorsten


Post a reply to this message

From: Alain
Subject: Re: Calling a macro in layered texture
Date: 30 Jan 2010 19:25:40
Message: <4b64ce04$1@news.povray.org>

> Thorsten Froehlich<tho### [at] trfde>  wrote:>
>
>>> [Thomas wrote:]
>>> The following gives a parse error stating that it cannot find the closing
>>> pigment brace but finds a macro identifier instead:
>>>
>>> #declare MyTex =
>>> texture{ pigment{uv_mapping p_map16 }}
>>> texture{ pigment {color GammaColor(<0.83,0.83,0.83>,Gamma) transmit  0.17}}
>>>
>>
>> The question is: What does the macro return? A vector? - If so, that vector
>> is interpreted to be a 5-component vector (or extended accordingly). If a
>> vector is returned, the error message is correct
>> (http://www.povray.org/documentation/view/3.6.1/230/) because the transmit
>> would be a second color you are specifying, which is of course "unexpected".
>>
>
> I want to make sure I understand this myself. (I just re-read the "common color
> pitfalls" section of the docs, but don't quite know which part is applicable
> here.) Let's assume that Thomas's macro returns a simple 3-component vector.
> Would adding 'rgb' solve his problem?
>
> texture{ pigment {color rgb GammaColor(<0.83,0.83,0.83>,Gamma) transmit  0.17}}
>
> Ken
>
>
>
>
>
>
>

Not sure. I found that rgb<1,0.2,0.5,0.7> is treated as rgbf<1,0.2,0.5,0.7>.
That is, if you provide a 4 dimentions vector as a colour, the fourth 
component IS used as the filter value.

A 5 dimentions vector will also include a transmit value.
rgb<1,0.2,0.5,0.7,0.17> is treated as rgbft<1,0.2,0.5,0.7,0.17>.

Your sample would gives something like (Assuming Gamma =1):

texture{ pigment {color rgb<0.83, 0.83, 0.83, 0> transmit 0.17}}

or even this, if the macro is made to handle 5 dimentions colours:

texture{ pigment {color rgb<0.83, 0.83, 0.83, 0, 0> transmit 0.17}}

It would be safer to rewrite the macro ether as 3 macros (GammaColor3, 
GammaColor4 and GammaColor5) or a single macro with another parameter to 
sellect the number of dimention of the returned vector.



Alain


Post a reply to this message

From: Thomas de Groot
Subject: Re: Calling a macro in layered texture
Date: 1 Feb 2010 04:55:35
Message: <4b66a517$1@news.povray.org>
Sorrry for not answering immediately, but I had a hardware problem....

The macro returns a 3 component vector:

#macro GammaColor (Color,Gamma)
  rgb <pow(Color.red,Gamma),pow(Color.green,Gamma),pow(Color.blue,Gamma)>
#end

Somehow, I got it to work now correctly - I don't know exactly how - but I 
guess that I had a kind of conflict of interest. I discovered that I called 
the macro twice and that may (?) have caused the problem... It is a bit 
frustrating that I cannot put exactly the finger on the sore spot, so to 
say... :(

Thanks a lot anyway, to Kenneth, Thorsten and Alain for their comments. They 
helped me to think less muddy :)

Thomas


Post a reply to this message

From: Thomas de Groot
Subject: Re: Calling a macro in layered texture
Date: 1 Feb 2010 10:24:11
Message: <4b66f21b$1@news.povray.org>
"Alain" <aze### [at] qwertyorg> schreef in bericht 
news:4b64ce04$1@news.povray.org...
> It would be safer to rewrite the macro ether as 3 macros (GammaColor3, 
> GammaColor4 and GammaColor5) or a single macro with another parameter to 
> sellect the number of dimention of the returned vector.
>

Yes, this is what I shall do eventually, for those cases where filter and/or 
transmit are used.

Thomas


Post a reply to this message

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