geometry: tweak provided tangents to enforce orthonormality.

Fixes #1291.
This commit is contained in:
Philip Rideout
2019-06-12 15:43:38 -07:00
parent 5795bef02a
commit 709c5884ea
2 changed files with 8 additions and 0 deletions

View File

@@ -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)

View File

@@ -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);