Closed tigrazone closed 2 weeks ago
It look like ONB isnt it?
void Onb(in vec3 N, inout vec3 T, inout vec3 B) { vec3 up = abs(N.z) < 0.9999999 ? vec3(0, 0, 1) : vec3(1, 0, 0); T = normalize(cross(up, N)); B = cross(N, T); }
or newer https://graphics.pixar.com/library/OrthonormalB/paper.pdf
void branchless_onb(vec3 n, out vec3 b1, out vec3 b2) { float sign = n.z > 0.f ? 1.f : -1.f; float a = -1.f / (sign + n.z); b2 = vec3(n.x * n.y * a, sign + n.y * n.y * a, -n.y); b1 = vec3(1.f + sign * n.x * n.x * a, sign * b2.x, -sign * n.x); }
it is ONB, copy from Metal3 PathTracing code, performance friendly
It look like ONB isnt it?
or newer https://graphics.pixar.com/library/OrthonormalB/paper.pdf