diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index eb9132cad3..754cb8b0c2 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -6,6 +6,7 @@ A new header is inserted each time a *tag* is created. # Release notes +- Improved robustness in the tangents utility for meshes that have tangents *and* normals. - Introduced `RenderTarget` API that allows View to reference an offscreen render target. - Added `lucy_bloom` sample to demonstrate the new `RenderTarget` API. - Added Screen Space Ambient Occlusion support (SAO) diff --git a/libs/geometry/src/SurfaceOrientation.cpp b/libs/geometry/src/SurfaceOrientation.cpp index 54a1d7c4f5..cd552dccd4 100644 --- a/libs/geometry/src/SurfaceOrientation.cpp +++ b/libs/geometry/src/SurfaceOrientation.cpp @@ -169,6 +169,13 @@ SurfaceOrientation OrientationBuilderImpl::buildWithSuppliedTangents() { float3 n = *normal; float3 t = *tanvec; float3 b = *tandir > 0 ? cross(t, n) : cross(n, t); + + // Some assets do not provide perfectly orthogonal tangents and normals, so we adjust the + // tangent to enforce orthonormality. We would rather honor the exact normal vector than + // the exact tangent vector since the latter is only used for bump mapping and anisotropic + // lighting. + t = *tandir > 0 ? cross(n, b) : cross(b, n); + quats[qindex] = mat3f::packTangentFrame({t, b, n}); normal = (const float3*) (((const uint8_t*) normal) + nstride); tanvec = (const float3*) (((const uint8_t*) tanvec) + tstride);