POV-Ray : Newsgroups : povray.advanced-users : Randomizing pattern functions : Re: Randomizing pattern functions Server Time
28 Jul 2024 20:20:26 EDT (-0400)
  Re: Randomizing pattern functions  
From: Mike Williams
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

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