Change the behavior of AO pass in Blender internal's shader/render node tree so that it becomes (1.0, 1.0, 1.0) when AO is disabled.

For materials using AO pass, this makes the material preview and the GLSL
preview more accurate, but shouldn't affect final rendering in most cases
because we usually enable AO when using the AO pass in node tree.

Thanks to Brecht for code review.
This commit is contained in:
2013-11-12 10:59:40 +00:00
parent e177ac100b
commit ba7fd8cd5c
3 changed files with 25 additions and 12 deletions

View File

@@ -1789,18 +1789,20 @@ void shade_lamp_loop(ShadeInput *shi, ShadeResult *shr)
}
/* AO pass */
if (R.wrld.mode & (WO_AMB_OCC|WO_ENV_LIGHT|WO_INDIRECT_LIGHT)) {
if (((passflag & SCE_PASS_COMBINED) && (shi->combinedflag & (SCE_PASS_AO|SCE_PASS_ENVIRONMENT|SCE_PASS_INDIRECT))) ||
(passflag & (SCE_PASS_AO|SCE_PASS_ENVIRONMENT|SCE_PASS_INDIRECT)))
{
if (R.r.mode & R_SHADOW) {
/* AO was calculated for scanline already */
if (shi->depth || shi->volume_depth)
ambient_occlusion(shi);
copy_v3_v3(shr->ao, shi->ao);
copy_v3_v3(shr->env, shi->env); /* XXX multiply */
copy_v3_v3(shr->indirect, shi->indirect); /* XXX multiply */
}
if (((passflag & SCE_PASS_COMBINED) && (shi->combinedflag & (SCE_PASS_AO|SCE_PASS_ENVIRONMENT|SCE_PASS_INDIRECT))) ||
(passflag & (SCE_PASS_AO|SCE_PASS_ENVIRONMENT|SCE_PASS_INDIRECT))) {
if ((R.wrld.mode & (WO_AMB_OCC|WO_ENV_LIGHT|WO_INDIRECT_LIGHT)) && (R.r.mode & R_SHADOW)) {
/* AO was calculated for scanline already */
if (shi->depth || shi->volume_depth)
ambient_occlusion(shi);
copy_v3_v3(shr->ao, shi->ao);
copy_v3_v3(shr->env, shi->env); /* XXX multiply */
copy_v3_v3(shr->indirect, shi->indirect); /* XXX multiply */
}
else {
shr->ao[0]= shr->ao[1]= shr->ao[2]= 1.0f;
zero_v3(shr->env);
zero_v3(shr->indirect);
}
}