POV-Ray : Newsgroups : povray.general : Order of texture and pigment matter? Server Time
27 Nov 2024 16:51:19 EST (-0500)
  Order of texture and pigment matter? (Message 1 to 9 of 9)  
From: wealthychef
Subject: Order of texture and pigment matter?
Date: 12 May 2008 18:25:00
Message: <web.4828c29b90917db34a296dd40@news.povray.org>
I don't understand something.  When I use the following code:

#declare testfinish = finish {ambient 0.7}

triangle {
    v0 v1 v2
    texture {
       pignment { color Red }
      testfinish
    }
}

 I get this error:
File: jaime.inc  Line: 94
File Context (5 lines):
    v0 v1 v2
    texture {
      pigment { color Red }
      testfinish
Parse Error: No matching } in 'texture', finish identifier found instead

But if I just switch the order of pigment and testfinish, as follows, the scene
renders as I expect:

triangle {
    v0 v1 v2
    texture {
      testfinish
      pigment { color Red }
        }
}

The same is true if I don't use the #declare, but just use the finish keyword
directly:

triangle {
    v0 v1 v2
    texture {
      pigment { color Red }
      finish {ambient 0.7}
        }
}


I've seen this kind of thing before and always "just make it work," but I'd love
to know what's actually happening here.


Post a reply to this message

From: Zeger Knaepen
Subject: Re: Order of texture and pigment matter?
Date: 12 May 2008 19:30:51
Message: <4828d32b$1@news.povray.org>
"wealthychef" <nomail@nomail> wrote in message 
news:web.4828c29b90917db34a296dd40@news.povray.org...
>I don't understand something.  When I use the following code:
>
> #declare testfinish = finish {ambient 0.7}
>
> triangle {
>    v0 v1 v2
>    texture {
>       pignment { color Red }
>      testfinish
>    }
> }
>
> I get this error:
> File: jaime.inc  Line: 94
> File Context (5 lines):
>    v0 v1 v2
>    texture {
>      pigment { color Red }
>      testfinish
> Parse Error: No matching } in 'texture', finish identifier found instead
>
> But if I just switch the order of pigment and testfinish, as follows, the 
> scene
> renders as I expect:
>
> triangle {
>    v0 v1 v2
>    texture {
>      testfinish
>      pigment { color Red }
>        }
> }

actually I wouldn't have expected that to work, unless testfinish is 
considered a complete texture by POV-Ray.

cu!
-- 
#macro G(b,e)b+(e-b)*C/50#end#macro _(b,e,k,l)#local C=0;#while(C<50)
sphere{G(b,e)+3*z.1pigment{rgb G(k,l)}finish{ambient 1}}#local C=C+1;
#end#end _(y-x,y,x,x+y)_(y,-x-y,x+y,y)_(-x-y,-y,y,y+z)_(-y,y,y+z,x+y)
_(0x+y.5+y/2x)_(0x-y.5+y/2x)            // ZK http://www.povplace.com


Post a reply to this message

From: wealthychef
Subject: Re: Order of texture and pigment matter?
Date: 12 May 2008 19:55:00
Message: <web.4828d8b0b71ebc3b4a296dd40@news.povray.org>
"Zeger Knaepen" <zeg### [at] povplacecom> wrote:
> "wealthychef" <nomail@nomail> wrote in message

> > But if I just switch the order of pigment and testfinish, as follows, the
> > scene
> > renders as I expect:
> >
> > triangle {
> >    v0 v1 v2
> >    texture {
> >      testfinish
> >      pigment { color Red }
> >        }
> > }
>
> actually I wouldn't have expected that to work, unless testfinish is
> considered a complete texture by POV-Ray.
>
> cu!


Care to expand on that a little?  Why wouldn't it work?   What is going on?
Clue, please.  :-)


Post a reply to this message

From: Tim Attwood
Subject: Re: Order of texture and pigment matter?
Date: 12 May 2008 20:25:16
Message: <4828dfec$1@news.povray.org>
> Care to expand on that a little?  Why wouldn't it work?   What is going 
> on?
> Clue, please.  :-)

POV finds a finish identifier, not a finish statement,
identifiers and statements aren't interchangeable.
It expects usage like ...

#declare testfinish = finish {ambient 0.7};

triangle {
    v0, v1, v2
    texture {
      pigment { Red }
      finish { testfinish }
    }
}

Declare statements shouldn't be confused with macros.
A macro substitutes the lines directly into the calling
code instead of using identifiers. Example...

#macro testfinish() finish {ambient 0.7} #end

triangle {
    v0, v1, v2
    texture {
      pigment { Red }
      testfinish()
   }
}

Here testfinish() is replaced by "finish {ambient 0.7}"
which is a finish statement instead of a finish identifier.


Post a reply to this message

From: Thomas de Groot
Subject: Re: Order of texture and pigment matter?
Date: 13 May 2008 03:38:26
Message: <48294572$1@news.povray.org>
"wealthychef" <nomail@nomail> schreef in bericht 
news:web.4828c29b90917db34a296dd40@news.povray.org...
>I don't understand something.  When I use the following code:
>
> #declare testfinish = finish {ambient 0.7}
>
> triangle {
>    v0 v1 v2
>    texture {
>       pignment { color Red }
>      testfinish
>    }
> }
>

I think this should be written as:
triangle {
   v0 v1 v2
   texture {
      pignment { color Red }
      finish {testfinish}
   }
}

Thomas


Post a reply to this message

From: Thorsten Froehlich
Subject: Re: Order of texture and pigment matter?
Date: 13 May 2008 05:31:03
Message: <48295fd7$1@news.povray.org>
Zeger Knaepen wrote:
> actually I wouldn't have expected that to work

You are correct, it is no legal syntax, but the parser is flexible enough to 
accept it anyway.

	Thorsten


Post a reply to this message

From: wealthychef
Subject: Re: Order of texture and pigment matter?
Date: 13 May 2008 12:30:00
Message: <web.4829c11eb71ebc3b4a296dd40@news.povray.org>
"Tim Attwood" <tim### [at] comcastnet> wrote:
> > Care to expand on that a little?  Why wouldn't it work?   What is going
> > on?
> > Clue, please.  :-)
>
> POV finds a finish identifier, not a finish statement,
> identifiers and statements aren't interchangeable.
> It expects usage like ...
>
> #declare testfinish = finish {ambient 0.7};
>
> triangle {
>     v0, v1, v2
>     texture {
>       pigment { Red }
>       finish { testfinish }
>     }
> }
>
> Declare statements shouldn't be confused with macros.
> A macro substitutes the lines directly into the calling
> code instead of using identifiers. Example...
>
> #macro testfinish() finish {ambient 0.7} #end
>
> triangle {
>     v0, v1, v2
>     texture {
>       pigment { Red }
>       testfinish()
>    }
> }
>
> Here testfinish() is replaced by "finish {ambient 0.7}"
> which is a finish statement instead of a finish identifier.

thank you.  This point has been confusing me for years about Povray, as I only
occasionally dabble in it.  So it seems as though in a #declare statement, the
"finish {ambient 0.7}" piece is somehow compiled (?) into a "finish
identifier?"   What is the difference between an identifier and a statement?
Is this true:  "finish" is to "identifier" in Povray as "integer" is to
"variable" in C?
Aha! I think I get it:

If I were to say
#declare testtexture texture { pigment {Red} finish {ambient 0.7} };

I then use it like this:

triangle {
v0,v1,v2
 texture {testtexture}
}

Thank you.  It's interesting and revealing.


Post a reply to this message

From: Dave Dunn
Subject: Re: Order of texture and pigment matter?
Date: 13 May 2008 13:55:00
Message: <web.4829d5a3b71ebc3b653c34500@news.povray.org>
Actually, it might make more sense in explaining that macro to insert a value as
in:

#macro testfinish(V) finish {ambient V} #end

That way, you could change the value (V) when calling the macro, like so:

testfinish(.7)

-- Dave

>



"wealthychef" <nomail@nomail> wrote:
> "Tim Attwood" <tim### [at] comcastnet> wrote:
> > > Care to expand on that a little?  Why wouldn't it work?   What is going
> > > on?
> > > Clue, please.  :-)
> >
> > POV finds a finish identifier, not a finish statement,
> > identifiers and statements aren't interchangeable.
> > It expects usage like ...
> >
> > #declare testfinish = finish {ambient 0.7};
> >
> > triangle {
> >     v0, v1, v2
> >     texture {
> >       pigment { Red }
> >       finish { testfinish }
> >     }
> > }
> >
> > Declare statements shouldn't be confused with macros.
> > A macro substitutes the lines directly into the calling
> > code instead of using identifiers. Example...
> >
> > #macro testfinish() finish {ambient 0.7} #end
> >
> > triangle {
> >     v0, v1, v2
> >     texture {
> >       pigment { Red }
> >       testfinish()
> >    }
> > }
> >
> > Here testfinish() is replaced by "finish {ambient 0.7}"
> > which is a finish statement instead of a finish identifier.
>
> thank you.  This point has been confusing me for years about Povray, as I only
> occasionally dabble in it.  So it seems as though in a #declare statement, the
> "finish {ambient 0.7}" piece is somehow compiled (?) into a "finish
> identifier?"   What is the difference between an identifier and a statement?
> Is this true:  "finish" is to "identifier" in Povray as "integer" is to
> "variable" in C?
> Aha! I think I get it:
>
> If I were to say
> #declare testtexture texture { pigment {Red} finish {ambient 0.7} };
>
> I then use it like this:
>
> triangle {
> v0,v1,v2
>  texture {testtexture}
> }
>
> Thank you.  It's interesting and revealing.


Post a reply to this message

From: Tim Attwood
Subject: Re: Order of texture and pigment matter?
Date: 13 May 2008 18:00:48
Message: <482a0f90$1@news.povray.org>
> thank you.  This point has been confusing me for years about Povray, as I 
> only
> occasionally dabble in it.  So it seems as though in a #declare statement, 
> the
> "finish {ambient 0.7}" piece is somehow compiled (?) into a "finish
> identifier?"   What is the difference between an identifier and a 
> statement?
> Is this true:  "finish" is to "identifier" in Povray as "integer" is to
> "variable" in C?
> Aha! I think I get it:

Close, testtexture is a variable, the contents of testtexture is
a finish identifier. The statement after "#declare testtexture =" is
evaluated, found to be a finish, and stored in testtexture as a
finish identifier. An identifier is most like a pointer in C...

>
> If I were to say
> #declare testtexture texture { pigment {Red} finish {ambient 0.7} };

Right, but with the "="

> I then use it like this:
>
> triangle {
> v0,v1,v2
> texture {testtexture}
> }
>
> Thank you.  It's interesting and revealing.

Glad to help.


Post a reply to this message

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