Commit: 60cf62ff4b08e310208dca9e35bd75131833e1aa
Author: Sergey Sharybin
Date:   Thu Mar 24 15:00:09 2016 +0100
Branches: master
https://developer.blender.org/rB60cf62ff4b08e310208dca9e35bd75131833e1aa

Cycles: Minor optimization of equirectangular projection

Don't calculate sine twice, store this in a variable instead.

Perhaps compilers can optimize this out, but helping them a but wouldn't hurt.

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

M       intern/cycles/kernel/kernel_projection.h

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

diff --git a/intern/cycles/kernel/kernel_projection.h 
b/intern/cycles/kernel/kernel_projection.h
index d042acc..c1a359e 100644
--- a/intern/cycles/kernel/kernel_projection.h
+++ b/intern/cycles/kernel/kernel_projection.h
@@ -47,10 +47,10 @@ ccl_device float2 direction_to_spherical(float3 dir)
 
 ccl_device float3 spherical_to_direction(float theta, float phi)
 {
-       return make_float3(
-               sinf(theta)*cosf(phi),
-               sinf(theta)*sinf(phi),
-               cosf(theta));
+       float sin_theta = sinf(theta);
+       return make_float3(sin_theta*cosf(phi),
+                          sin_theta*sinf(phi),
+                          cosf(theta));
 }
 
 /* Equirectangular coordinates <-> Cartesian direction */
@@ -67,11 +67,10 @@ ccl_device float3 equirectangular_range_to_direction(float 
u, float v, float4 ra
 {
        float phi = range.x*u + range.y;
        float theta = range.z*v + range.w;
-
-       return make_float3(
-               sinf(theta)*cosf(phi),
-               sinf(theta)*sinf(phi),
-               cosf(theta));
+       float sin_theta = sinf(theta);
+       return make_float3(sin_theta*cosf(phi),
+                          sin_theta*sinf(phi),
+                          cosf(theta));
 }
 
 ccl_device float2 direction_to_equirectangular(float3 dir)

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to