POV-Ray : Newsgroups : povray.newusers : trouble using random numbers : Re: trouble using random numbers Server Time
4 Sep 2024 18:18:03 EDT (-0400)
  Re: trouble using random numbers  
From: Warp
Date: 4 Oct 2002 07:34:03
Message: <3d9d7cab@news.povray.org>
Besides the fact that rand() always returns the same number sequence for
a given seed, you are using rand() in the wrong way.
  This is how rand() should be used:

#declare Conifer_Cluster =
  union
  {
    #declare Conifer_Seed = seed(0); // or whatever number you like
    #declare numNeedles = 5 + rand(Conifer_Seed)*5;
    #declare iter = 0;
    #while(iter < numNeedles)
      object
      { Conifer_Needle rotate<rand(Conifer_Seed)*80,0,rand(Conifer_Seed)*80> }
      #declare iter = iter+1;
    #end
    rotate <-40,0,-40>
    rotate <90,0,0>
  }


  Since there's no variable in POV-Ray which changes from render to render,
there's no way of getting a different seed from render to render.
  However, in an animation it's possible, as there are variables which
change. The most useful is 'frame_number'.
  Thus, in an animation you could change the Conifer_Seed declaration above
to look like this:

    #declare Conifer_Seed = seed(frame_number);

  This way you get a different distribution for each frame of the animation.

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

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