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
Notes: blender-bot 2023-02-14 09:10:48 +01:00
Referenced by issue #44598, Texture baking with shadow sampling leads to nondeterministic results (blender internal engine)
1 changed files with 11 additions and 0 deletions

View File

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