[Bf-blender-cvs] [6045fc40f4c] gsoc-2018-many-light-sampling: Cycles: Light tree optimization

Erik Englesson noreply at git.blender.org
Fri Jul 27 18:19:50 CEST 2018


Commit: 6045fc40f4cd1d89f326a2d937e07752f5e3ad7c
Author: Erik Englesson
Date:   Wed Jul 25 13:47:27 2018 +0200
Branches: gsoc-2018-many-light-sampling
https://developer.blender.org/rB6045fc40f4cd1d89f326a2d937e07752f5e3ad7c

Cycles: Light tree optimization

The importance metric calculations now uses the
fast_cos() and fast_acos() functions. This gave
a 1.4x speedup on one of the test scenes.

===================================================================

M	intern/cycles/kernel/kernel_light.h

===================================================================

diff --git a/intern/cycles/kernel/kernel_light.h b/intern/cycles/kernel/kernel_light.h
index 56f4e9e0c72..af8127a08a6 100644
--- a/intern/cycles/kernel/kernel_light.h
+++ b/intern/cycles/kernel/kernel_light.h
@@ -1112,21 +1112,21 @@ ccl_device float calc_importance(KernelGlobals *kg, float3 P, float3 N,
 	} else {
 		const float sin_theta_u_squared = r2 / d2;
 		const float cos_theta_u         = safe_sqrtf(1.0f - sin_theta_u_squared);
-		theta_u                         = acosf(cos_theta_u);
+		theta_u                         = fast_acosf(cos_theta_u);
 	}
 
 	/* cos(theta') */
-	const float theta       = acosf(dot(axis, centroidToPDir));
+	const float theta       = fast_acosf(dot(axis, centroidToPDir));
 	const float theta_prime = fmaxf(theta - theta_o - theta_u, 0.0f);
 	if (theta_prime >= theta_e){
 		return 0.0f;
 	}
-	const float cos_theta_prime = cosf(theta_prime);
+	const float cos_theta_prime = fast_cosf(theta_prime);
 
 	/* f_a|cos(theta'_i)| -- diffuse approximation */
-	const float theta_i               = acosf(dot(N, -centroidToPDir));
+	const float theta_i               = fast_acosf(dot(N, -centroidToPDir));
 	const float theta_i_prime         = fmaxf(theta_i - theta_u, 0.0f);
-	const float cos_theta_i_prime     = cosf(theta_i_prime);
+	const float cos_theta_i_prime     = fast_cosf(theta_i_prime);
 	const float abs_cos_theta_i_prime = fabsf(cos_theta_i_prime);
 	/* doing something similar to bsdf_diffuse_eval_reflect() */
 	/* TODO: Use theta_i or theta_i_prime here? */



More information about the Bf-blender-cvs mailing list