Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Sharybin <sergey.vfx@gmail.com>2016-03-24 17:00:09 +0300
committerSergey Sharybin <sergey.vfx@gmail.com>2016-03-24 17:01:39 +0300
commit60cf62ff4b08e310208dca9e35bd75131833e1aa (patch)
treed580e65f9cdb0f6d594e60aa8ff6cf15dacbea24 /intern/cycles/kernel/kernel_projection.h
parent8249046b82f7a7a79eac42f3870349604eeb2711 (diff)
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.
Diffstat (limited to 'intern/cycles/kernel/kernel_projection.h')
-rw-r--r--intern/cycles/kernel/kernel_projection.h17
1 files changed, 8 insertions, 9 deletions
diff --git a/intern/cycles/kernel/kernel_projection.h b/intern/cycles/kernel/kernel_projection.h
index d042acc76b3..c1a359e9269 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)