Fix for bug #8963: there was still an issue with SSS and transparency
in the shading because of ramps.
This commit is contained in:
@@ -1430,19 +1430,8 @@ static void shade_sample_sss(ShadeSample *ssamp, Material *mat, ObjectInstanceRe
|
||||
/* texture blending */
|
||||
texfac= shi->mat->sss_texfac;
|
||||
|
||||
alpha= shr.col[3];
|
||||
alpha= shr.combined[3];
|
||||
*area *= alpha;
|
||||
|
||||
if(texfac == 0.0f) {
|
||||
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];
|
||||
}
|
||||
}
|
||||
|
||||
static void zbufshade_sss_free(RenderPart *pa)
|
||||
|
||||
@@ -1552,6 +1552,24 @@ void shade_lamp_loop(ShadeInput *shi, ShadeResult *shr)
|
||||
shr->col[1]= shi->g*shi->alpha;
|
||||
shr->col[2]= shi->b*shi->alpha;
|
||||
shr->col[3]= shi->alpha;
|
||||
|
||||
if((ma->sss_flag & MA_DIFF_SSS) && !has_sss_tree(&R, ma)) {
|
||||
if(ma->sss_texfac == 0.0f) {
|
||||
shi->r= shi->g= shi->b= shi->alpha= 1.0f;
|
||||
shr->col[0]= shr->col[1]= shr->col[2]= shr->col[3]= 1.0f;
|
||||
}
|
||||
else {
|
||||
shi->r= pow(shi->r, ma->sss_texfac);
|
||||
shi->g= pow(shi->g, ma->sss_texfac);
|
||||
shi->b= pow(shi->b, ma->sss_texfac);
|
||||
shi->alpha= pow(shi->alpha, ma->sss_texfac);
|
||||
|
||||
shr->col[0]= pow(shr->col[0], ma->sss_texfac);
|
||||
shr->col[1]= pow(shr->col[1], ma->sss_texfac);
|
||||
shr->col[2]= pow(shr->col[2], ma->sss_texfac);
|
||||
shr->col[3]= pow(shr->col[3], ma->sss_texfac);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(ma->mode & MA_SHLESS) {
|
||||
@@ -1618,29 +1636,31 @@ 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], alpha, invalpha, texfac= ma->sss_texfac;
|
||||
float sss[3], col[3], 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;
|
||||
invalpha= (shr->col[3] > FLT_EPSILON)? 1.0f/shr->col[3]: 1.0f;
|
||||
|
||||
if(texfac==0.0f) {
|
||||
VECCOPY(col, shr->col);
|
||||
VecMulf(col, invalpha);
|
||||
}
|
||||
else if(texfac==1.0f) {
|
||||
col[0]= col[1]= col[2]= 1.0f;
|
||||
VecMulf(col, invalpha);
|
||||
}
|
||||
else {
|
||||
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);
|
||||
VecMulf(col, invalpha);
|
||||
col[0]= pow(col[0], 1.0f-texfac);
|
||||
col[1]= pow(col[1], 1.0f-texfac);
|
||||
col[2]= pow(col[2], 1.0f-texfac);
|
||||
}
|
||||
|
||||
shr->diff[0]= sss[0]*col[0]*invalpha;
|
||||
shr->diff[1]= sss[1]*col[1]*invalpha;
|
||||
shr->diff[2]= sss[2]*col[2]*invalpha;
|
||||
shr->diff[0]= sss[0]*col[0];
|
||||
shr->diff[1]= sss[1]*col[1];
|
||||
shr->diff[2]= sss[2]*col[2];
|
||||
|
||||
if(shi->combinedflag & SCE_PASS_SHADOW) {
|
||||
shr->shad[0]= shr->diff[0];
|
||||
|
||||
Reference in New Issue
Block a user