Cycles: Implement unaligned nodes BVH builder

This is a special builder type which is allowed to orient nodes to
strands direction, hence minimizing their surface area in comparison
with axis-aligned nodes. Such nodes are much more efficient for hair
rendering.

Implementation of BVH builder is based on Embree, and generally idea
there is to calculate axis-aligned SAH and oriented SAH and if SAH
of oriented node is smaller than axis-aligned SAH we create unaligned
node.

We store both aligned and unaligned nodes in the same tree (which
seems to be different from what Embree is doing) so we don't have
any any extra calculations needed to set up hair ray for BVH
traversal, hence avoiding any possible negative effect of this new
BVH nodes type.

This new builder is currently not in use, still need to make BVH
traversal code aware of unaligned nodes.
This commit is contained in:
2016-07-07 12:18:57 +02:00
parent 1a2012145d
commit b03e66e75f
21 changed files with 1357 additions and 261 deletions

View File

@@ -127,6 +127,19 @@ ccl_device_inline Transform make_transform(float a, float b, float c, float d,
return t;
}
/* Constructs a coordinate frame from a normalized normal. */
ccl_device_inline Transform make_transform_frame(const float3& N)
{
const float3 dx0 = cross(make_float3(1.0f, 0.0f, 0.0f), N);
const float3 dx1 = cross(make_float3(0.0f, 1.0f, 0.0f), N);
const float3 dx = normalize((dot(dx0,dx0) > dot(dx1,dx1))? dx0: dx1);
const float3 dy = normalize(cross(N, dx));
return make_transform(dx.x, dx.y, dx.z, 0.0f,
dy.x, dy.y, dy.z, 0.0f,
N.x , N.y, N.z, 0.0f,
0.0f, 0.0f, 0.0f, 1.0f);
}
#ifndef __KERNEL_GPU__
ccl_device_inline Transform operator*(const Transform a, const Transform b)