POV-Ray : Newsgroups : povray.general : recursively defined objects and memory Server Time
29 Jul 2024 10:22:40 EDT (-0400)
  recursively defined objects and memory (Message 14 to 23 of 43)  
<<< Previous 10 Messages Goto Latest 10 Messages Next 10 Messages >>>
From: Fractracer
Subject: Re: recursively defined objects and memory
Date: 14 Aug 2013 14:00:00
Message: <web.520bc499e896405bda87b1b90@news.povray.org>
"Thorsten Froehlich" <nomail@nomail> wrote:
> "Anthony D. Baye" <Sha### [at] spamnomorehotmailcom> wrote:
> > scott <sco### [at] scottcom> wrote:
> > > > now, from what I've read, it takes more than a thousand iterations to get good
> > > > results, but trying to do just fifty iterations makes POV do an imitation of
> > > > PAC-Man with my memory and swap space.  All 16GB of it.
> > > >
> > > > I don't know if this is a bug or a natural limitation of the geometry parsing
> > > > engine.
> > >
> > > It looks to me like at each iteration you are doubling the number of
> > > objects POV has in memory (by creating an intersection of two versions
> > > of the previous object). That means after 50 iterations you will have
> > > about 2^50 objects - I'm surprised you got that far!
> >
> > That's about what I figured was happening.  And I didn't get that far because
> > I had to shut it down.
>
> And no matter what you do, you won't be able to get that many with POV on any
> system available on this planet today. Even with references, and no
> transformations, it would take 8 petabytes (8192 terabytes) just to store the
> references. Realistically you might get 2^30 spheres on a PC, but not with a
> regular Windows (you need the a server variant, desktop variants only support 64
> GB of RAM) as you will probably need 256 to 512 GB of RAM for it. Or you need a
> lot of fast swap space.
>
> Thorsten

If I am not wrong, Windows7-32 bits can only have 4GB of memory, while Win7-64
bits can have 192 GB with pro edition.


Post a reply to this message

From: Thorsten Froehlich
Subject: Re: recursively defined objects and memory
Date: 14 Aug 2013 15:00:00
Message: <web.520bd282e896405b45eb5620@news.povray.org>
"Fractracer" <lg.### [at] gmailcom> wrote:
> > And no matter what you do, you won't be able to get that many with POV on any
> > system available on this planet today. Even with references, and no
> > transformations, it would take 8 petabytes (8192 terabytes) just to store the
> > references. Realistically you might get 2^30 spheres on a PC, but not with a
> > regular Windows (you need the a server variant, desktop variants only support 64
> > GB of RAM) as you will probably need 256 to 512 GB of RAM for it. Or you need a
> > lot of fast swap space.
> >
> > Thorsten
>
> If I am not wrong, Windows7-32 bits can only have 4GB of memory, while Win7-64
> bits can have 192 GB with pro edition.

You are right about Win 64, I confused it ith the PAE limit:, for Windows 32 bit
systems the limit is 64 GB if using PAE.

As for the 192 GB, iirc there is a default 128 GB per process limit on available
memory (meaning swap wont help). The server version upper limit is 4 TB of
physical memory, btw.

Thorsten


Post a reply to this message

From: clipka
Subject: Re: recursively defined objects and memory
Date: 14 Aug 2013 15:04:14
Message: <520bd4ae$1@news.povray.org>
Am 14.08.2013 16:55, schrieb Bald Eagle:
>
>> - Macros are /always/ evaluated during parsing.
>
> I guess I didn't say or mean to imply that they weren't.
>
>> - Functions may be evaluated either during parsing or during rendering,
>> depending on the context in which they are used.
>
> And those contexts are?
> Function outside of a macro only at parse time, function inside a macro during
> parse and render?

Macros have /nothing/ to do with the time at which a function is evaluated.

I'm not sure off the top of my head whether there are exceptions, but 
the general rules are as follows:

- Actually, it is not about the time at which a /function/ is evaluated, 
but the time at which an /expression/ is evaluated.

- In any expression, variables (defined with #declare or #local) and 
macro invocations are /always/ resolved during parsing of that 
expression, no matter when the expression as a whole is evaluated.

- Expressions outside of a function{} block are /always/ evaluated as 
soon as they are parsed.

- Expressions inside the function{} block of a function definition are 
evaluated as soon as any expression is evaluated that invokes this function.

- Expressions inside any other function{} block (e.g. in an isosurface 
object, a function pigment, or some such) are evaluated during rendering.


Post a reply to this message

From: Alain
Subject: Re: recursively defined objects and memory
Date: 16 Aug 2013 19:49:21
Message: <520eba81$1@news.povray.org>

> "Anthony D. Baye"  wrote in message
> news:web.5209e02df7af87b1328783aa0@news.povray.org...
>
>> Over the weekend, I was trying to implement a CSG method for
>> generating random
>> planets.
>
>> The basic algorithm is simple: Take a sphere, cut it in half along a
>> random
>> plane, scale each half independently by some small amount, iterate.
>
> That's the concept, not the algorithm. The algorithm is:
>
> * Start with a mesh sphere
> Select a random plane, scale vertices above and below the plane
> independently by some small amount, iterate.
>

Several years ago, I stumbled on something similar, but it never 
manipulated any 3D object. Instead, it created a ray scale image of the 
elevation. That image was a longitude-latitude GIF with a 2:1 aspect ratio.
Sadly, I lost that small application. It could be run from a floppy...


Post a reply to this message

From: Bald Eagle
Subject: Re: recursively defined objects and memory
Date: 16 Aug 2013 20:55:00
Message: <web.520ec950e896405b73fc9ebb0@news.povray.org>
> - Actually, it is not about the time at which a /function/ is evaluated,
> but the time at which an /expression/ is evaluated.
>
> - In any expression, variables (defined with #declare or #local) and
> macro invocations are /always/ resolved during parsing of that
> expression, no matter when the expression as a whole is evaluated.

I see.  Mostly.  I'll likely flowchart this out or write an illustrative POV
file to work it all out .. eventually.

I'll have to take a look at two of my SDL's and compare their #while - #else -
#end loops to get a better idea of when THEY get ... implemented.

Thanks for your clarifications.  I always learn a lot from your posts.
Your time on these newsgroups and your advice and assistance is always
appreciated.


Post a reply to this message

From: clipka
Subject: Re: recursively defined objects and memory
Date: 17 Aug 2013 05:48:08
Message: <520f46d8$1@news.povray.org>
Am 17.08.2013 02:52, schrieb Bald Eagle:

> Thanks for your clarifications.  I always learn a lot from your posts.
> Your time on these newsgroups and your advice and assistance is always
> appreciated.

Glad to hear that.


Post a reply to this message

From: Ger Remmers
Subject: Re: recursively defined objects and memory
Date: 18 Aug 2013 17:08:14
Message: <521137be$1@news.povray.org>
On 08/13/2013 02:28 AM, Anthony D. Baye wrote:

> If anyone has suggestions, I'd welcome them.
>
> Regards,
> A.D.B.
>
>

Doing it the sphere-cut-in-half-rinse-repeat method is obviously not 
going to work as has been discussed.

I have implemented another way to produce a similar result.

Define evenly distributed points on the sphere (you'll need quite a few 
points (I have one running now with 5M points(*)))

Create a random plane to cut the sphere in half, every point inside the 
plane gets lowered, all other points get raised.

Repeat the plane thingy until you get something you like.

(*) Povray seems to have a problem with very large arrays. I  can go as 
high as 800K nodes, after that the last position in the array seems to 
get corrupted.
So, for the > 800K version I have created an external program.

I'll post an example image in pbi

-- 
Cheers
Ger


Post a reply to this message

From: clipka
Subject: Re: recursively defined objects and memory
Date: 18 Aug 2013 17:48:24
Message: <52114128@news.povray.org>
Am 18.08.2013 23:08, schrieb Ger Remmers:

> (*) Povray seems to have a problem with very large arrays. I  can go as
> high as 800K nodes, after that the last position in the array seems to
> get corrupted.

Obviously that shouldn't happen. Can you provide a sample scene to 
reproduce, dissect and debug the problem?


Post a reply to this message

From: Ger Remmers
Subject: Re: recursively defined objects and memory
Date: 18 Aug 2013 18:01:22
Message: <52114432$1@news.povray.org>
On 08/18/2013 04:48 PM, clipka wrote:
> Am 18.08.2013 23:08, schrieb Ger Remmers:
>
>> (*) Povray seems to have a problem with very large arrays. I  can go as
>> high as 800K nodes, after that the last position in the array seems to
>> get corrupted.
>
> Obviously that shouldn't happen. Can you provide a sample scene to
> reproduce, dissect and debug the problem?
>

It messes up in the WriteDataFile() macro

#declare DataFilename = "nodes.inc";

#macro WriteDataFile()

   #fopen DataFile DataFilename write
   #write( DataFile, "#declare NumberOfNodes = 
",str(NumberOfNodes,0,0),";\n")
   #write( DataFile, "#declare Nodes =array [NumberOfNodes]\n")
   #write( DataFile, "{\n")
   #for (NodeCount, 0, NumberOfNodes -2, 1)
       #write ( DataFile, "<",vstr(3, Nodes[NodeCount],",",0,-1),">,\n")
   #end

/*
When including the written data it turns out that the next line is not 
executed
*/
   #write ( DataFile, "<",vstr(3, Nodes[NumberOfNodes-1],",",0,-1),">\n")
   #write (DataFile,"}\n")
   #fclose DataFile

   #debug concat("Done writing data file with ",str(NumberOfNodes,0,0)," 
nodes for frame ",str(frame_number,0,0),"\n")
#end


/*
   Only at the first frame do we need to initialize the nodes on the sphere,
   after that we load the node data from disk.
*/

#if (frame_number = 1)
   #declare NumberOfNodes = 5000000;

/*
With NumberOfNodes < ~800K it works fine
*/
   #declare Nodes =array [NumberOfNodes];
   #declare dlong = pi * (3-sqrt(5));
   #declare dz = 2.0 / NumberOfNodes;
   #declare Longitude = 0;
   #declare Z = 1 - dz / 2;

   #for (NodeCount, 0, NumberOfNodes - 1, 1)
     #declare Radius = sqrt(1 - Z * Z);
     #declare Nodes[NodeCount] = <cos(Longitude)* Radius, sin(Longitude) 
* Radius, Z>;
     #declare Z = Z - dz;
     #declare Longitude = Longitude + dlong;
   #end

   #else
     #include DataFilename
#end

#declare NumberOfItterations = 5;
#declare RandAngle = seed(66);
#if (frame_number > 1)
   #for(Dummy,0, (frame_number - 1) * NumberOfItterations * 4,1)
     #declare PlaneAngle = rand(RandAngle);
   #end
#end
#declare PlaneAngle = rand(RandAngle);
#declare CuttingPlane = plane{y, 0};
//#declare Cutter = box {<-10, 0.0, -10>,<10, -10, 10>};

#macro AdjustNodes(AngleX, AngleY, AngleZ, Displacement)
   #declare Cut = object { CuttingPlane translate y * Displacement 
rotate <AngleX, AngleY, AngleZ> };
   #for (NodeCount, 0, NumberOfNodes - 1, 1)
     #if (inside (Cut, Nodes[NodeCount]))
       #declare Nodes[NodeCount] = Nodes[NodeCount] / 1.001;
     #else
       #declare Nodes[NodeCount] = Nodes[NodeCount] * 1.001;
     #end
   #end
#end

   #for (ItterationCount, 0, NumberOfItterations - 1, 1)
   #declare PlaneAngleX = rand(RandAngle) * 360;
   #declare PlaneAngleY = rand(RandAngle) * 360;
   #declare PlaneAngleZ = rand(RandAngle) * 360;
   #declare Displacement = 0.5 - rand(RandAngle);
//  #local Cut = object { CuttingPlane rotate PlaneAngle };
   AdjustNodes(PlaneAngleX, PlaneAngleY, PlaneAngleZ, Displacement)
//    #debug concat(str(PlaneAngle,0,0),"\n")
#end
WriteDataFile()

-- 
Cheers
Ger


Post a reply to this message

From: Ger Remmers
Subject: Re: recursively defined objects and memory (for Clipka full source)
Date: 18 Aug 2013 18:13:45
Message: <52114719$1@news.povray.org>
/*

Original code from somewhere on the internet.
How to evenly distribute points on a sphere.

dlong := pi*(3-sqrt(5))   ~2.39996323
dz    := 2.0/N
long := 0
z    := 1 - dz/2
for k := 0 .. N-1
     r    := sqrt(1-z*z)
     node[k] := (cos(long)*r, sin(long)*r, z)
     z    := z - dz
     long := long + dlong
*/

#version 3.7;


/*
   Original code transcribed to SDL
   Create an array with NumberOfNodes points
   evenly distributed on the sphere
*/

#declare DataFilename = "nodes.inc";

#macro WriteDataFile()

   #fopen DataFile DataFilename write
   #write( DataFile, "#declare NumberOfNodes = 
",str(NumberOfNodes,0,0),";\n")
   #write( DataFile, "#declare Nodes =array [NumberOfNodes]\n")
   #write( DataFile, "{\n")
   #for (NodeCount, 0, NumberOfNodes -2, 1)
       #write ( DataFile, "<",vstr(3, Nodes[NodeCount],",",0,-1),">,\n")
   #end
   #write ( DataFile, "<",vstr(3, Nodes[NumberOfNodes-2],",",0,-1),">\n")
   #write (DataFile,"}\n")
   #fclose DataFile

   #debug concat("Done writing data file with ",str(NumberOfNodes,0,0)," 
nodes for frame ",str(frame_number,0,0),"\n")
#end


/*
   Only at the first frame do we need to initialize the nodes on the sphere,
   after that we load the node data from disk.
*/

#if (frame_number = 1)
   #declare NumberOfNodes = 5000000;
   #declare Nodes =array [NumberOfNodes];
   #declare dlong = pi * (3-sqrt(5));
   #declare dz = 2.0 / NumberOfNodes;
   #declare Longitude = 0;
   #declare Z = 1 - dz / 2;

   #for (NodeCount, 0, NumberOfNodes - 1, 1)
     #declare Radius = sqrt(1 - Z * Z);
     #declare Nodes[NodeCount] = <cos(Longitude)* Radius, sin(Longitude) 
* Radius, Z>;
     #declare Z = Z - dz;
     #declare Longitude = Longitude + dlong;
   #end

   #else
     #include DataFilename
#end
/*
   Now for the mountainous transformations

   We use a plane (Plane) to cut the sphere into 2 halves,
   every node "inside" the plane will be lowered, every node "outside"
   will be raised.
*/

#declare NumberOfItterations = 5;
#declare RandAngle = seed(66);
#if (frame_number > 1)
   #for(Dummy,0, (frame_number - 1) * NumberOfItterations * 4,1)
     #declare PlaneAngle = rand(RandAngle);
   #end
#end
#declare PlaneAngle = rand(RandAngle);
#declare CuttingPlane = plane{y, 0};


#macro AdjustNodes(AngleX, AngleY, AngleZ, Displacement)

   #declare Cut = object { CuttingPlane translate y * Displacement 
rotate <AngleX, AngleY, AngleZ> };

   #for (NodeCount, 0, NumberOfNodes - 1, 1)
     #if (inside (Cut, Nodes[NodeCount]))
       #declare Nodes[NodeCount] = Nodes[NodeCount] / 1.001;
     #else
       #declare Nodes[NodeCount] = Nodes[NodeCount] * 1.001;
     #end
   #end
#end

   #for (ItterationCount, 0, NumberOfItterations - 1, 1)
   #declare PlaneAngleX = rand(RandAngle) * 360;
   #declare PlaneAngleY = rand(RandAngle) * 360;
   #declare PlaneAngleZ = rand(RandAngle) * 360;
   #declare Displacement = 0.5 - rand(RandAngle);

   AdjustNodes(PlaneAngleX, PlaneAngleY, PlaneAngleZ, Displacement)

#end
WriteDataFile()

/*
   And now to make the whole thing visible
*/

#declare Diameter = 2/sqrt(NumberOfNodes);
#declare MutilatedEarth = union {
#for (NodeCount, 0, NumberOfNodes - 1, 1)
   sphere{Nodes[NodeCount], Diameter}
#end
    pigment{
      onion color_map{
      [0.0  0.6 color <0, 1, 1> color <1, 0, 0>]
      [0.6 0.8 color <1, 0, 0> color <0, 1, 0>]
      [0.80 0.85 color <0, 1, 0> color <0, 0, 0.5>]
      [0.85 0.9 color <0, 0, 0.5> color <0, 0, 1>]
      [0.95 1.0 color <0, 0, 1> color <0, 0, 0>]}
      scale 1
    }
}



#declare LightStrenght = 1;

light_source {< -400, 1000, -500>*10000, color <1.0, 1.0, 1.0> * 
LightStrenght
//	      area_light 10000, 10000, 51, 51 adaptive 0
	      }

light_source {< -400, 1000, 500>*1000, color 0.06125/2 * LightStrenght 
rotate y * 120 shadowless}
light_source {< -400, 1000, 500>*1000, color 0.06125/2 * LightStrenght 
rotate y * -120 shadowless}
light_source {< 0, -100000, 0>, color 0.06125/2 * LightStrenght shadowless}


#declare Blue_Sky3 =
pigment {
     granite
     turbulence 0.4
     color_map {
         [0.6 rgb <0, 0, 0.2> * LightStrenght]
         [1.0 rgb 0.5 * LightStrenght]
     }
}

sky_sphere {pigment {Blue_Sky3 scale < 3, 1, 3>*10}}


global_settings {
     ambient_light 0.0
     adc_bailout 0.09
     max_trace_level 200
     noise_generator 3
     assumed_gamma 1.0
     }

object { MutilatedEarth }


#declare CameraLocation =  <0,0,-3>;
#declare CameraLookat = <0, 0, 0>;


camera {
   location CameraLocation
   look_at CameraLookat
   direction z *   1.0
   right image_width / image_height * x
}


Post a reply to this message

<<< Previous 10 Messages Goto Latest 10 Messages Next 10 Messages >>>

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