Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Anisotropy rotation mismatch? #555

Open
echadwick-artist opened this issue Jul 10, 2024 · 1 comment
Open

Anisotropy rotation mismatch? #555

echadwick-artist opened this issue Jul 10, 2024 · 1 comment

Comments

@echadwick-artist
Copy link
Contributor

Anisotropy seems to be rendering perpendicular to the angle shown in every other glTF renderer.

image
Left object is without anisotropy, right object is with anisotropy.

All screenshots are using the "Studio" hdr from Babylonjs: https://github.com/BabylonJS/Assets/blob/master/environments/studioSoftbox2Umbrellas_panorama_radiance.hdr

For the object with anisotropy there are two materials: "spiral-anisotropy" for the flat sides with the circular grooves, and "grooved-anisotropy" for the curved part with the linear grooves. The spiral material is using an anisotropyTexture, the grooved material is not (anisotropyRotation alone controls the angle).

Materials on the object with anisotropy:

    {
      "extensions": {
        "KHR_materials_anisotropy": {
          "anisotropyStrength": 1,
          "anisotropyRotation": 1.6
        }
      },
      "name": "grooved-anisotropy",
      "normalTexture": {
        "extensions": {
          "KHR_texture_transform": {
            "rotation": 1.5707963705062866,
            "scale": [
              6,
              2
            ]
          }
        },
        "index": 2,
        "scale": 0.5
      },
      "pbrMetallicRoughness": {
        "baseColorFactor": [
          1,
          1,
          1,
          1
        ],
        "baseColorTexture": {
          "index": 1
        },
        "metallicRoughnessTexture": {
          "index": 3
        }
      }
    },
    {
      "extensions": {
        "KHR_materials_anisotropy": {
          "anisotropyStrength": 1,
          "anisotropyRotation": 1.6,
          "anisotropyTexture": {
            "index": 4
          }
        }
      },
      "name": "spiral-anisotropy",
      "normalTexture": {
        "index": 0,
        "scale": 0.5
      },
      "pbrMetallicRoughness": {
        "baseColorFactor": [
          0.5795467495918274,
          0.2715774476528168,
          0.18354901671409607,
          1
        ],
        "roughnessFactor": 0.1
      }
    },

compare_anisotropy.zip

@UX3D-kanzler
Copy link
Contributor

Upon further analyzing this issue I came to the conclusion that tangents are calculated differently. The discrepancy in the renderings is subsequently the result of anisotropy-rotation being calculated in tangent space.
The given file does not include tangents for the meshes. In this case Sample Viewer uses MikkTSpace to calculate tangents globally as suggested by the specification.

If you inspect carefully the Babylon rendering you see the individual triangles of the mesh as a result of tangents being calculated locally in the shader:
babylon-no-tangents-crop

I have created a version of your file that includes tangents in the mesh:
compare_anisotropy_tangents.zip

In this case, the renderings of Babylon and Sample Viewer show the same rotation for anisotropy:

Sample Viewer:
sample-viewer-tangents

Babylon:
babylon-tangents

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants