Cycles: ambient occlusion support, with AO factor and distance, and a render pass.
[blender.git] / intern / cycles / kernel / kernel_accumulate.h
index e71fad58c96096418129d32fd3f662153ef6fa16..7d9aaf81906e00fd999284b5cdaf63cfc102c4a4 100644 (file)
@@ -135,6 +135,7 @@ __device_inline void path_radiance_init(PathRadiance *L, int use_light_pass)
 
                L->emission = make_float3(0.0f, 0.0f, 0.0f);
                L->background = make_float3(0.0f, 0.0f, 0.0f);
+               L->ao = make_float3(0.0f, 0.0f, 0.0f);
        }
        else
                L->emission = make_float3(0.0f, 0.0f, 0.0f);
@@ -199,6 +200,27 @@ __device_inline void path_radiance_accum_emission(PathRadiance *L, float3 throug
 #endif
 }
 
+__device_inline void path_radiance_accum_ao(PathRadiance *L, float3 throughput, float3 bsdf, float3 ao, int bounce)
+{
+#ifdef __PASSES__
+       if(L->use_light_pass) {
+               if(bounce == 0) {
+                       /* directly visible lighting */
+                       L->direct_diffuse += throughput*bsdf*ao;
+                       L->ao += throughput*ao;
+               }
+               else {
+                       /* indirectly visible lighting after BSDF bounce */
+                       L->indirect += throughput*bsdf*ao;
+               }
+       }
+       else
+               L->emission += throughput*bsdf*ao;
+#else
+       *L += throughput*bsdf*ao;
+#endif
+}
+
 __device_inline void path_radiance_accum_light(PathRadiance *L, float3 throughput, BsdfEval *bsdf_eval, int bounce)
 {
 #ifdef __PASSES__