question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Normal is not correct when switching Variant in webgl_loader_gltf_variants

See original GitHub issue

Describe the bug

I tried the sample KHR_materials_variants extension of glTF. However, when I switch the Variant from midnight to beach, Normal does not seem to be correct.

To Reproduce

  1. Go to https://threejs.org/examples/?q=variant#webgl_loader_gltf_variants
  2. Switch the Variant from midnight to beach
  3. Look at the logo on the side of the shoe.

Expected behavior

Since this model refers to the same normal.jpg, the expected behavior is that the unevenness will not change.

Screenshots

Variant image
midnight image
beach image

Platform:

  • Device: MacBook Air
  • OS: Windows 10 (BootCamp)
  • Browser: Chrome 87.0.4280.141
  • Three.js version: r124

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:2
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

5reactions
elalishcommented, Jan 25, 2021

Well, I gave it a try and no such luck. assignFinalMaterial negates normalScale.y every time, so it ends up switching back and forth as you swap back to already-loaded variants. I think that line needs to move inside the cached ClonedMaterial block. I’ll work up a PR.

2reactions
donmccurdycommented, Jan 25, 2021

As @Mugen87 points out, the assignFinalMaterial would normally do some adjustments to materials based on the mesh they’re attached to, as we need to know whether the geometry has tangents or not. See https://github.com/mrdoob/three.js/issues/11438#issuecomment-501942328. Variants are applied well after the model was loaded, outside of GLTFLoader, and the example wouldn’t know about these details.

Ideally this model would contain vertex tangents… Blender can generate them, but won’t read/write the variants, so unfortunately that’s difficult to add at the moment. With vertex tangents this would not be an issue.

Perhaps https://github.com/mrdoob/three.js/pull/20789 would also help fix this, but I’m still worried about several parts of that.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Early discussion around asset variants · Issue #1569 - GitHub
This means, any variant can explicitly change a scalar, color value, texture, material, primitive, mesh or whatever a specific variant requires.
Read more >
Efficiently rendering glTF models | WebGPU ... - GitHub Pages
A walkthrough of building a basic, efficient glTF renderer with WebGPU.
Read more >
glTF 2.0 — Blender Manual - Import-Export
You can switch Variant, by selecting the variant you want to display, then clicking on Display Variant. You can switch to default materials...
Read more >
Beware of GLTF - Unity Forum
I'm using Siccity's GLTF plugin to load gitf file from web, it works well in Unity Editor, but when I build an iOS...
Read more >
GLTFLoader – three.js docs
A loader for glTF 2.0 resources. glTF (GL Transmission Format) is an open format specification for efficient delivery and loading of 3D content....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found