POV-Ray : Newsgroups : povray.general : seed/rand not so random? : Re: seed/rand not so random? Server Time
29 Jul 2024 22:33:49 EDT (-0400)
  Re: seed/rand not so random?  
From: Kenneth
Date: 12 May 2010 13:20:00
Message: <web.4beae08bb815a86eae92d9930@news.povray.org>
"stevenvh" <nomail@nomail> wrote:
> I'm shocked! :-)
>
> I'm using the animation function to generate a series of images of my scene,
> where the camera position is chosen at random, using the frame number as seed.
>....
> Time for a new seed function (seed2?) ?
>

Ah, welcome to the *interesting* world of POV's seed() and rand(). They do
indeed produce some patterns (which are especially visible in animation, as I
found out awhile ago.)

The need for a new random-number generator is well-known.  Take a look at
something I posted awhile ago; among the replies are some suggestions for
getting *around* the repeating-pattern behavior...

http://news.povray.org/povray.general/thread/%3Cweb.497a1e5215dcf5ebf50167bc0%40news.povray.org%3E/?mtop=21

For my own animations, here's *one* of the workarounds I've come up with
(simplified for explanation):
1) Choose only *one* seed value, at the beginning of the animation file.
2) Fill an array with LOTS of rand() values from that seed().
3) In the body of the scene, pick out these values from the arrays, for use. If
you need some 'new' rand values for each frame of animation (as for your camera
position, for example), use frame_number (in whatever way is practical) to
choose different array locations and thus different rands. (This is why the
array needs to be large, to hold as many values as might be needed.)

This scheme has its pros and cons: The array needs to be loaded with its rand
values for every frame of animation--so it's kind of a 'brute-force' method. But
the values don't change from frame to frame, because seed stays the same.
(That's a GOOD thing.) And in my own experience, using a single seed value helps
hide or eliminate repeating patterns--from a practical standpoint, anyway. I.e.,
it seems to produce far more 'random' results than choosing different SEEDS for
every animation frame.

Ken


Post a reply to this message

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