[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [60198] trunk/blender/intern/cycles/kernel : Fix #36741: cycles AO pass giving values > 1.0 with transparency.

Brecht Van Lommel brechtvanlommel at pandora.be
Tue Sep 17 15:22:42 CEST 2013


Revision: 60198
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=60198
Author:   blendix
Date:     2013-09-17 13:22:42 +0000 (Tue, 17 Sep 2013)
Log Message:
-----------
Fix #36741: cycles AO pass giving values > 1.0 with transparency.

Modified Paths:
--------------
    trunk/blender/intern/cycles/kernel/kernel_accumulate.h
    trunk/blender/intern/cycles/kernel/kernel_passes.h
    trunk/blender/intern/cycles/kernel/kernel_path.h
    trunk/blender/intern/cycles/kernel/kernel_shader.h

Modified: trunk/blender/intern/cycles/kernel/kernel_accumulate.h
===================================================================
--- trunk/blender/intern/cycles/kernel/kernel_accumulate.h	2013-09-17 13:07:48 UTC (rev 60197)
+++ trunk/blender/intern/cycles/kernel/kernel_accumulate.h	2013-09-17 13:22:42 UTC (rev 60198)
@@ -210,14 +210,14 @@
 #endif
 }
 
-__device_inline void path_radiance_accum_ao(PathRadiance *L, float3 throughput, float3 bsdf, float3 ao, int bounce)
+__device_inline void path_radiance_accum_ao(PathRadiance *L, float3 throughput, float3 alpha, 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;
+			L->ao += alpha*throughput*ao;
 		}
 		else {
 			/* indirectly visible lighting after BSDF bounce */

Modified: trunk/blender/intern/cycles/kernel/kernel_passes.h
===================================================================
--- trunk/blender/intern/cycles/kernel/kernel_passes.h	2013-09-17 13:07:48 UTC (rev 60197)
+++ trunk/blender/intern/cycles/kernel/kernel_passes.h	2013-09-17 13:22:42 UTC (rev 60198)
@@ -108,8 +108,8 @@
 			mist = powf(mist, mist_falloff);
 
 		/* modulate by transparency */
-		float3 alpha = throughput*(make_float3(1.0f, 1.0f, 1.0f) - shader_bsdf_transparency(kg, sd));
-		L->mist += (1.0f - mist)*average(alpha);
+		float3 alpha = shader_bsdf_alpha(kg, sd);
+		L->mist += (1.0f - mist)*average(throughput*alpha);
 	}
 #endif
 }

Modified: trunk/blender/intern/cycles/kernel/kernel_path.h
===================================================================
--- trunk/blender/intern/cycles/kernel/kernel_path.h	2013-09-17 13:07:48 UTC (rev 60197)
+++ trunk/blender/intern/cycles/kernel/kernel_path.h	2013-09-17 13:22:42 UTC (rev 60198)
@@ -229,6 +229,7 @@
 			float3 ao_bsdf = shader_bsdf_ao(kg, &sd, ao_factor, &ao_N);
 			float3 ao_D;
 			float ao_pdf;
+			float3 ao_alpha = make_float3(0.0f, 0.0f, 0.0f);
 
 			sample_cos_hemisphere(ao_N, bsdf_u, bsdf_v, &ao_D, &ao_pdf);
 
@@ -246,7 +247,7 @@
 				light_ray.dD = differential3_zero();
 
 				if(!shadow_blocked(kg, &state, &light_ray, &ao_shadow))
-					path_radiance_accum_ao(L, throughput, ao_bsdf, ao_shadow, state.bounce);
+					path_radiance_accum_ao(L, throughput, ao_alpha, ao_bsdf, ao_shadow, state.bounce);
 			}
 		}
 #endif
@@ -624,6 +625,7 @@
 			float3 ao_bsdf = shader_bsdf_ao(kg, &sd, ao_factor, &ao_N);
 			float3 ao_D;
 			float ao_pdf;
+			float3 ao_alpha = shader_bsdf_alpha(kg, &sd);
 
 			sample_cos_hemisphere(ao_N, bsdf_u, bsdf_v, &ao_D, &ao_pdf);
 
@@ -641,7 +643,7 @@
 				light_ray.dD = differential3_zero();
 
 				if(!shadow_blocked(kg, &state, &light_ray, &ao_shadow))
-					path_radiance_accum_ao(&L, throughput, ao_bsdf, ao_shadow, state.bounce);
+					path_radiance_accum_ao(&L, throughput, ao_alpha, ao_bsdf, ao_shadow, state.bounce);
 			}
 		}
 #endif
@@ -1076,6 +1078,7 @@
 			float ao_factor = kernel_data.background.ao_factor;
 			float3 ao_N;
 			float3 ao_bsdf = shader_bsdf_ao(kg, &sd, ao_factor, &ao_N);
+			float3 ao_alpha = shader_bsdf_alpha(kg, &sd);
 
 			for(int j = 0; j < num_samples; j++) {
 				float bsdf_u, bsdf_v;
@@ -1100,7 +1103,7 @@
 					light_ray.dD = differential3_zero();
 
 					if(!shadow_blocked(kg, &state, &light_ray, &ao_shadow))
-						path_radiance_accum_ao(&L, throughput*num_samples_inv, ao_bsdf, ao_shadow, state.bounce);
+						path_radiance_accum_ao(&L, throughput*num_samples_inv, ao_alpha, ao_bsdf, ao_shadow, state.bounce);
 				}
 			}
 		}

Modified: trunk/blender/intern/cycles/kernel/kernel_shader.h
===================================================================
--- trunk/blender/intern/cycles/kernel/kernel_shader.h	2013-09-17 13:07:48 UTC (rev 60197)
+++ trunk/blender/intern/cycles/kernel/kernel_shader.h	2013-09-17 13:22:42 UTC (rev 60198)
@@ -602,6 +602,16 @@
 #endif
 }
 
+__device float3 shader_bsdf_alpha(KernelGlobals *kg, ShaderData *sd)
+{
+	float3 alpha = make_float3(1.0f, 1.0f, 1.0f) - shader_bsdf_transparency(kg, sd);
+
+	alpha = max(alpha, make_float3(0.0f, 0.0f, 0.0f));
+	alpha = min(alpha, make_float3(1.0f, 1.0f, 1.0f));
+	
+	return alpha;
+}
+
 __device float3 shader_bsdf_diffuse(KernelGlobals *kg, ShaderData *sd)
 {
 #ifdef __MULTI_CLOSURE__




More information about the Bf-blender-cvs mailing list