psychopy.tools.mathtools.fixTangentHandedness

psychopy.tools.mathtools.fixTangentHandedness(tangents, normals, bitangents, out=None, dtype=None)[source]

Ensure the handedness of tangent vectors are all the same.

Often 3D computed tangents may not have the same handedness due to how texture coordinates are specified. This function takes input surface vectors are ensures that tangents have the same handedness. Use this function if you notice that normal mapping shading appears reversed with respect to the incident light direction. The output array of corrected tangents can be used inplace of the original.

Parameters:
  • tangents (array_like) – Input Nx3 arrays of triangle tangents, normals and bitangents. All arrays must have the same size.

  • normals (array_like) – Input Nx3 arrays of triangle tangents, normals and bitangents. All arrays must have the same size.

  • bitangents (array_like) – Input Nx3 arrays of triangle tangents, normals and bitangents. All arrays must have the same size.

  • out (ndarray, optional) – Optional output array for tangents. If not specified, a new array of tangents will be allocated.

  • dtype (dtype or str, optional) – Data type for computations can either be ‘float32’ or ‘float64’. If out is specified, the data type of out is used and this argument is ignored. If out is not provided, ‘float64’ is used by default.

Returns:

Array of tangents with handedness corrected.

Return type:

ndarray


Back to top