Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTon Roosendaal <ton@blender.org>2005-08-25 17:11:04 +0400
committerTon Roosendaal <ton@blender.org>2005-08-25 17:11:04 +0400
commit8d940dfafe577ea92c279cc41e791b0012c78d2b (patch)
tree88d286b2bc9ad136e7f96661fcd802d2811a52f2 /source/blender/blenlib/BLI_rand.h
parentc9f01eefcd3c21da95c7245a6b1f54ceae4024b1 (diff)
Random() issues with rendering...
- AO and soft shadow AreaLight tables were generated without fixed seed, causing animations to give unwanted amounts of noise. - Made sure these tables now are calculated before render, with fixed seed - Then found out the BLI_rand() has very bad seeding... it showed up as patterns. After some experimenting, found a nice method using noise.c hash tables. For compatibility with old code, named it BLI_srandom() to use this next to the BLI_srand(). This follows libc rand() and random() naming convention. - Then of course threading should work... so made a BLI_thread_rand version of the calls. Now supports up to 16 threads, comments added in .h and .c Result is stable animation render with AO and soft shadow. But, please test and feedback!
Diffstat (limited to 'source/blender/blenlib/BLI_rand.h')
-rw-r--r--source/blender/blenlib/BLI_rand.h18
1 files changed, 18 insertions, 0 deletions
diff --git a/source/blender/blenlib/BLI_rand.h b/source/blender/blenlib/BLI_rand.h
index e6b0146cfab..da2ecb79651 100644
--- a/source/blender/blenlib/BLI_rand.h
+++ b/source/blender/blenlib/BLI_rand.h
@@ -55,6 +55,9 @@ void rng_shuffleArray(struct RNG *rng, void *data, int elemSize, int numElems);
/** Seed the random number generator */
void BLI_srand (unsigned int seed);
+ /** Better seed for the random number generator, using noise.c hash[] */
+void BLI_srandom (unsigned int seed);
+
/** Return a pseudo-random number N where 0<=N<(2^31) */
int BLI_rand (void);
@@ -77,5 +80,20 @@ void BLI_fillrand (void *addr, int len);
*/
void BLI_array_randomize (void *data, int elemSize, int numElems, unsigned int seed);
+
+ /** Better seed for the random number generator, using noise.c hash[] */
+ /** Allows up to 16 threads to address */
+void BLI_thread_srandom (int thread, unsigned int seed);
+
+ /** Return a pseudo-random number N where 0<=N<(2^31) */
+ /** Allows up to 16 threads to address */
+int BLI_thread_rand (int thread);
+
+ /** Return a pseudo-random number N where 0.0f<=N<1.0f */
+ /** Allows up to 16 threads to address */
+float BLI_thread_frand (int thread);
+
+
+
#endif