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
path: root/source
diff options
context:
space:
mode:
authorBrecht Van Lommel <brechtvanlommel@pandora.be>2008-03-04 22:58:22 +0300
committerBrecht Van Lommel <brechtvanlommel@pandora.be>2008-03-04 22:58:22 +0300
commit4ba2162e636c78001ffc508a64423357745ed868 (patch)
tree23f1b401ce3f640f38f85807e2820d218033f847 /source
parent8b5a5b71d53a139212bd6bfb630e3ea87b533727 (diff)
Bugfix: the shadow samplenr increment to reuse shadow results in
the renderer could lead to results being reused for unrelated points, result was one wrong pixel or strand per part. Now instead of setting the sample counter to 0 multiple times, it keeps a global counter per thread for the whole render.
Diffstat (limited to 'source')
-rw-r--r--source/blender/render/intern/include/render_types.h3
-rw-r--r--source/blender/render/intern/include/shading.h2
-rw-r--r--source/blender/render/intern/source/convertblender.c2
-rw-r--r--source/blender/render/intern/source/rendercore.c4
-rw-r--r--source/blender/render/intern/source/shadeinput.c6
-rw-r--r--source/blender/render/intern/source/strand.c2
-rw-r--r--source/blender/render/intern/source/zbuf.c4
7 files changed, 12 insertions, 11 deletions
diff --git a/source/blender/render/intern/include/render_types.h b/source/blender/render/intern/include/render_types.h
index 271bbd3de00..edb5f1442b2 100644
--- a/source/blender/render/intern/include/render_types.h
+++ b/source/blender/render/intern/include/render_types.h
@@ -152,6 +152,9 @@ struct Render
float jit[32][2];
QMCSampler *qsa;
+ /* shadow counter, detect shadow-reuse for shaders */
+ int shadowsamplenr[BLENDER_MAX_THREADS];
+
/* scene, and its full copy of renderdata and world */
Scene *scene;
RenderData r;
diff --git a/source/blender/render/intern/include/shading.h b/source/blender/render/intern/include/shading.h
index e015309784d..6f1cb8dd7a9 100644
--- a/source/blender/render/intern/include/shading.h
+++ b/source/blender/render/intern/include/shading.h
@@ -47,8 +47,6 @@ typedef struct ShadeSample {
/* could be malloced once */
ShadeInput shi[RE_MAX_OSA];
ShadeResult shr[RE_MAX_OSA];
-
- int samplenr; /* counter, detect shadow-reuse for shaders */
} ShadeSample;
diff --git a/source/blender/render/intern/source/convertblender.c b/source/blender/render/intern/source/convertblender.c
index c7eb03a295a..eccb8e23c2b 100644
--- a/source/blender/render/intern/source/convertblender.c
+++ b/source/blender/render/intern/source/convertblender.c
@@ -3641,6 +3641,8 @@ static GroupObject *add_render_lamp(Render *re, Object *ob)
LampShadowSample *ls;
LampShadowSubSample *lss;
int a, b;
+
+ memset(re->shadowsamplenr, 0, sizeof(re->shadowsamplenr));
lar->shadsamp= MEM_mallocN(re->r.threads*sizeof(LampShadowSample), "lamp shadow sample");
ls= lar->shadsamp;
diff --git a/source/blender/render/intern/source/rendercore.c b/source/blender/render/intern/source/rendercore.c
index c72edabc65c..1d65f400634 100644
--- a/source/blender/render/intern/source/rendercore.c
+++ b/source/blender/render/intern/source/rendercore.c
@@ -1281,7 +1281,7 @@ static void shade_sample_sss(ShadeSample *ssamp, Material *mat, ObjectInstanceRe
float texfac, orthoarea, nor[3];
/* cache for shadow */
- shi->samplenr++;
+ shi->samplenr= R.shadowsamplenr[shi->thread]++;
if(quad)
shade_input_set_triangle_i(shi, obi, vlr, 0, 2, 3);
@@ -1821,7 +1821,7 @@ static void bake_set_shade_input(ObjectInstanceRen *obi, VlakRen *vlr, ShadeInpu
}
/* cache for shadow */
- shi->samplenr++;
+ shi->samplenr= R.shadowsamplenr[shi->thread]++;
shi->u= -u;
shi->v= -v;
diff --git a/source/blender/render/intern/source/shadeinput.c b/source/blender/render/intern/source/shadeinput.c
index f0ce02ef994..29be0d710ca 100644
--- a/source/blender/render/intern/source/shadeinput.c
+++ b/source/blender/render/intern/source/shadeinput.c
@@ -1235,8 +1235,6 @@ void shade_sample_initialize(ShadeSample *ssamp, RenderPart *pa, RenderLayer *rl
}
get_sample_layers(pa, rl, ssamp->rlpp);
-
- ssamp->samplenr= 0; /* counter, detect shadow-reuse for shaders */
}
/* Do AO or (future) GI */
@@ -1286,7 +1284,7 @@ void shade_samples_fill_with_ps(ShadeSample *ssamp, PixStr *ps, int x, int y)
shi->mask= (1<<samp);
// shi->rl= ssamp->rlpp[samp];
- shi->samplenr= ssamp->samplenr++; /* this counter is not being reset per pixel */
+ shi->samplenr= R.shadowsamplenr[shi->thread]++; /* this counter is not being reset per pixel */
shade_input_set_viewco(shi, xs, ys, (float)ps->z);
shade_input_set_uv(shi);
shade_input_set_normals(shi);
@@ -1307,7 +1305,7 @@ void shade_samples_fill_with_ps(ShadeSample *ssamp, PixStr *ps, int x, int y)
ys= (float)y + 0.5f;
}
shi->mask= curmask;
- shi->samplenr= ssamp->samplenr++;
+ shi->samplenr= R.shadowsamplenr[shi->thread]++;
shade_input_set_viewco(shi, xs, ys, (float)ps->z);
shade_input_set_uv(shi);
shade_input_set_normals(shi);
diff --git a/source/blender/render/intern/source/strand.c b/source/blender/render/intern/source/strand.c
index a459e5e5848..1c5d793dbc9 100644
--- a/source/blender/render/intern/source/strand.c
+++ b/source/blender/render/intern/source/strand.c
@@ -275,7 +275,7 @@ void strand_shade_point(Render *re, ShadeSample *ssamp, StrandSegment *sseg, Str
shi->obr= sseg->obi->obr;
/* cache for shadow */
- shi->samplenr= ssamp->samplenr++;
+ shi->samplenr= re->shadowsamplenr[shi->thread]++;
shade_input_set_strand(shi, sseg->strand, spoint);
shade_input_set_strand_texco(shi, sseg->strand, sseg->v[1], spoint);
diff --git a/source/blender/render/intern/source/zbuf.c b/source/blender/render/intern/source/zbuf.c
index ded525f6f35..1243e99e521 100644
--- a/source/blender/render/intern/source/zbuf.c
+++ b/source/blender/render/intern/source/zbuf.c
@@ -3778,7 +3778,7 @@ static void shade_tra_samples_fill(ShadeSample *ssamp, int x, int y, int z, int
shi++;
}
shi->mask= (1<<samp);
- shi->samplenr= ssamp->samplenr++;
+ shi->samplenr= R.shadowsamplenr[shi->thread]++;
shade_input_set_viewco(shi, xs, ys, (float)z);
shade_input_set_uv(shi);
shade_input_set_normals(shi);
@@ -3798,7 +3798,7 @@ static void shade_tra_samples_fill(ShadeSample *ssamp, int x, int y, int z, int
ys= (float)y + 0.5f;
}
shi->mask= curmask;
- shi->samplenr= ssamp->samplenr++;
+ shi->samplenr= R.shadowsamplenr[shi->thread]++;
shade_input_set_viewco(shi, xs, ys, (float)z);
shade_input_set_uv(shi);
shade_input_set_normals(shi);