Fix T38831: blender internal enabling shadow pass changes material node diffuse.
It would include/exclude shadow depending on the pass being disabled/enabled, but that should have no influence on the combined render result. Now it always includes shadow.
This commit is contained in:
parent
4cfca0adfe
commit
1dbd3ae629
Notes:
blender-bot
2023-02-14 11:07:22 +01:00
Referenced by issue #38831, shadow pass makes differences when using material node
|
@ -186,7 +186,7 @@ static void node_shader_exec_material(void *data, int UNUSED(thread), bNode *nod
|
|||
if (node->type == SH_NODE_MATERIAL_EXT) {
|
||||
/* Shadow, Reflect, Refract, Radiosity, Speed seem to cause problems inside
|
||||
* a node tree :( */
|
||||
copy_v3_v3(out[MAT_OUT_DIFFUSE]->vec, shrnode.diff);
|
||||
copy_v3_v3(out[MAT_OUT_DIFFUSE]->vec, shrnode.diffshad);
|
||||
copy_v3_v3(out[MAT_OUT_SPEC]->vec, shrnode.spec);
|
||||
copy_v3_v3(out[MAT_OUT_AO]->vec, shrnode.ao);
|
||||
}
|
||||
|
|
|
@ -50,9 +50,10 @@ typedef struct ShadeResult {
|
|||
float col[4];
|
||||
float alpha, mist, z;
|
||||
float emit[3];
|
||||
float diff[3]; /* no ramps, shadow, etc */
|
||||
float spec[3];
|
||||
float shad[4]; /* shad[3] is shadow intensity */
|
||||
float diff[3]; /* diffuse with no ramps, shadow, etc */
|
||||
float diffshad[3]; /* diffuse with shadow */
|
||||
float spec[3]; /* specular with shadow */
|
||||
float shad[4]; /* shad[3] is shadow intensity */
|
||||
float ao[3];
|
||||
float env[3];
|
||||
float indirect[3];
|
||||
|
|
|
@ -563,6 +563,7 @@ void shade_ray(Isect *is, ShadeInput *shi, ShadeResult *shr)
|
|||
|
||||
/* raytrace likes to separate the spec color */
|
||||
sub_v3_v3v3(shr->diff, shr->combined, shr->spec);
|
||||
copy_v3_v3(shr->diffshad, shr->diff);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -118,8 +118,10 @@ void shade_material_loop(ShadeInput *shi, ShadeResult *shr)
|
|||
madd_v3_v3fl(shr->combined, shr_t.combined, fac);
|
||||
if (shi->passflag & SCE_PASS_SPEC)
|
||||
madd_v3_v3fl(shr->spec, shr_t.spec, fac);
|
||||
if (shi->passflag & SCE_PASS_DIFFUSE)
|
||||
if (shi->passflag & SCE_PASS_DIFFUSE) {
|
||||
madd_v3_v3fl(shr->diff, shr_t.diff, fac);
|
||||
madd_v3_v3fl(shr->diffshad, shr_t.diffshad, fac);
|
||||
}
|
||||
if (shi->passflag & SCE_PASS_SHADOW)
|
||||
madd_v3_v3fl(shr->shad, shr_t.shad, fac);
|
||||
|
||||
|
|
|
@ -937,6 +937,8 @@ void shade_color(ShadeInput *shi, ShadeResult *shr)
|
|||
shr->diff[2] *= obcol[2];
|
||||
if (shi->mode & MA_TRANSP) shr->alpha *= obcol[3];
|
||||
}
|
||||
|
||||
copy_v3_v3(shr->diffshad, shr->diff);
|
||||
}
|
||||
|
||||
/* ramp for at end of shade */
|
||||
|
@ -1874,9 +1876,11 @@ void shade_lamp_loop(ShadeInput *shi, ShadeResult *shr)
|
|||
}
|
||||
|
||||
if (shi->combinedflag & SCE_PASS_SHADOW)
|
||||
copy_v3_v3(shr->combined, shr->shad); /* note, no ';' ! */
|
||||
copy_v3_v3(shr->diffshad, shr->shad); /* note, no ';' ! */
|
||||
else
|
||||
copy_v3_v3(shr->combined, shr->diff);
|
||||
copy_v3_v3(shr->diffshad, shr->diff);
|
||||
|
||||
copy_v3_v3(shr->combined, shr->diffshad);
|
||||
|
||||
/* calculate shadow pass, we use a multiplication mask */
|
||||
/* if diff = 0,0,0 it doesn't matter what the shadow pass is, so leave it as is */
|
||||
|
|
|
@ -216,8 +216,10 @@ static void interpolate_shade_result(ShadeResult *shr1, ShadeResult *shr2, float
|
|||
}
|
||||
if (addpassflag & SCE_PASS_EMIT)
|
||||
interpolate_vec3(shr1->emit, shr2->emit, t, negt, shr->emit);
|
||||
if (addpassflag & SCE_PASS_DIFFUSE)
|
||||
if (addpassflag & SCE_PASS_DIFFUSE) {
|
||||
interpolate_vec3(shr1->diff, shr2->diff, t, negt, shr->diff);
|
||||
interpolate_vec3(shr1->diffshad, shr2->diffshad, t, negt, shr->diffshad);
|
||||
}
|
||||
if (addpassflag & SCE_PASS_SPEC)
|
||||
interpolate_vec3(shr1->spec, shr2->spec, t, negt, shr->spec);
|
||||
if (addpassflag & SCE_PASS_SHADOW)
|
||||
|
|
|
@ -748,6 +748,7 @@ static void volume_trace(struct ShadeInput *shi, struct ShadeResult *shr, int in
|
|||
shr->alpha = col[3];
|
||||
|
||||
copy_v3_v3(shr->diff, shr->combined);
|
||||
copy_v3_v3(shr->diffshad, shr->diff);
|
||||
}
|
||||
|
||||
/* Traces a shadow through the object,
|
||||
|
|
Loading…
Reference in New Issue