Fix T44598: blender internal not giving same result on repeated texture bakes.

This commit is contained in:
Brecht Van Lommel 2015-05-06 22:58:22 +02:00
parent fb0dd596e9
commit e73f1035d7

@ -34,6 +34,7 @@
#include "MEM_guardedalloc.h" #include "MEM_guardedalloc.h"
#include "BLI_math.h" #include "BLI_math.h"
#include "BLI_rand.h"
#include "BLI_threads.h" #include "BLI_threads.h"
#include "BLI_utildefines.h" #include "BLI_utildefines.h"
@ -75,6 +76,8 @@ extern struct Render R;
typedef struct BakeShade { typedef struct BakeShade {
int thread;
ShadeSample ssamp; ShadeSample ssamp;
ObjectInstanceRen *obi; ObjectInstanceRen *obi;
VlakRen *vlr; VlakRen *vlr;
@ -737,6 +740,9 @@ static void bake_single_vertex(BakeShade *bs, VertRen *vert, float u, float v)
MLoopCol *basevcol; MLoopCol *basevcol;
MLoop *mloop; MLoop *mloop;
/* per vertex fixed seed */
BLI_thread_srandom(bs->thread, vert->index);
origindex = RE_vertren_get_origindex(bs->obi->obr, vert, 0); origindex = RE_vertren_get_origindex(bs->obi->obr, vert, 0);
if (!origindex || *origindex == ORIGINDEX_NONE) if (!origindex || *origindex == ORIGINDEX_NONE)
return; return;
@ -812,6 +818,9 @@ static void shade_tface(BakeShade *bs)
float vec[4][2]; float vec[4][2];
int a, i1, i2, i3; int a, i1, i2, i3;
/* per face fixed seed */
BLI_thread_srandom(bs->thread, vlr->index);
/* check valid zspan */ /* check valid zspan */
if (ima != bs->ima) { if (ima != bs->ima) {
BKE_image_release_ibuf(bs->ima, bs->ibuf, NULL); BKE_image_release_ibuf(bs->ima, bs->ibuf, NULL);
@ -1037,6 +1046,8 @@ int RE_bake_shade_all_selected(Render *re, int type, Object *actob, short *do_up
/* get the threads running */ /* get the threads running */
for (a = 0; a < re->r.threads; a++) { for (a = 0; a < re->r.threads; a++) {
handles[a].thread = a;
/* set defaults in handles */ /* set defaults in handles */
handles[a].ssamp.shi[0].lay = re->lay; handles[a].ssamp.shi[0].lay = re->lay;