forked from bartvdbraak/blender
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:
parent
e177ac100b
commit
ba7fd8cd5c
@ -393,11 +393,21 @@ void set_rgb_zero(out vec3 outval)
|
||||
outval = vec3(0.0);
|
||||
}
|
||||
|
||||
void set_rgb_one(out vec3 outval)
|
||||
{
|
||||
outval = vec3(1.0);
|
||||
}
|
||||
|
||||
void set_rgba_zero(out vec4 outval)
|
||||
{
|
||||
outval = vec4(0.0);
|
||||
}
|
||||
|
||||
void set_rgba_one(out vec4 outval)
|
||||
{
|
||||
outval = vec4(1.0);
|
||||
}
|
||||
|
||||
void brightness_contrast(vec4 col, float brightness, float contrast, out vec4 outcol)
|
||||
{
|
||||
float a = 1.0 + contrast;
|
||||
|
@ -299,6 +299,7 @@ static int gpu_shader_material(GPUMaterial *mat, bNode *node, bNodeExecData *UNU
|
||||
if (node->type == SH_NODE_MATERIAL_EXT) {
|
||||
out[MAT_OUT_DIFFUSE].link = shr.diff;
|
||||
out[MAT_OUT_SPEC].link = shr.spec;
|
||||
GPU_link(mat, "set_rgb_one", &out[MAT_OUT_AO].link);
|
||||
}
|
||||
|
||||
return 1;
|
||||
|
@ -1789,11 +1789,9 @@ 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) {
|
||||
(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);
|
||||
@ -1801,6 +1799,10 @@ void shade_lamp_loop(ShadeInput *shi, ShadeResult *shr)
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user