Model code: Variants for computing tangent-space vectors

Issue #100 resolved
Carsten Fuchs created an issue

In order to apply normal-maps to a mesh correctly, we have to compute the tangent-space vectors (normals, tangents, binormals/-tangents) exactly like the program did that created the normal-map (by projecting the details of a high-poly mesh onto a normal-map for use on the corresponding low-detail mesh).

Different programs may do this differently, e.g. averaging the tangent-space vectors of triangle with equal weight, or weighted by triangle area, or weighted by triangle angle at the common vertex, etc.

Also, we may wish to have a variant where no smoothing (averaging) is computed at all, e.g. for crates and boxes and other very simple models, or for testing.

The same facility would allow us to get rid of the `gts_*` members in `CafuModelT::MeshT`. (If we removed the `gts_*` members, we have to save all currently used `ase` and `lwo` models appropriately (with the proper tangent-space variant set) as `cmdl` files.)

Comments (7)

  1. Carsten Fuchs reporter

    (In [474]) Model code: Add support for importing smoothing groups to all model loaders.

    The loaders of all model file formats have been augmented to import smoothing groups, whenever such information is available in the imported file. The imported smoothing groups data is stored in our appropriately extended `cmdl` files, and the `CafuModelT` class has been extended accordingly.

    Still missing is - the actual ''use'' of the newly available information (at this time, we continue to compute tangent-space as before), - thorough testing for each of the supported file formats.

    References #100 and #101.

  2. Carsten Fuchs reporter

    (In [475]) Model code: Add per-mesh settings for tangent-space method and cast shadows.

    Continuing r474, this change adds new members to the `CafuModelT::MeshT` class for setting - the method for generating the tangent-space axes, and - if the mesh should cast dynamic shadows.

    The new settings are saved to and loaded from the Cafu `cmdl` model files, and have been made available to the user in the Model Editor's "Mesh Inspector" dialogs.

    References #100 and #101.

  3. Carsten Fuchs reporter

    (In [476]) Model code: Added implementations for the tangent-space methods.

    Continuing r475, this change adds implementations for the previously added tangent-space computation methods.

    Implemented, however, are only the methods `HARD` and `GLOBAL`. Method `SM_GROUPS` is currently the same as `GLOBAL`, and subject to implementation in separate ticket #101. Implementing the originally planned t-s method `SG_LOCAL` is unfortunately not worthwhile, as it seems to work well only for cone-shaped meshes (the relevant code is still present, but `#if 0...`'ed).

    For #100, it remains to remove the `gts_` ("given tangent-space") code as outlined in the ticket description.

    References #100.

  4. Carsten Fuchs reporter

    (In [479]) Model code: Removed support for "gts" (given tangent space) from the .lwo loader.

    "Given tangent space" is when our model code doesn't compute the normals and tangent vectors itself, but relies on those found in the file. This, however, is problematic in many regards (requires extra storage, works only for non-animated models, can be incomplete (comes with normals, but not with tangents), etc.), and thus support for "gts" is removed from our model code.

    References #100.

  5. Carsten Fuchs reporter

    (In [481]) Model code: Removed support for "gts" (given tangent space) from the .ase loader.

    Meshes loaded with the .ase loader are set to use the `HARD` tangent-space method by default, as this helps with many older and/or simpler models that are not immediately edited (converted to `cmdl`) in the Model Editor.

    "Given tangent space" is when our model code doesn't compute the normals and tangent vectors itself, but relies on those found in the file. This, however, is problematic in many regards (requires extra storage, works only for non-animated models, can be incomplete (comes with normals, but not with tangents), etc.), and thus support for "gts" is removed from our model code.

    References #100.

  6. Carsten Fuchs reporter

    (In [482]) Model code: Removed the remaining, obsolete and unused "gts" (given tangent space) code.

    "Given tangent space" is when our model code doesn't compute the normals and tangent vectors itself, but relies on those found in the file. This, however, is problematic in many regards (requires extra storage, works only for non-animated models, can be incomplete (comes with normals, but not with tangents), etc.), and thus support for "gts" is removed from our model code.

    Closes #100.

  7. Log in to comment