POV-Ray : Newsgroups : povray.general : Duplicate ? Server Time
5 Aug 2024 08:21:35 EDT (-0400)
  Duplicate ? (Message 11 to 20 of 26)  
<<< Previous 10 Messages Goto Latest 10 Messages Next 6 Messages >>>
From: Rafal 'Raf256' Maj
Subject: Re: (exacly) - Duplicate ?
Date: 24 Nov 2002 14:35:13
Message: <Xns92D0D0DA175ADraf256com@204.213.191.226>
#macro PutGrassLeaf(grassPos, grassPrec, grassSeed)
[...]
#macro qua(aaa,bbb,ccc,ddd) 
  triangle { aaa, bbb, ccc }  
  triangle { aaa, ccc, ddd } 
#end
[...]
mesh {
  #local iii=0;  #while (iii<=cfgHeight)
  [...]
        qua(_a,_b,_bu,_au) qua(_b,_c,_cu,_bu) // front side
        qua(_c,_d,_du,_cu) qua(_d,_e,_eu,_du) // right side
  [...]
  #local iii=iii+1;  #end 
  scale [...] rotate [...] translate grassPos+<0,-2,0>
}
#end // end of PutGrassLeaf

#macro CoverWithGrass(fromX,fromZ,toX,toZ, prec, seed1)
  [...]
  #local r1=seed(seed1);
  #local ix=fromX;  #while (ix<=toX)
   #local iy=fromZ;  #while (iy<=toZ)
      PutGrassLeaf(  <ix,0,iy>*[...] )
      #declare StGrass= StGrass+1;
    #local iy=iy+1; #end
  #local ix=ix+1; #end
#end

#declare GrassBlocks = array[5]; // 5 types of grass block
#declare I=0; #while (I<5) // create 5 blocks, 10*10 leafs each
  #declare GrassBlocks[I] = 
  union {
    CoverWithGrass(0,0,10,10, 25, 12345)
    scale .025 [...]
  } 
#declare I=I+1; #end
                    

// FINAL MACRO - using grass blocks to cover a large area :
#macro CoverWithGrassBlocks(fromX,fromZ,toX,toZ)
  #local ix=fromX;  #while (ix<=toX)
    #local iz=fromZ;  #while (iz<=toZ)
      object {
        GrassBlocks[rand([...])*5] // select grass block #0..#4
        translate <ix,0,iz>
      }  
    #local iz=iz+GBSizeZ; #end
  #local ix=ix+GBSizeX; #end
#end

// FINAL OBJECT
union {  
  CoverWithGrassBlocks(-150,-150,+150,250)  
  texture { [...] } 
}  


-- 
#macro g(U,V)(.4*abs(sin(9*sqrt(pow(x-U,2)+pow(y-V,2))))*pow(1-min(1,(sqrt(
pow(x-U,2)+pow(y-V,2))*.3)),2)+.9)#end#macro p(c)#if(c>1)#local l=mod(c,100
);g(2*div(l,10)-8,2*mod(l,10)-8)*p(div(c,100))#else 1#end#end light_source{
y 2}sphere{z*20 9pigment{function{p(26252423)*p(36455644)*p(66656463)}}}//M


Post a reply to this message

From: Warp
Subject: Re: Duplicate ?
Date: 24 Nov 2002 14:48:55
Message: <3de12d27@news.povray.org>
As the other have already answered, you need to #declare the mesh as
an identifier and then create instances of this identifier. Like this:

#declare GrassPatch = mesh { ... }

object { GrassPatch translate ... }
object { GrassPatch translate ... }
object { GrassPatch translate ... }
...

  When you do it this way, the mesh data will be stored in memory only once,
independently of how many instances you make.

  I hope this clears all misunderstandings.

-- 
#macro N(D)#if(D>99)cylinder{M()#local D=div(D,104);M().5,2pigment{rgb M()}}
N(D)#end#end#macro M()<mod(D,13)-6mod(div(D,13)8)-3,10>#end blob{
N(11117333955)N(4254934330)N(3900569407)N(7382340)N(3358)N(970)}//  - Warp -


Post a reply to this message

From: Rafal 'Raf256' Maj
Subject: Re: Duplicate ?
Date: 24 Nov 2002 15:06:03
Message: <Xns92D0D6128DEDEraf256com@204.213.191.226>
Warp <war### [at] tagpovrayorg> wrote in news:3de12d27@news.povray.org

> #declare GrassPatch = mesh { ... }

> object { GrassPatch translate ... }
> object { GrassPatch translate ... }
> object { GrassPatch translate ... }

unfourtunetly I need 1000*1000 object { GrassPatch }
so I wanted to create BigGrassPatch that is a union of 10*10 GrassPatch'es 
and then duplicate it 100*100 times, but in current yntax it seems 
impossible without hand transforming each grass pice (as described in post 
(exacly)...)




-- 
#macro g(U,V)(.4*abs(sin(9*sqrt(pow(x-U,2)+pow(y-V,2))))*pow(1-min(1,(sqrt(
pow(x-U,2)+pow(y-V,2))*.3)),2)+.9)#end#macro p(c)#if(c>1)#local l=mod(c,100
);g(2*div(l,10)-8,2*mod(l,10)-8)*p(div(c,100))#else 1#end#end light_source{
y 2}sphere{z*20 9pigment{function{p(26252423)*p(36455644)*p(66656463)}}}//M


Post a reply to this message

From: Rafal 'Raf256' Maj
Subject: Re: Duplicate ?
Date: 24 Nov 2002 15:11:49
Message: <Xns92D0D70F74507raf256com@204.213.191.226>
"Thorsten Froehlich" <tho### [at] trfde> wrote in
news:3de1236d$1@news.povray.org 

> it as necessary.  The mesh data will not be copied.  Of course, the
> transform data needs to be stored for each copy of the mesh (unless
> you don't transform it, of course). 
> That way your one million pieces of grass (meshes) will take somewhere
> between 100 and 500 bytes per piece of grass (meshes).

yes, and 500*1000,000 = 500 MB is my current memory usage (with is not bad 
when realizing that scene uses about 500,000,000 * 200 triangles).

But to save more mory I wanted do organize this meshes into super-meshes - 
clusters of about 10*10 (or 50*50) sub-meshes, only problem stoping me for 
doing this is that I need to transfor each sub-mesh before placing in big-
mesh, and I can't 

mesh { // big 
  mesh { triangle[...] rotate [...] // small
  mesh { triangle[...] rotate [...] // small
  rotate [...]
}



-- 
#macro g(U,V)(.4*abs(sin(9*sqrt(pow(x-U,2)+pow(y-V,2))))*pow(1-min(1,(sqrt(
pow(x-U,2)+pow(y-V,2))*.3)),2)+.9)#end#macro p(c)#if(c>1)#local l=mod(c,100
);g(2*div(l,10)-8,2*mod(l,10)-8)*p(div(c,100))#else 1#end#end light_source{
y 2}sphere{z*20 9pigment{function{p(26252423)*p(36455644)*p(66656463)}}}//M


Post a reply to this message

From: Christopher James Huff
Subject: Re: Duplicate ?
Date: 24 Nov 2002 15:41:53
Message: <chrishuff-0EDD32.15402424112002@netplex.aussie.org>
In article <3de12385$1@news.povray.org>,
 "Thorsten Froehlich" <tho### [at] trfde> wrote:

> You forgot that meshes are already reference copied.

No I didn't...that's exactly why I suggested he make tiles of multiple 
blades each. Where did I say they weren't copied by reference? If that 
were so, I would have suggested a single giant mesh.

-- 
Christopher James Huff <cja### [at] earthlinknet>
http://home.earthlink.net/~cjameshuff/
POV-Ray TAG: chr### [at] tagpovrayorg
http://tag.povray.org/


Post a reply to this message

From: Warp
Subject: Re: Duplicate ?
Date: 25 Nov 2002 03:13:59
Message: <3de1dbc6@news.povray.org>
Rafal 'Raf256' Maj <raf### [at] raf256com> wrote:
> unfourtunetly I need 1000*1000 object { GrassPatch }
> so I wanted to create BigGrassPatch that is a union of 10*10 GrassPatch'es 
> and then duplicate it 100*100 times, but in current yntax it seems 
> impossible without hand transforming each grass pice (as described in post 
> (exacly)...)

  Have you ever heard of #while-loops? They are handy, you know...


#declare GrassPatch = mesh { ... }

#declare Xpos = 0;
#while(Xpos < 100)
  #declare Zpos = 0;
  #while(Zpos < 100)
    object { GrassPatch translate <Xpos, 0, Zpos> }
    #declare Zpos = Zpos+1;
  #end
  #declare Xpos = Xpos+1;
#end

  Magically you get 100*100 instances of the mesh.

-- 
#macro N(D)#if(D>99)cylinder{M()#local D=div(D,104);M().5,2pigment{rgb M()}}
N(D)#end#end#macro M()<mod(D,13)-6mod(div(D,13)8)-3,10>#end blob{
N(11117333955)N(4254934330)N(3900569407)N(7382340)N(3358)N(970)}//  - Warp -


Post a reply to this message

From: ABX
Subject: Re: Duplicate ?
Date: 25 Nov 2002 03:35:36
Message: <cun3uukglfb2mnsf7trmtlnsm9amtpissu@4ax.com>
On 24 Nov 2002 12:02:23 -0500, "Rafal 'Raf256' Maj" <raf### [at] raf256com> wrote:
> 2. add new syntax :
>   duplicate { ... } 
> that will work in same way as 
>   object {... }
> but will re-use memory

That's near top on my TODO and perheps will be realised this year.
Check http://news.povray.org/povray.binaries.images/14001/

ABX


Post a reply to this message

From: Rafal 'Raf256' Maj
Subject: Re: Duplicate ?
Date: 25 Nov 2002 09:25:25
Message: <Xns92D19C56FF14Braf256com@204.213.191.226>
Warp <war### [at] tagpovrayorg> wrote in news:3de1dbc6@news.povray.org

>   Have you ever heard of #while-loops? They are handy, you know...
> #while(Xpos < 100)
>   #while(Zpos < 100)
>     object { GrassPatch translate <Xpos, 0, Zpos> }
>   Magically you get 100*100 instances 

...and copy of mesh[1] for each loop-pass (100*100 copies in RAM).

Your sarcasm was quite stupid, if You would read first post(s) carfule You 
will notice that techinque described above is exacly what i'm doing now, 
but that I'm searching for more memory-saving idea.

[1] mesh data = bounding box etc. Ofcourse list of triangles wectors is not 
replicated, but still even bounding boxes.

-- 
#macro g(U,V)(.4*abs(sin(9*sqrt(pow(x-U,2)+pow(y-V,2))))*pow(1-min(1,(sqrt(
pow(x-U,2)+pow(y-V,2))*.3)),2)+.9)#end#macro p(c)#if(c>1)#local l=mod(c,100
);g(2*div(l,10)-8,2*mod(l,10)-8)*p(div(c,100))#else 1#end#end light_source{
y 2}sphere{z*20 9pigment{function{p(26252423)*p(36455644)*p(66656463)}}}//M


Post a reply to this message

From: Warp
Subject: Re: Duplicate ?
Date: 25 Nov 2002 10:01:55
Message: <3de23b63@news.povray.org>
Rafal 'Raf256' Maj <raf### [at] raf256com> wrote:
> ...and copy of mesh[1] for each loop-pass (100*100 copies in RAM).

  10000 copies does not sound like extremely memory-intensive.
  How much memory does one copy need? Even if it required, let's say,
1 kilobyte, that would only require about 10 megabytes, far less than
the 500 megabytes you were talking about. And the copies probably need
far less than 1 kilobyte.

  If you want less memory consumption, then make the mesh patch larger
and make less copies. If you, for example, make the mesh patch twice as
large in both axes and then make 50*50 copies, that's only 2500 copies
instead of 10000. The memory requirement for the copies dropped by 3/4.

-- 
#macro N(D)#if(D>99)cylinder{M()#local D=div(D,104);M().5,2pigment{rgb M()}}
N(D)#end#end#macro M()<mod(D,13)-6mod(div(D,13)8)-3,10>#end blob{
N(11117333955)N(4254934330)N(3900569407)N(7382340)N(3358)N(970)}//  - Warp -


Post a reply to this message

From: Jaime Vives Piqueres
Subject: Re: Duplicate ?
Date: 25 Nov 2002 10:14:46
Message: <20021125161445.2dba7058.jaimevives@ignorancia.org>
On 24 Nov 2002 12:02:23 -0500
"Rafal 'Raf256' Maj" <raf### [at] raf256com> wrote:

> 
> I have following problem - I want to cover large area (about 1000x1000
> 
> units) by grass, each grass "leaf" tooks about 1 unit space on ground,
> so I wolud need about 1 mln leafs. 
> Each leaf is build from about 500 triangles, with gives 500,000,000 
> triangles - way to much to hold in memory.
> 
> So I thinked of optimisation :
> 1. every grass leaf is a mesh
> 2. organise 10x10 leafs into an union like GrassBlock
> 3. cover area (flat land) with same GrassBlock object
> 
> problem is with step #3 - each :
>   object { GrassBlock translate <X,0,Z> }
> results in duplicating GrassBlock in memory - so no memroy is saved as
> I aspected.

  I had a similar problem with this scene:

    http://www.ignorancia.org/images/marjal.jpg 

  and the less consuming solution was to actually move the
transformations from the grass patchs to the individual triangles, so
you can get a whole mesh for every grass patch, and then you can make a
union of these (with few but bigger meshes). Not that good as the
posibility of nesting meshes, but feasible, and the only solution that
worked for my 512MB.


-- 
Jaime Vives Piqueres
		
La Persistencia de la Ignorancia
http://www.ignorancia.org


Post a reply to this message

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

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