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-04-12 20:31:29 +0400
committerBrecht Van Lommel <brechtvanlommel@pandora.be>2008-04-12 20:31:29 +0400
commitf810245076f145683d263d978cd16450d479521f (patch)
tree8ab59027f57893a6793c7f0aec72cd721ac06f69 /source
parent0ec76c6dcf462f51d8f2a46c21dbd83870fc4eda (diff)
Fix or bug #8712: transparency + sss gave too bright results.
Diffstat (limited to 'source')
-rw-r--r--source/blender/render/intern/source/rendercore.c21
-rw-r--r--source/blender/render/intern/source/shadeoutput.c24
2 files changed, 26 insertions, 19 deletions
diff --git a/source/blender/render/intern/source/rendercore.c b/source/blender/render/intern/source/rendercore.c
index 222dc932004..4ac7b6ed7b4 100644
--- a/source/blender/render/intern/source/rendercore.c
+++ b/source/blender/render/intern/source/rendercore.c
@@ -1279,7 +1279,7 @@ static void shade_sample_sss(ShadeSample *ssamp, Material *mat, ObjectInstanceRe
{
ShadeInput *shi= ssamp->shi;
ShadeResult shr;
- float texfac, orthoarea, nor[3];
+ float texfac, orthoarea, nor[3], alpha;
/* cache for shadow */
shi->samplenr= R.shadowsamplenr[shi->thread]++;
@@ -1345,15 +1345,18 @@ static void shade_sample_sss(ShadeSample *ssamp, Material *mat, ObjectInstanceRe
/* texture blending */
texfac= shi->mat->sss_texfac;
+ alpha= shr.col[3];
+ *area *= alpha;
+
if(texfac == 0.0f) {
- if(shr.col[0]!=0.0f) color[0] /= shr.col[0];
- if(shr.col[1]!=0.0f) color[1] /= shr.col[1];
- if(shr.col[2]!=0.0f) color[2] /= shr.col[2];
- }
- else if(texfac != 1.0f) {
- if(shr.col[0]!=0.0f) color[0] *= pow(shr.col[0], texfac)/shr.col[0];
- if(shr.col[1]!=0.0f) color[1] *= pow(shr.col[1], texfac)/shr.col[1];
- if(shr.col[2]!=0.0f) color[2] *= pow(shr.col[2], texfac)/shr.col[2];
+ if(shr.col[0]!=0.0f) color[0] *= alpha/shr.col[0];
+ if(shr.col[1]!=0.0f) color[1] *= alpha/shr.col[1];
+ if(shr.col[2]!=0.0f) color[2] *= alpha/shr.col[2];
+ }
+ else if(texfac != 1.0f && (alpha > FLT_EPSILON)) {
+ if(shr.col[0]!=0.0f) color[0] *= alpha*pow(shr.col[0]/alpha, texfac)/shr.col[0];
+ if(shr.col[1]!=0.0f) color[1] *= alpha*pow(shr.col[1]/alpha, texfac)/shr.col[1];
+ if(shr.col[2]!=0.0f) color[2] *= alpha*pow(shr.col[2]/alpha, texfac)/shr.col[2];
}
}
diff --git a/source/blender/render/intern/source/shadeoutput.c b/source/blender/render/intern/source/shadeoutput.c
index 4da9617f959..d4398fcaaee 100644
--- a/source/blender/render/intern/source/shadeoutput.c
+++ b/source/blender/render/intern/source/shadeoutput.c
@@ -1620,10 +1620,13 @@ void shade_lamp_loop(ShadeInput *shi, ShadeResult *shr)
if (shr->shad[2] < 0) shr->shad[2] = 0;
if(ma->sss_flag & MA_DIFF_SSS) {
- float sss[3], col[3], texfac= ma->sss_texfac;
+ float sss[3], col[3], alpha, invalpha, texfac= ma->sss_texfac;
/* this will return false in the preprocess stage */
if(sample_sss(&R, ma, shi->co, sss)) {
+ alpha= shr->col[3];
+ invalpha= (alpha > FLT_EPSILON)? 1.0f/alpha: 1.0f;
+
if(texfac==0.0f) {
VECCOPY(col, shr->col);
}
@@ -1631,19 +1634,20 @@ void shade_lamp_loop(ShadeInput *shi, ShadeResult *shr)
col[0]= col[1]= col[2]= 1.0f;
}
else {
- col[0]= pow(shr->col[0], 1.0f-texfac);
- col[1]= pow(shr->col[1], 1.0f-texfac);
- col[2]= pow(shr->col[2], 1.0f-texfac);
+ VECCOPY(col, shr->col);
+ col[0]= alpha*pow(col[0]*invalpha, 1.0f-texfac);
+ col[1]= alpha*pow(col[1]*invalpha, 1.0f-texfac);
+ col[2]= alpha*pow(col[2]*invalpha, 1.0f-texfac);
}
- shr->diff[0]= sss[0]*col[0];
- shr->diff[1]= sss[1]*col[1];
- shr->diff[2]= sss[2]*col[2];
+ shr->diff[0]= sss[0]*col[0]*invalpha;
+ shr->diff[1]= sss[1]*col[1]*invalpha;
+ shr->diff[2]= sss[2]*col[2]*invalpha;
if(shi->combinedflag & SCE_PASS_SHADOW) {
- shr->shad[0]= sss[0]*col[0];
- shr->shad[1]= sss[1]*col[1];
- shr->shad[2]= sss[2]*col[2];
+ shr->shad[0]= shr->diff[0];
+ shr->shad[1]= shr->diff[1];
+ shr->shad[2]= shr->diff[2];
}
}
}