Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions src/testrender/raytracer.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,14 @@ class OptixRenderer; // FIXME -- should not be here
inline OSL_HOSTDEVICE void
ortho(const Vec3& n, Vec3& x, Vec3& y)
{
x = (fabsf(n.x) > .01f ? Vec3(n.z, 0, -n.x) : Vec3(0, -n.z, n.y))
.normalize();
y = n.cross(x);
// https://research.pixar.com/docs/2017.Others.DBCHKLV.pdf
Comment thread
lgritz marked this conversation as resolved.
// Duff, et al. "Building an Orthonormal Basis, Revisited", JCGT 6(1) 2017.
float sign = copysignf(1.0f, n.z);
const float a = -1.0f / (sign + n.z);
const float b = n.x * n.y * a;

x = Vec3(1.0f + sign * n.x * n.x * a, sign * b, -sign * n.x);
y = Vec3(b, sign + n.y * n.y * a, -n.y);
}


Expand Down
3 changes: 2 additions & 1 deletion src/testrender/sampling.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ struct TangentFrame {
// build frame from unit normal
static OSL_HOSTDEVICE TangentFrame from_normal(const Vec3& n)
{
// https://graphics.pixar.com/library/OrthonormalB/paper.pdf
// https://research.pixar.com/docs/2017.Others.DBCHKLV.pdf
Comment thread
lgritz marked this conversation as resolved.
// Duff, et al. "Building an Orthonormal Basis, Revisited", JCGT 6(1) 2017.
const float sign = copysignf(1.0f, n.z);
const float a = -1 / (sign + n.z);
const float b = n.x * n.y * a;
Expand Down
Loading