Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Page 4 of 4 FirstFirst ... 234
Results 31 to 33 of 33

Thread: Quaternion functions for GLSL

  1. #31
    Advanced Member Frequent Contributor
    Join Date
    Apr 2009
    Posts
    529

    Re: Quaternion functions for GLSL

    As a side point....

    Very few models out there deliberately have non-orthogonal TBN-vector sets, very few. Additionally, using a skew matrix for modelview is not really that common either....

    Also as a side note, using quaternions for stuff besides TBN does happen, quite a bit at time. Indeed, if one knows apriori that the transformations one has are always orthoginal, then a (vec3, float, quaternion) tuple handles translation, scaling, mirroring and rotation.. i.e. an translation + M where M is orthogonal. The main benefit of such in C/C++ code is that composition can be so that the quaternion multiplies normalized the result.. this keeps thing much more numerically stable and is faster than reorthogonalizing a matrix.

    at any rate making quaternion a built in type in GLSL is useful.

  2. #32
    Advanced Member Frequent Contributor
    Join Date
    Apr 2009
    Posts
    529

    Re: Quaternion functions for GLSL

    Can't edit older posts... another nice thing to add: complex types and arithmetic.

  3. #33
    Member Regular Contributor DmitryM's Avatar
    Join Date
    Mar 2009
    Location
    Toronto
    Posts
    436

    Re: Quaternion functions for GLSL

    Let me share some experience of using quaternions for everything, including TBN.

    I provided (quaternion,handedness) pair instead of (normal,tangent,bitangent) in vertex attirbutes. Handedness is either +1 or -1. All vertex shaders linked with GLSL quaternion library, and used it to transform light & camera vectors in the tangent/whatever space. This setup supported everything you could do with orthonormalized TBN, took less space and bandwidth, but obviously required more code.

    The export procedure gets especially complex. First, you need to support the case when no UV is given by generating "fake" quaternions that would still provide you with good normals. Second, there has to be a smart pre-processing algorithm performed if you need those quaternions to be interpolation-friendly.

    This was a wonderful experience and all, you could even find my article about quaternions in GPU Pro-3. However, for the next project (kri-web) I decided to use quaternions only for complex problems (like skeletal animations) on a GPU side, and stick with a few matrices in most of other scenarios.

    In conclusion, I would appreciate the official support for quaternion operations in GLSL, but that's no longer as actual as it used to for me.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •