POV-Ray : Newsgroups : povray.general : Duplicate ? Server Time
18 Nov 2024 01:22:30 EST (-0500)
  Duplicate ? (Message 1 to 10 of 26)  
Goto Latest 10 Messages Next 10 Messages >>>
From: Rafal 'Raf256' Maj
Subject: Duplicate ?
Date: 24 Nov 2002 12:02:23
Message: <Xns92D0B6F081DF6raf256com@204.213.191.226>
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.

AFAIK if GrassBlock would be a mesh (not union of 100 meshes) then it wolud 
not be duplicated right ?

So I suggest 2 future reguests to achive this :
1. allow syntax 
mesh {
  mesh { ... rotate ... translate ... } // leaf 1
  mesh { ... rotate ... translate ... } // leaf 2
  [...]
  rotate ... translate ...
} // grass block

2. add new syntax :
  duplicate { ... } 
that will work in same way as 
  object {... }
but will re-use memory


-- 
#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: Marc-Hendrik Bremer
Subject: Re: Duplicate ?
Date: 24 Nov 2002 12:30:53
Message: <3de10ccd@news.povray.org>
"Rafal 'Raf256' Maj" <raf### [at] raf256com> schrieb im Newsbeitrag
news:Xns### [at] 204213191226...
> So I suggest 2 future reguests to achive this :
> 1. allow syntax
> mesh {
>   mesh { ... rotate ... translate ... } // leaf 1
>   mesh { ... rotate ... translate ... } // leaf 2
>   [...]
>   rotate ... translate ...
> } // grass block

Why don't you just use a macro for this? Okay, you will end up, with one
mesh with some thousands of triangles, but that should be no problem, as
most meshes are much larger.

Regards,

Marc-Hendrik


Post a reply to this message

From: Thorsten Froehlich
Subject: Re: Duplicate ?
Date: 24 Nov 2002 12:44:19
Message: <3de10ff3@news.povray.org>
In article <Xns### [at] 204213191226>, "Rafal 'Raf256' Maj"
<raf### [at] raf256com> wrote:

> 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.

If this is happening to you, you are not using the mesh object properly.

Follow Marc's suggestion and maybe you also should try to just explain your
problem and wait for an answer, not immediately turn it into a redundant
feature request...

    Thorsten

____________________________________________________
Thorsten Froehlich, Duisburg, Germany
e-mail: tho### [at] trfde

Visit POV-Ray on the web: http://mac.povray.org


Post a reply to this message

From: Christopher James Huff
Subject: Re: Duplicate ?
Date: 24 Nov 2002 12:48:10
Message: <chrishuff-C869B0.12464124112002@netplex.aussie.org>
In article <Xns### [at] 204213191226>,
 "Rafal 'Raf256' Maj" <raf### [at] raf256com> wrote:

> So I suggest 2 future reguests to achive this :
> 1. allow syntax 
> mesh {
>   mesh { ... rotate ... translate ... } // leaf 1
>   mesh { ... rotate ... translate ... } // leaf 2
>   [...]
>   rotate ... translate ...
> } // grass block

This type of thing has been discussed many times before. It would be a 
fairly major piece of work to do it completely, but it has a chance of 
being done as a 3.5 patch. Something similar for blobs would be nice too.


> 2. add new syntax :
>   duplicate { ... } 
> that will work in same way as 
>   object {... }
> but will re-use memory

There is no need for a new syntax, copy by reference can be done with 
the existing syntax. However, it would take a lot of work, don't expect 
it before the 4.0 rewrite.

The best solution to your problem would be to just put multiple grass 
blades in a single mesh tile. This is the most efficient way to do mesh 
grass.

-- 
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: Rafal 'Raf256' Maj
Subject: Re: (exacly) - Duplicate ?
Date: 24 Nov 2002 13:04:54
Message: <Xns92D0C18A32116raf256com@204.213.191.226>
"Marc-Hendrik Bremer" <Mar### [at] t-onlinede> wrote in 
news:3de10ccd@news.povray.org

> 
> "Rafal 'Raf256' Maj" <raf### [at] raf256com> schrieb im Newsbeitrag
> news:Xns### [at] 204213191226...
>> So I suggest 2 future reguests to achive this :
>> 1. allow syntax
>> mesh {
>>   mesh { ... rotate ... translate ... } // leaf 1
>>   mesh { ... rotate ... translate ... } // leaf 2
>>   [...]
>>   rotate ... translate ...
>> } // grass block
> Why don't you just use a macro for this? Okay, you will end up, with one
> mesh with some thousands of triangles, but that should be no problem, as
> most meshes are much larger.

I do use macro :)

Exacly :

Macro PutGrass - generates single grass leaf (about 200-500 triangles).
It works as :
mesh {
  // loop {
    triangle { ... }
  // }
  translate ... rotate ... // ((-1-))
}


Macro PutGrassArea calls PutGrass in loop

Later, we have
#declare GrassBlock = union { // ((-2-))
  PutGrassArea(0,0,10,10)
}

The problem is, that I cann't change union to mesh in line ((-2-)) due to 
transforms in ((-1-))

In free time I will try to work-around, by either :
1. removing ((-1-)) and applying this transform to each wector of each 
triangle by hand (vrotate etc)
2. writting a C program that will generate grass for me (GrassBlock)

any other ideas ?

-- 
#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 13:06:00
Message: <Xns92D0C1BA42826raf256com@204.213.191.226>
"Thorsten Froehlich" <tho### [at] trfde> wrote in
news:3de10ff3@news.povray.org 

> If this is happening to you, you are not using the mesh object
> properly. 
> Follow Marc's suggestion and maybe you also should try to just explain
> your problem and wait for an answer, not immediately turn it into a
> redundant feature request...

Ok, I did it. I know that it would be better to have one mesh istead union 
of 100 meshes, but as I explain - it's a problem due to transforms in each 
"sub-mesh"




-- 
#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: Thorsten Froehlich
Subject: Re: Duplicate ?
Date: 24 Nov 2002 14:07:25
Message: <3de1236d$1@news.povray.org>
In article <Xns### [at] 204213191226>, "Rafal 'Raf256' Maj"
<raf### [at] raf256com> wrote:

>> If this is happening to you, you are not using the mesh object
>> properly.
>> Follow Marc's suggestion and maybe you also should try to just explain
>> your problem and wait for an answer, not immediately turn it into a
>> redundant feature request...
>
> Ok, I did it. I know that it would be better to have one mesh istead union
> of 100 meshes, but as I explain - it's a problem due to transforms in each
> "sub-mesh"

No, create one mesh, i.e. #declare mymesh = mesh { ... }.  Then transform it
using object { mymesh translate ... rotate ... }.  In consequence you have
exactly one mesh in memory and can then transform 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).

    Thorsten

____________________________________________________
Thorsten Froehlich, Duisburg, Germany
e-mail: tho### [at] trfde

Visit POV-Ray on the web: http://mac.povray.org


Post a reply to this message

From: Thorsten Froehlich
Subject: Re: Duplicate ?
Date: 24 Nov 2002 14:07:49
Message: <3de12385$1@news.povray.org>
In article <chr### [at] netplexaussieorg> , 
Christopher James Huff <chr### [at] maccom>  wrote:

>> 2. add new syntax :
>>   duplicate { ... }
>> that will work in same way as
>>   object {... }
>> but will re-use memory
>
> There is no need for a new syntax, copy by reference can be done with
> the existing syntax. However, it would take a lot of work, don't expect
> it before the 4.0 rewrite.
>
> The best solution to your problem would be to just put multiple grass
> blades in a single mesh tile. This is the most efficient way to do mesh
> grass.

You forgot that meshes are already reference copied.

    Thorsten

____________________________________________________
Thorsten Froehlich, Duisburg, Germany
e-mail: tho### [at] trfde

Visit POV-Ray on the web: http://mac.povray.org


Post a reply to this message

From: Thorsten Froehlich
Subject: Re: (exacly) - Duplicate ?
Date: 24 Nov 2002 14:09:41
Message: <3de123f5$1@news.povray.org>
In article <Xns### [at] 204213191226>, "Rafal 'Raf256' Maj"
<raf### [at] raf256com> wrote:

> Macro PutGrass - generates single grass leaf (about 200-500 triangles).
> It works as :
> mesh {
>   // loop {
>     triangle { ... }
>   // }
>   translate ... rotate ... // ((-1-))
> }
>
>
> Macro PutGrassArea calls PutGrass in loop
>
> Later, we have
> #declare GrassBlock = union { // ((-2-))
>   PutGrassArea(0,0,10,10)
> }

This in no way shows what you are doing.  Do you create multiple
"GrassBlock"s?  Or do you copy them?  Just some rough scatch of your scene
will not allow anybody to determine what you are doing wrong, nor really
help you without having to guess most of the important facts.

    Thorsten

____________________________________________________
Thorsten Froehlich, Duisburg, Germany
e-mail: tho### [at] trfde

Visit POV-Ray on the web: http://mac.povray.org


Post a reply to this message

From: Rafal 'Raf256' Maj
Subject: Re: Duplicate ?
Date: 24 Nov 2002 14:29:45
Message: <Xns92D0CFED285BAraf256com@204.213.191.226>
"Thorsten Froehlich" <tho### [at] trfde> wrote in 
news:3de12385$1@news.povray.org

> You forgot that meshes are already reference copied.

This future will be very usefull for other objects, i.e. I made trees 
basing mostly on cones. I'm planing to make a sity - there I would use 
mostly box'es (differences / intersecions / union's of them)

-- 
#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

Goto Latest 10 Messages Next 10 Messages >>>

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