Back to Filament

packTangentFrame

docs/android/dokka/filament-android/com.google.android.filament/-math-utils/pack-tangent-frame.md

1.75.04.7 KB
Original Source

//filament-android/com.google.android.filament/MathUtils/packTangentFrame

packTangentFrame

[main]
open fun packTangentFrame(tangentX: Float, tangentY: Float, tangentZ: Float, bitangentX: Float, bitangentY: Float, bitangentZ: Float, normalX: Float, normalY: Float, normalZ: Float, quaternion: Array<Float>)

Packs the tangent frame represented by the specified tangent, bitangent, and normal into a quaternion.

Reflection is preserved by encoding it as the sign of the w component in the resulting quaternion. Since -0 cannot always be represented on the GPU, this function computes a bias to ensure values are always either positive or negative, never 0. The bias is computed based on a per-element storage size of 2 bytes, making the resulting quaternion suitable for storage into an SNORM16 vector.

Parameters

main

tangentXthe X component of the tangent
tangentYthe Y component of the tangent
tangentZthe Z component of the tangent
bitangentXthe X component of the bitangent
bitangentYthe Y component of the bitangent
bitangentZthe Z component of the bitangent
normalXthe X component of the normal
normalYthe Y component of the normal
normalZthe Z component of the normal
quaterniona float array of at least size 4 for the quaternion result to be stored

[main]
open fun packTangentFrame(tangentX: Float, tangentY: Float, tangentZ: Float, bitangentX: Float, bitangentY: Float, bitangentZ: Float, normalX: Float, normalY: Float, normalZ: Float, quaternion: Array<Float>, offset: Int)

Packs the tangent frame represented by the specified tangent, bitangent, and normal into a quaternion.

Reflection is preserved by encoding it as the sign of the w component in the resulting quaternion. Since -0 cannot always be represented on the GPU, this function computes a bias to ensure values are always either positive or negative, never 0. The bias is computed based on a per-element storage size of 2 bytes, making the resulting quaternion suitable for storage into an SNORM16 vector.

Parameters

main

tangentXthe X component of the tangent
tangentYthe Y component of the tangent
tangentZthe Z component of the tangent
bitangentXthe X component of the bitangent
bitangentYthe Y component of the bitangent
bitangentZthe Z component of the bitangent
normalXthe X component of the normal
normalYthe Y component of the normal
normalZthe Z component of the normal
quaterniona float array of at least size 4 for the quaternion result to be stored
offsetoffset, in elements, into the quaternion array to store the results