POV-Ray : Newsgroups : povray.binaries.animations : Uberpov persistent feature for animation of big scene Server Time
31 Oct 2024 08:17:00 EDT (-0400)
  Uberpov persistent feature for animation of big scene (Message 1 to 10 of 14)  
Goto Latest 10 Messages Next 4 Messages >>>
From: muyu
Subject: Uberpov persistent feature for animation of big scene
Date: 5 Jan 2018 20:15:01
Message: <web.5a50228f5c821073553834de0@news.povray.org>
As suggested, I tried the Uberpov persistent feature to reduce parsing time. I
replace the #declare with #persistent and also union all the objects. But still
it need some time for parsing. Here I attached the scene (it is wheat crop
field...relative small field). Could you please help have a look? Thanks a lot
in advance. Shouyang


Post a reply to this message


Attachments:
Download 'wheat_animation.rar.dat' (1045 KB)

From: clipka
Subject: Re: Uberpov persistent feature for animation of big scene
Date: 6 Jan 2018 01:01:15
Message: <5a50662b$1@news.povray.org>
Am 06.01.2018 um 02:12 schrieb muyu:
> As suggested, I tried the Uberpov persistent feature to reduce parsing time. I
> replace the #declare with #persistent and also union all the objects. But still
> it need some time for parsing. Here I attached the scene (it is wheat crop
> field...relative small field). Could you please help have a look? Thanks a lot
> in advance. Shouyang

You absolutely positively need to wrap the `#persistent Foo = ...`
statements into `#ifndef(Foo) ... #end` blocks. Otherwise, it
effectively makes no difference whether they persist from frame to frame
because you're re-defining them over and over again.


Post a reply to this message

From: Kenneth
Subject: Re: Uberpov persistent feature for animation of big scene
Date: 6 Jan 2018 19:10:01
Message: <web.5a5163af6e53ffa4a47873e10@news.povray.org>
clipka <ano### [at] anonymousorg> wrote:
>
> You absolutely positively need to wrap the `#persistent Foo = ...`
> statements into `#ifndef(Foo) ... #end` blocks. Otherwise, it
> effectively makes no difference whether they persist from frame to frame
> because you're re-defining them over and over again.

Do you mean like this... (I'm using his very first texture as an example)...

#ifndef(APPID_340814880_342762184)
#persistent APPID_340814880_342762184 = texture {
  pigment {
    color rgbt <0,1,0,0>
  }
    finish {
    ambient 0.0
    diffuse 0.041370, 0.008514
    specular 0.0
  }
#else
#end

*If* that's correct, then I do see that the #persistent is
only invoked on the first animation frame; all the following frames will use the
already-'declared' APPID_340814880_342762184... because it's 'persistent.'

Am I thinking right?

It looks like most of his entire scene is in a union, so here's a question:
Instead of having to wrap each and every #persistent FOO = ......  in an #ifndef
block, could the entire UNION have only *one* #ifndef block around it instead?
Or, maybe like...

#ifndef(FOO)
#persistent FOO =
union{.....
....... everything (NO #persistent for any of these items, but regular #declares
or #locals, if needed).........
..............
}
#else
#end

object{FOO}


Post a reply to this message

From: clipka
Subject: Re: Uberpov persistent feature for animation of big scene
Date: 6 Jan 2018 22:11:26
Message: <5a518fde$1@news.povray.org>
Am 07.01.2018 um 01:04 schrieb Kenneth:

> Do you mean like this... (I'm using his very first texture as an example)...
[snip]
> *If* that's correct, then I do see that the #persistent is
> only invoked on the first animation frame; all the following frames will use the
> already-'declared' APPID_340814880_342762184... because it's 'persistent.'
> 
> Am I thinking right?

Yes.

> It looks like most of his entire scene is in a union, so here's a question:
> Instead of having to wrap each and every #persistent FOO = ......  in an #ifndef
> block, could the entire UNION have only *one* #ifndef block around it instead?
> Or, maybe like...
> 
> #ifndef(FOO)
> #persistent FOO =
> union{.....
> ........ everything (NO #persistent for any of these items, but regular #declares
> or #locals, if needed).........
> ...............
> }
> #else
> #end
> 
> object{FOO}

I presume you mean something like this:

    #ifndef(MyBigFatUnion)
      #define Blah = ...
      #define Dunno = ...
      ...
      #persistent MyBigFatUnion = union {
        object { Blah }
        object { Dunno }
        ...
      }
    #endif
    object { MyBigFatUnion }

That should indeed work fine.


Post a reply to this message

From: Kenneth
Subject: Re: Uberpov persistent feature for animation of big scene
Date: 7 Jan 2018 00:40:00
Message: <web.5a51b2006e53ffa4a47873e10@news.povray.org>
clipka <ano### [at] anonymousorg> wrote:

>
> I presume you mean something like this:
>
>     #ifndef(MyBigFatUnion)
>       #define Blah = ...
>       #define Dunno = ...
[clip]

Uh... #define? I couldn't find that in the docs. A UNIX thing maybe??

I'm guessing that you mean...

#ifndef(MyBigFatUnion)
#declare Blah = ...
#declare Dunno = ...

I do see what you mean, though-- that the #declare-d things (#declared within
the #ifndef block) need to come *before* the #persistent union{...} of those
things.

I was somehow thinking that the following kind of construct would work instead,
and still be 'persistent' (although it's a strange example, I admit-- I wouldn't
normally put #declares within a union)...

#ifndef(FOO)
#persistent FOO =
union{
#declare TEX_1 = texture{...}
#declare MY_BOX = box{0,1}
object{MY_BOX texture{TEX_1}
....similar stuff...
....
#end

object{FOO}

My guess is that the inner #declares are NOT 'persistent', even though they are
wrapped in a #persistent block. (Assuming that my crazy union even works at
all!!)


Post a reply to this message

From: clipka
Subject: Re: Uberpov persistent feature for animation of big scene
Date: 7 Jan 2018 04:39:47
Message: <5a51eae3$1@news.povray.org>
Am 07.01.2018 um 06:37 schrieb Kenneth:

> Uh... #define? I couldn't find that in the docs. A UNIX thing maybe??

A C/C++ thing. It's a miracle I'm not mixing it up with POV-Ray's
`#declare' more often.

> I was somehow thinking that the following kind of construct would work instead,
> and still be 'persistent' (although it's a strange example, I admit-- I wouldn't
> normally put #declares within a union)...
> 
> #ifndef(FOO)
> #persistent FOO =
> union{
> #declare TEX_1 = texture{...}
> #declare MY_BOX = box{0,1}
> object{MY_BOX texture{TEX_1}
> .....similar stuff...
> .....
> #end
> 
> object{FOO}
> 
> My guess is that the inner #declares are NOT 'persistent', even though they are
> wrapped in a #persistent block. (Assuming that my crazy union even works at
> all!!)

It should work fine as well.

The inner `#declare`s are indeed not persistent; however, their content
(or, more precisely, a copy thereof) is inserted into a union that /is/
persistent.

If it helps understand the concept, you might think of `#persistent` as
a "super-global" equivalent of `#declare`.

Take a look at the following macro, and compare it to your code:

    #macro MyMacro()
      #ifndef(FOO)
      #declare FOO =
        union {
          #local TEX_1 = texture{...}
          #local MY_BOX = box{0,1}
          object{MY_BOX texture{TEX_1}
          ...
        }
      #end
      object{FOO}
    #end

Note how this assembles a union from local variables (which "die" each
time the end of the macro is reached), and assigns the resulting object
to a global variable, which will still be "alive" if the macro is
invoked again later.

Now just like a macro's local variables "die" each time the end of the
macro is reached, but their contents can "survive" into the next macro
invocation if plugged into a global variable, so do global variables
"die" each time the "end of the frame" is reached, but their contents
can "survive" into the next frame if plugged into a persistent variable.


Post a reply to this message

From: Kenneth
Subject: Re: Uberpov persistent feature for animation of big scene
Date: 7 Jan 2018 15:10:01
Message: <web.5a527e686e53ffa4a47873e10@news.povray.org>
clipka <ano### [at] anonymousorg> wrote:
>
> Take a look at the following macro, and compare it to your code:
>
>     #macro MyMacro()
>       #ifndef(FOO)
>       #declare FOO =
>         union {
>           #local TEX_1 = texture{...}
>           #local MY_BOX = box{0,1}
>           object{MY_BOX texture{TEX_1}
>           ...
>         }
>       #end
>       object{FOO}
>     #end
>
> Note how this assembles a union from local variables (which "die" each
> time the end of the macro is reached), and assigns the resulting object
> to a global variable, which will still be "alive" if the macro is
> invoked again later.
>

I never realized that a macro's result-- object(FOO)-- was a global variable
that remained 'alive' in a scene once the macro was invoked. Is that
specifically because #ifndef is used here? (Actually, I'm guessing that it has
nothing to do with #ifndef.)

I always thought the *entire* contents of a macro died after each use (as if
object(FOO) was always a #local thing as well.) So in effect, the result is
'cached' for use later. Very interesting!

I'm thinking of another example, just to help clarify the concept:

#macro MyMacro()
pigment{image_map{tiff "MY_IMAGE.tif"}} // a large hi-res file
#end

Same cached behavior? (i.e., is the pigment already treated as a 'global'
thing)? Or does the macro need to be like this instead:

#macro MyMacro()
#local FOO = pigment{image_map{tiff "MY_IMAGE.tif"}}
pigment{FOO}
// or maybe just FOO by itself?
#end

Sorry for getting a bit off-topic. Although I've used macros plenty of times,
there are still a few mysteries that I need to fully understand.


Post a reply to this message

From: Bald Eagle
Subject: Re: Uberpov persistent feature for animation of big scene
Date: 7 Jan 2018 16:10:01
Message: <web.5a528b9f6e53ffa45cafe28e0@news.povray.org>
"Kenneth" <kdw### [at] gmailcom> wrote:

> I never realized that a macro's result-- object(FOO)-- was a global variable
> that remained 'alive' in a scene once the macro was invoked.

It has to be, since macros "spit thing out" to be used outside of the macro.

> I always thought the *entire* contents of a macro died after each use (as if
> object(FOO) was always a #local thing as well.) So in effect, the result is
> 'cached' for use later. Very interesting!

I think it depends on if you use #declare or #local.

We cover this from time to time:
http://news.povray.org/povray.newusers/message/%3Cweb.5751decd76b80bcda4b712a50%40news.povray.org%3E/#%3Cweb.5751decd76
b80bcda4b712a50%40news.povray.org%3E

I'd say probably the best way to think of a macro when dealing with variables
like this, is that it's essentially just like an include file - it's just an
encapsulated piece of code.
Calling it just re-runs the code, and if it has arguments, it just uses those
new arguments.
I think the argument names and values are the only thing that are temporary,
local, and get destroyed upon exiting.


Post a reply to this message

From: clipka
Subject: Re: Uberpov persistent feature for animation of big scene
Date: 7 Jan 2018 18:57:17
Message: <5a52b3dd$1@news.povray.org>
Am 07.01.2018 um 21:09 schrieb Kenneth:
> clipka <ano### [at] anonymousorg> wrote:
>>
>> Take a look at the following macro, and compare it to your code:
>>
>>     #macro MyMacro()
>>       #ifndef(FOO)
>>       #declare FOO =
>>         union {
>>           #local TEX_1 = texture{...}
>>           #local MY_BOX = box{0,1}
>>           object{MY_BOX texture{TEX_1}
>>           ...
>>         }
>>       #end
>>       object{FOO}
>>     #end
>>
>> Note how this assembles a union from local variables (which "die" each
>> time the end of the macro is reached), and assigns the resulting object
>> to a global variable, which will still be "alive" if the macro is
>> invoked again later.
>>
> 
> I never realized that a macro's result-- object(FOO)-- was a global variable
> that remained 'alive' in a scene once the macro was invoked. Is that
> specifically because #ifndef is used here? (Actually, I'm guessing that it has
> nothing to do with #ifndef.)

Nonono...

The first time the macro is invoked, `FOO` isn't defined yet, so the
`#ifndef(FOO)` block is entered, which contains a `#declare FOO`
statement. That statement defines a global variable named `FOO` that
sticks around even after the macro is long gone.

The `object{FOO}` is just an example statement to do _something_ with
that variable.

The second time the macro is invoked, `FOO` is already defined (because
it still sticks around from the last macro invocation), and the
`#ifndef(FOO)` block is skipped.

The `object{FOO}` again is just an example statement to do _something_
with that variable. Note that this time around it isn't using an object
created during the macro invocation itself, but rather re-uses the
object created during the first macro invocation.


The variable `FOO` persists across macro invocations regardless of
whether the `object{FOO}` statement is present or not. But without that
statement the variable would never actually be used for anything.


Post a reply to this message

From: Kenneth
Subject: Re: Uberpov persistent feature for animation of big scene
Date: 7 Jan 2018 21:50:01
Message: <web.5a52db5e6e53ffa4a47873e10@news.povray.org>
clipka <ano### [at] anonymousorg> wrote:

>
> Nonono...
>
> The first time the macro is invoked, `FOO` isn't defined yet, so the
> `#ifndef(FOO)` block is entered, which contains a `#declare FOO`
> statement. That statement defines a global variable named `FOO` that
> sticks around even after the macro is long gone.
>
Oops, I didn't 'see' that FOO was #declared (rather than #local-ed.) Understood.
Sorry for that confusion.


Post a reply to this message

Goto Latest 10 Messages Next 4 Messages >>>

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