Fix #30081: the fix for #30026 related to rendering indirect/environment light
authorBrecht Van Lommel <brechtvanlommel@pandora.be>
Tue, 7 Feb 2012 21:04:10 +0000 (21:04 +0000)
committerBrecht Van Lommel <brechtvanlommel@pandora.be>
Tue, 7 Feb 2012 21:04:10 +0000 (21:04 +0000)
with material ambient zero broke backwards compatibility too much. The behavior
to have ambient zero affect things even if it is not used as a factor does not
make much sense but keeps things compatible. Now instead fixed the use of
uninitialized memory.

source/blender/render/intern/source/shadeoutput.c

index 0e9cfd1..9aac7aa 100644 (file)
@@ -1030,12 +1030,17 @@ static void do_specular_ramp(ShadeInput *shi, float is, float t, float spec[3])
 /* preprocess, textures were not done, don't use shi->amb for that reason */
 void ambient_occlusion(ShadeInput *shi)
 {
-       if(R.wrld.ao_gather_method == WO_AOGATHER_APPROX)
+       if((R.wrld.ao_gather_method == WO_AOGATHER_APPROX) && shi->mat->amb!=0.0f) {
                sample_occ(&R, shi);
-       else if(R.r.mode & R_RAYTRACE)
+       }
+       else if((R.r.mode & R_RAYTRACE) && shi->mat->amb!=0.0f) {
                ray_ao(shi, shi->ao, shi->env);
-       else
+       }
+       else {
                shi->ao[0]= shi->ao[1]= shi->ao[2]= 1.0f;
+               zero_v3(shi->env);
+               zero_v3(shi->indirect);
+       }
 }