POV-Ray : Newsgroups : povray.advanced-users : Randomizing pattern functions Server Time
25 Nov 2024 03:38:07 EST (-0500)
  Randomizing pattern functions (Message 1 to 6 of 6)  
From: Dan P
Subject: Randomizing pattern functions
Date: 5 Jan 2004 21:51:01
Message: <3ffa2295@news.povray.org>
I'm attempting to generate a macro that spits out an isosurface that
generates a boulder depending upon a seed. Then, I will take and write a
macro that spits them all out on a grid so that I can pick and choose from a
contact sheet.

I figured that translating a pattern would be like translating a pigment and
that randomly translating it's position would give me different forms.
However, I can't pass another parameter to a pattern function, so I'm not
sure how to get the translation inside of the pattern{} block.

Has anyone tried this kind of thing? Thanks!

-- >8 Code --

#declare f_rock1_1  =
function
{
 pattern
 {
  wrinkles
 }
}



#declare f_rock1_2  =
function
{
 pattern
 {
  bozo
 }
}



#macro rock1 (n)

 #declare R_ROCK1 = seed(n);

 isosurface
 {
  function { (f_sphere (x, y, z, 1) + f_rock1_1(x, y, z) + f_rock1_2(x, y,
z) ) / 3 }
  max_gradient 5
  evaluate 5, 1, 0.2

  #ifdef (DRAFT)
   accuracy 0.1
  #end

  #ifndef (DRAFT)

   pigment
   {
    granite

    color_map
    {
     [0 rgb <0.7, 0.7, 0.7> ]
     [1 White ]
    }

    translate <rand(R_ROCK1), rand(R_ROCK1)>
   }

  #else

   pigment { color White }

  #end
 }

#end

-- 
- Respectfully,
Dan

"When it is not in our power to follow what is true,
we ought to follow what is most probable."
                                         - Rene Descartes


Post a reply to this message

From: Mike Williams
Subject: Re: Randomizing pattern functions
Date: 6 Jan 2004 00:35:55
Message: <iDTbvBAKjk+$EwQ6@econym.demon.co.uk>
Wasn't it Dan P who wrote:
>I'm attempting to generate a macro that spits out an isosurface that
>generates a boulder depending upon a seed. Then, I will take and write a
>macro that spits them all out on a grid so that I can pick and choose from a
>contact sheet.
>
>I figured that translating a pattern would be like translating a pigment and
>that randomly translating it's position would give me different forms.
>However, I can't pass another parameter to a pattern function, so I'm not
>sure how to get the translation inside of the pattern{} block.
>
>Has anyone tried this kind of thing? Thanks!

I'd tend to do it by sticking the translation inside the isosurface {}
by variable substitution 
(see http://www.econym.demon.co.uk/isotut/substitute.htm)
like this:

#macro rock1 (n,m)

 #declare R_ROCK1 = seed(n);
 #declare R_ROCK2 = seed(m);
 #local R1=rand(R_ROCK2);            
 #local R2=rand(R_ROCK2);            
 #local R3=rand(R_ROCK2);            
             
 isosurface
 {
  function { (f_sphere (x, y, z, 1) 
            + f_rock1_1(x+R1, y+R2, z+R3) 
            + f_rock1_2(x+R1, y+R2, z+R3) )
             / 3 }
  ...


Note that you can't use rand() inside the isosurface function definition
itself.

-- 
Mike Williams
Gentleman of Leisure


Post a reply to this message

From: Dan P
Subject: Re: Randomizing pattern functions
Date: 6 Jan 2004 01:23:25
Message: <3ffa545d$1@news.povray.org>
"Mike Williams" <nos### [at] econymdemoncouk> wrote in message
news:iDTbvBAKjk+$EwQ### [at] econymdemoncouk...
> Wasn't it Dan P who wrote:
<snip>
> >I figured that translating a pattern would be like translating a pigment
and
> >that randomly translating it's position would give me different forms.
> >However, I can't pass another parameter to a pattern function, so I'm not
> >sure how to get the translation inside of the pattern{} block.
> >
> I'd tend to do it by sticking the translation inside the isosurface {}
> by variable substitution
> (see http://www.econym.demon.co.uk/isotut/substitute.htm)

Ah, brilliant! I hadn't thought of it from that angle. Thank you!!!


Post a reply to this message

From: David Wallace
Subject: Re: Randomizing pattern functions
Date: 11 Jan 2004 22:01:34
Message: <40020e0e@news.povray.org>
If you are going to generate a large number of rocks you might want to pass
an actual seed into the macro rather than just an integer.  That way you get
new rocks each time you call the macro.

"Mike Williams" <nos### [at] econymdemoncouk> wrote in message
news:iDTbvBAKjk+$EwQ### [at] econymdemoncouk...
> Wasn't it Dan P who wrote:
> >I'm attempting to generate a macro that spits out an isosurface that
> >generates a boulder depending upon a seed. Then, I will take and write a
> >macro that spits them all out on a grid so that I can pick and choose
from a
> >contact sheet.
> >
> >I figured that translating a pattern would be like translating a pigment
and
> >that randomly translating it's position would give me different forms.
> >However, I can't pass another parameter to a pattern function, so I'm not
> >sure how to get the translation inside of the pattern{} block.
> >
> >Has anyone tried this kind of thing? Thanks!
>
> I'd tend to do it by sticking the translation inside the isosurface {}
> by variable substitution
> (see http://www.econym.demon.co.uk/isotut/substitute.htm)
> like this:
>
---- edited code ----
#declare rs = seed(4394); // Use your own number

 #macro rock1 (sd, sz)

 #local R1=rand(sd)*sz;
 #local R2=rand(sd)*sz;
 #local R3=rand(sd)*sz;

  isosurface
  {
   function { (f_sphere (x, y, z, 1)
             + f_rock1_1(x+R1, y+R2, z+R3)
             + f_rock1_2(x+R1, y+R2, z+R3) )
              / 3 }
  ...
---- edited code ----
>
>
> Note that you can't use rand() inside the isosurface function definition
> itself.
>
> -- 

-- 
David Wallace
TenArbor Consulting
"Just in Time Cash"
http://www.tenarbor.com


Post a reply to this message

From: Mike Williams
Subject: Re: Randomizing pattern functions
Date: 12 Jan 2004 01:07:21
Message: <nEMqeCAOmjAAFwON@econym.demon.co.uk>
Wasn't it David Wallace who wrote:
>If you are going to generate a large number of rocks you might want to pass
>an actual seed into the macro rather than just an integer.  That way you get
>new rocks each time you call the macro.

But that very fact makes it less appropriate for Daniel's original
purpose. He wanted to LOOK at a a large number of rocks, and then choose
a few that happened to look nice to use in a real scene. So it's more
appropriate to have a macro that produces the same rock when passed the
same parameters.

-- 
Mike Williams
Gentleman of Leisure


Post a reply to this message

From: Dan P
Subject: Re: Randomizing pattern functions
Date: 12 Jan 2004 19:04:46
Message: <4003361e$1@news.povray.org>
"Mike Williams" <nos### [at] econymdemoncouk> wrote in message
news:nEM### [at] econymdemoncouk...
> Wasn't it David Wallace who wrote:
> >If you are going to generate a large number of rocks you might want to
pass
> >an actual seed into the macro rather than just an integer.  That way you
get
> >new rocks each time you call the macro.
>
> But that very fact makes it less appropriate for Daniel's original
> purpose. He wanted to LOOK at a a large number of rocks, and then choose
> a few that happened to look nice to use in a real scene. So it's more
> appropriate to have a macro that produces the same rock when passed the
> same parameters.

No matter what, though, Mike's way of translating it before it gets to the
function works. They're both good ideas depending upon the usage. For
example, David's idea would be great for automagically creating a rock bed.


Post a reply to this message

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