Skip to content

ComputeTangentFrameEx #1

@walbourn

Description

@walbourn

The basic ComputeNormals and ComputeTangentFrame do not perform any vertex splits, so artifacts can be found on large angle changes.

An alternative version is needed which would be able to duplicate vertices to resolve these problems.

enum CTF_FLAGS
{
   CTF_DEFAULT = 0x0,
       // Default is to compute normals using weight-by-angle

    CTF_WEIGHT_BY_AREA = 0x1,
        // Computes normals using weight-by-area

    CTF_WEIGHT_EQUAL = 0x2,
        // Compute normals with equal weights

    CTF_WIND_CW = 0x4,
        // Vertices are clock-wise (defaults to CCW)

    CTF_DONT_ORTHOGONALIZE = 0x10,
    CTF_ORTHOGONALIZE_FROM_U = 0x20,
    CTF_ORTHOGONALIZE_FROM_V = 0x40,

    CTF_DONT_NORMALIZE_PARTIALS = 0x80,

    CTF_WRAP_U = 0x100,
    CTF_WRAP_V = 0x200,
    CTF_WRAP_UV = 0x300,
};

struct CTFVertex
{
    uint32_t vertex; // index of the 'original' vertex
    XMFLOAT3 normal;
    XMFLOAT4 tangent; // .w is handedness
    XMFLOAT3 bitangent;
};

HRESULT ComputeTangentFrameEx(
   _In_reads_(nFaces*3) const uint16_t* indices, _In_ size_t nFaces,
   _In_reads_(nVerts) const XMFLOAT3* positions,
   _In_reads_(nVerts) const XMFLOAT2* txtcoords, _In_ size_t nVerts, 
   _In_reads_(nFaces*3) const uint32_t* adjacency,
   _In_ DWORD flags,
   _In_ float partialEdgeThreshold,
   _In_ float singularPointThreshold,
   _In_ float normalEdgeThreshold,
   _Inout_ std::vector<CTFVertex>& frames, _Out_ size_t& nDupVerts );

HRESULT ComputeTangentFrameEx(
   _In_reads_(nFaces*3) const uint32_t* indices, _In_ size_t nFaces,
   _In_reads_(nVerts) const XMFLOAT3* positions,
   _In_reads_(nVerts) const XMFLOAT2* txtcoords, _In_ size_t nVerts, 
   _In_reads_(nFaces*3) const uint32_t* adjacency,
   _In_ DWORD flags,
   _In_ float partialEdgeThreshold,
   _In_ float singularPointThreshold,
   _In_ float normalEdgeThreshold,
   _Inout_ std::vector<CTFVertex>& frames, _Out_ size_t& nDupVerts );

The D3DXComputeTangentFrameEx function supported vertex splitting based on various thresholds.

The real question is if anyone needs the full original D3DX9 algorithm with all it's complex 'singularity group' handling, or if the current functionality is sufficient for modern needs.

At a minimum, there needs to be a duplicate vertices version to handle mirrored seams...

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions